1.1 --- a/stage2/minipc_gpio.c Wed Jul 12 15:46:53 2017 +0200
1.2 +++ b/stage2/minipc_gpio.c Sun Jul 23 17:44:24 2017 +0200
1.3 @@ -19,10 +19,11 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 +#include "minipc_gpio.h"
1.8 #include "minipc.h"
1.9 #include <stdint.h>
1.10
1.11 -#define PIN(x) (3 * 32 + x)
1.12 +#define PIN(x) gpio_global_pin(3, x)
1.13
1.14 const uint8_t GPIO_KEYIN_ROW[GPIO_KEYIN_COUNT] = {
1.15 0, 1, 2, 3, 4, 5, 6, 7 /* if jz_keypad.c is understood correctly */
2.1 --- a/stage2/minipc_gpio.h Wed Jul 12 15:46:53 2017 +0200
2.2 +++ b/stage2/minipc_gpio.h Sun Jul 23 17:44:24 2017 +0200
2.3 @@ -26,6 +26,8 @@
2.4
2.5 #include <stdint.h>
2.6
2.7 +#define gpio_global_pin(port, pin) (port * 32 + pin)
2.8 +
2.9 extern const uint8_t GPIO_KEYIN_ROW[GPIO_KEYIN_COUNT];
2.10 extern const uint8_t GPIO_KEYOUT_COL[GPIO_KEYOUT_COUNT];
2.11
3.1 --- a/stage2/nanonote_gpio.c Wed Jul 12 15:46:53 2017 +0200
3.2 +++ b/stage2/nanonote_gpio.c Sun Jul 23 17:44:24 2017 +0200
3.3 @@ -19,20 +19,21 @@
3.4 * Boston, MA 02110-1301, USA
3.5 */
3.6
3.7 +#include "nanonote_gpio.h"
3.8 #include "nanonote.h"
3.9 #include <stdint.h>
3.10
3.11 -#define PIN(x) (3 * 32 + 18 + x)
3.12 +#define PIN(x) gpio_global_pin(3, 18 + x)
3.13
3.14 const uint8_t GPIO_KEYIN_ROW[GPIO_KEYIN_COUNT] = {
3.15 - 0, 1, 2, 3, 4, 5, 6, 7
3.16 + PIN(0), PIN(1), PIN(2), PIN(3), PIN(4), PIN(5), PIN(6), PIN(8)
3.17 };
3.18
3.19 #undef PIN
3.20 -#define PIN(x) (2 * 32 + 10 + x)
3.21 +#define PIN(x) gpio_global_pin(2, 10 + x)
3.22
3.23 const uint8_t GPIO_KEYOUT_COL[GPIO_KEYOUT_COUNT] = {
3.24 - PIN(0), PIN(1), PIN(2), PIN(3), PIN(4), PIN(5), PIN(6), PIN(8),
3.25 + PIN(0), PIN(1), PIN(2), PIN(3), PIN(4), PIN(5), PIN(6), PIN(7),
3.26 };
3.27
3.28 #undef PIN
4.1 --- a/stage2/nanonote_gpio.h Wed Jul 12 15:46:53 2017 +0200
4.2 +++ b/stage2/nanonote_gpio.h Sun Jul 23 17:44:24 2017 +0200
4.3 @@ -26,6 +26,8 @@
4.4
4.5 #include <stdint.h>
4.6
4.7 +#define gpio_global_pin(port, pin) (port * 32 + pin)
4.8 +
4.9 extern const uint8_t GPIO_KEYIN_ROW[GPIO_KEYIN_COUNT];
4.10 extern const uint8_t GPIO_KEYOUT_COL[GPIO_KEYOUT_COUNT];
4.11
5.1 --- a/stage2/task_gpio.c Wed Jul 12 15:46:53 2017 +0200
5.2 +++ b/stage2/task_gpio.c Sun Jul 23 17:44:24 2017 +0200
5.3 @@ -33,10 +33,11 @@
5.4
5.5 for (virtual = TASK_GPIO_BASE, physical = GPIO_BASE_PHYSICAL;
5.6 virtual < (uint32_t) TASK_GPIO_BASE + (uint32_t) GPIO_REGION_SIZE;
5.7 - virtual += page_size(STAGE2_PAGESIZE), physical += page_size(STAGE2_PAGESIZE))
5.8 + virtual = next_page(virtual, STAGE2_PAGESIZE),
5.9 + physical = next_page(physical, STAGE2_PAGESIZE))
5.10 {
5.11 init_page_table(STAGE2_PAGE_TABLE_BASE, virtual, physical,
5.12 - page_size(STAGE2_PAGESIZE), TLB_UNCACHED | TLB_DIRTY | TLB_VALID, task);
5.13 + STAGE2_PAGESIZE, TLB_UNCACHED | TLB_DIRTY | TLB_VALID, task);
5.14 }
5.15 }
5.16
6.1 --- a/stage2/tasks/keyscan.c Wed Jul 12 15:46:53 2017 +0200
6.2 +++ b/stage2/tasks/keyscan.c Sun Jul 23 17:44:24 2017 +0200
6.3 @@ -56,7 +56,7 @@
6.4 task_gpio_as_input(GPIO_KEYOUT_COL[pin]);
6.5 }
6.6
6.7 - task_gpio_as_input(GPIO_POWER);
6.8 + task_gpio_as_input(gpio_global_pin(GPIO_PORT_POWER, GPIO_POWER));
6.9 }
6.10
6.11 /* Tasks. */
6.12 @@ -74,9 +74,11 @@
6.13 for (column = 0; column < GPIO_KEYOUT_COUNT; column++)
6.14 {
6.15 task_gpio_as_output(GPIO_KEYOUT_COL[column]);
6.16 + task_gpio_clear_pin(GPIO_KEYOUT_COL[column]);
6.17 +
6.18 + /* Employ a delay to avoid catching the last column's reading. */
6.19
6.20 for (unsigned int delay = 0; delay < 1000; delay++)
6.21 - task_gpio_clear_pin(GPIO_KEYOUT_COL[column]);
6.22
6.23 value = 0;
6.24
6.25 @@ -92,7 +94,7 @@
6.26 task_gpio_as_input(GPIO_KEYOUT_COL[column]);
6.27 }
6.28
6.29 - plot_value(100, 110, 0, 80, task_gpio_get_pin(GPIO_POWER) ? 0xff : 0);
6.30 + plot_value(100, 110, 0, 80, task_gpio_get_pin(gpio_global_pin(GPIO_PORT_POWER, GPIO_POWER)) ? 0xff : 0);
6.31 }
6.32 }
6.33