|
23 | 23 | extern "C" {
|
24 | 24 | #endif
|
25 | 25 |
|
26 |
| -// NOTE: TIMER0_BASE=(APBPERIPH_BASE + 0x10000) |
27 |
| -// TIMER1_BASE=(APBPERIPH_BASE + 0x10020) |
28 |
| -#define NU_MODNAME(MODBASE, SUBINDEX) ((MODBASE) | (SUBINDEX)) |
29 |
| -#define NU_MODBASE(MODNAME) ((MODNAME) & 0xFFFFFFE0) |
30 |
| -#define NU_MODSUBINDEX(MODNAME) ((MODNAME) & 0x0000001F) |
| 26 | +// NOTE: Check all module base addresses (XXX_BASE in BSP) for free bit fields to define module name |
| 27 | +// which encodes module base address and module index/subindex. |
| 28 | +#define NU_MODSUBINDEX_Pos 0 |
| 29 | +#define NU_MODSUBINDEX_Msk (0x1Ful << NU_MODSUBINDEX_Pos) |
| 30 | +#define NU_MODINDEX_Pos 20 |
| 31 | +#define NU_MODINDEX_Msk (0xFul << NU_MODINDEX_Pos) |
| 32 | + |
| 33 | +#define NU_MODNAME(MODBASE, INDEX, SUBINDEX) ((MODBASE) | ((INDEX) << NU_MODINDEX_Pos) | ((SUBINDEX) << NU_MODSUBINDEX_Pos)) |
| 34 | +#define NU_MODBASE(MODNAME) ((MODNAME) & ~(NU_MODINDEX_Msk | NU_MODSUBINDEX_Msk)) |
| 35 | +#define NU_MODINDEX(MODNAME) (((MODNAME) & NU_MODINDEX_Msk) >> NU_MODINDEX_Pos) |
| 36 | +#define NU_MODSUBINDEX(MODNAME) (((MODNAME) & NU_MODSUBINDEX_Msk) >> NU_MODSUBINDEX_Pos) |
31 | 37 |
|
32 | 38 | #if 0
|
33 | 39 | typedef enum {
|
34 |
| - GPIO_A = (int) NU_MODNAME(GPIOA_BASE, 0), |
35 |
| - GPIO_B = (int) NU_MODNAME(GPIOB_BASE, 0), |
36 |
| - GPIO_C = (int) NU_MODNAME(GPIOC_BASE, 0), |
37 |
| - GPIO_D = (int) NU_MODNAME(GPIOD_BASE, 0), |
38 |
| - GPIO_E = (int) NU_MODNAME(GPIOE_BASE, 0), |
39 |
| - GPIO_F = (int) NU_MODNAME(GPIOF_BASE, 0), |
40 |
| - GPIO_G = (int) NU_MODNAME(GPIOG_BASE, 0), |
41 |
| - GPIO_H = (int) NU_MODNAME(GPIOH_BASE, 0), |
42 |
| - GPIO_I = (int) NU_MODNAME(GPIOI_BASE, 0) |
| 40 | + GPIO_A = (int) NU_MODNAME(GPIOA_BASE, 0, 0), |
| 41 | + GPIO_B = (int) NU_MODNAME(GPIOB_BASE, 1, 0), |
| 42 | + GPIO_C = (int) NU_MODNAME(GPIOC_BASE, 2, 0), |
| 43 | + GPIO_D = (int) NU_MODNAME(GPIOD_BASE, 3, 0), |
| 44 | + GPIO_E = (int) NU_MODNAME(GPIOE_BASE, 4, 0), |
| 45 | + GPIO_F = (int) NU_MODNAME(GPIOF_BASE, 5, 0), |
| 46 | + GPIO_G = (int) NU_MODNAME(GPIOG_BASE, 6, 0), |
| 47 | + GPIO_H = (int) NU_MODNAME(GPIOH_BASE, 7, 0), |
| 48 | + GPIO_I = (int) NU_MODNAME(GPIOI_BASE, 8, 0) |
43 | 49 | } GPIOName;
|
44 | 50 | #endif
|
45 | 51 |
|
46 | 52 | typedef enum {
|
47 |
| - ADC_0_0 = (int) NU_MODNAME(EADC_BASE, 0), |
48 |
| - ADC_0_1 = (int) NU_MODNAME(EADC_BASE, 1), |
49 |
| - ADC_0_2 = (int) NU_MODNAME(EADC_BASE, 2), |
50 |
| - ADC_0_3 = (int) NU_MODNAME(EADC_BASE, 3), |
51 |
| - ADC_0_4 = (int) NU_MODNAME(EADC_BASE, 4), |
52 |
| - ADC_0_5 = (int) NU_MODNAME(EADC_BASE, 5), |
53 |
| - ADC_0_6 = (int) NU_MODNAME(EADC_BASE, 6), |
54 |
| - ADC_0_7 = (int) NU_MODNAME(EADC_BASE, 7), |
| 53 | + ADC_0_0 = (int) NU_MODNAME(EADC_BASE, 0, 0), |
| 54 | + ADC_0_1 = (int) NU_MODNAME(EADC_BASE, 0, 1), |
| 55 | + ADC_0_2 = (int) NU_MODNAME(EADC_BASE, 0, 2), |
| 56 | + ADC_0_3 = (int) NU_MODNAME(EADC_BASE, 0, 3), |
| 57 | + ADC_0_4 = (int) NU_MODNAME(EADC_BASE, 0, 4), |
| 58 | + ADC_0_5 = (int) NU_MODNAME(EADC_BASE, 0, 5), |
| 59 | + ADC_0_6 = (int) NU_MODNAME(EADC_BASE, 0, 6), |
| 60 | + ADC_0_7 = (int) NU_MODNAME(EADC_BASE, 0, 7), |
55 | 61 |
|
56 |
| - ADC_1_0 = (int) NU_MODNAME(EADC_BASE, 8), |
57 |
| - ADC_1_1 = (int) NU_MODNAME(EADC_BASE, 9), |
58 |
| - ADC_1_2 = (int) NU_MODNAME(EADC_BASE, 10), |
59 |
| - ADC_1_3 = (int) NU_MODNAME(EADC_BASE, 11), |
60 |
| - ADC_1_4 = (int) NU_MODNAME(EADC_BASE, 12), |
61 |
| - ADC_1_5 = (int) NU_MODNAME(EADC_BASE, 13), |
62 |
| - ADC_1_6 = (int) NU_MODNAME(EADC_BASE, 14), |
63 |
| - ADC_1_7 = (int) NU_MODNAME(EADC_BASE, 15), |
| 62 | + ADC_1_0 = (int) NU_MODNAME(EADC_BASE, 1, 0), |
| 63 | + ADC_1_1 = (int) NU_MODNAME(EADC_BASE, 1, 1), |
| 64 | + ADC_1_2 = (int) NU_MODNAME(EADC_BASE, 1, 2), |
| 65 | + ADC_1_3 = (int) NU_MODNAME(EADC_BASE, 1, 3), |
| 66 | + ADC_1_4 = (int) NU_MODNAME(EADC_BASE, 1, 4), |
| 67 | + ADC_1_5 = (int) NU_MODNAME(EADC_BASE, 1, 5), |
| 68 | + ADC_1_6 = (int) NU_MODNAME(EADC_BASE, 1, 6), |
| 69 | + ADC_1_7 = (int) NU_MODNAME(EADC_BASE, 1, 7), |
64 | 70 | } ADCName;
|
65 | 71 |
|
66 | 72 | typedef enum {
|
67 |
| - UART_0 = (int) NU_MODNAME(UART0_BASE, 0), |
68 |
| - UART_1 = (int) NU_MODNAME(UART1_BASE, 0), |
69 |
| - UART_2 = (int) NU_MODNAME(UART2_BASE, 0), |
70 |
| - UART_3 = (int) NU_MODNAME(UART3_BASE, 0), |
71 |
| - UART_4 = (int) NU_MODNAME(UART4_BASE, 0), |
72 |
| - UART_5 = (int) NU_MODNAME(UART5_BASE, 0), |
| 73 | + UART_0 = (int) NU_MODNAME(UART0_BASE, 0, 0), |
| 74 | + UART_1 = (int) NU_MODNAME(UART1_BASE, 1, 0), |
| 75 | + UART_2 = (int) NU_MODNAME(UART2_BASE, 2, 0), |
| 76 | + UART_3 = (int) NU_MODNAME(UART3_BASE, 3, 0), |
| 77 | + UART_4 = (int) NU_MODNAME(UART4_BASE, 4, 0), |
| 78 | + UART_5 = (int) NU_MODNAME(UART5_BASE, 5, 0), |
73 | 79 | // FIXME: board-specific
|
74 | 80 | STDIO_UART = UART_3
|
75 | 81 | } UARTName;
|
76 | 82 |
|
77 | 83 | typedef enum {
|
78 |
| - SPI_0 = (int) NU_MODNAME(SPI0_BASE, 0), |
79 |
| - SPI_1 = (int) NU_MODNAME(SPI1_BASE, 0), |
80 |
| - SPI_2 = (int) NU_MODNAME(SPI2_BASE, 0), |
81 |
| - SPI_3 = (int) NU_MODNAME(SPI3_BASE, 0) |
| 84 | + SPI_0 = (int) NU_MODNAME(SPI0_BASE, 0, 0), |
| 85 | + SPI_1 = (int) NU_MODNAME(SPI1_BASE, 1, 0), |
| 86 | + SPI_2 = (int) NU_MODNAME(SPI2_BASE, 2, 0), |
| 87 | + SPI_3 = (int) NU_MODNAME(SPI3_BASE, 3, 0) |
82 | 88 | } SPIName;
|
83 | 89 |
|
84 | 90 | typedef enum {
|
85 |
| - I2C_0 = (int) NU_MODNAME(I2C0_BASE, 0), |
86 |
| - I2C_1 = (int) NU_MODNAME(I2C1_BASE, 0), |
87 |
| - I2C_2 = (int) NU_MODNAME(I2C2_BASE, 0), |
88 |
| - I2C_3 = (int) NU_MODNAME(I2C3_BASE, 0), |
89 |
| - I2C_4 = (int) NU_MODNAME(I2C4_BASE, 0) |
| 91 | + I2C_0 = (int) NU_MODNAME(I2C0_BASE, 0, 0), |
| 92 | + I2C_1 = (int) NU_MODNAME(I2C1_BASE, 1, 0), |
| 93 | + I2C_2 = (int) NU_MODNAME(I2C2_BASE, 2, 0), |
| 94 | + I2C_3 = (int) NU_MODNAME(I2C3_BASE, 3, 0), |
| 95 | + I2C_4 = (int) NU_MODNAME(I2C4_BASE, 4, 0) |
90 | 96 | } I2CName;
|
91 | 97 |
|
92 | 98 | typedef enum {
|
93 |
| - PWM_0_0 = (int) NU_MODNAME(PWM0_BASE, 0), |
94 |
| - PWM_0_1 = (int) NU_MODNAME(PWM0_BASE, 1), |
95 |
| - PWM_0_2 = (int) NU_MODNAME(PWM0_BASE, 2), |
96 |
| - PWM_0_3 = (int) NU_MODNAME(PWM0_BASE, 3), |
97 |
| - PWM_0_4 = (int) NU_MODNAME(PWM0_BASE, 4), |
98 |
| - PWM_0_5 = (int) NU_MODNAME(PWM0_BASE, 5), |
| 99 | + PWM_0_0 = (int) NU_MODNAME(PWM0_BASE, 0, 0), |
| 100 | + PWM_0_1 = (int) NU_MODNAME(PWM0_BASE, 0, 1), |
| 101 | + PWM_0_2 = (int) NU_MODNAME(PWM0_BASE, 0, 2), |
| 102 | + PWM_0_3 = (int) NU_MODNAME(PWM0_BASE, 0, 3), |
| 103 | + PWM_0_4 = (int) NU_MODNAME(PWM0_BASE, 0, 4), |
| 104 | + PWM_0_5 = (int) NU_MODNAME(PWM0_BASE, 0, 5), |
99 | 105 |
|
100 |
| - PWM_1_0 = (int) NU_MODNAME(PWM1_BASE, 0), |
101 |
| - PWM_1_1 = (int) NU_MODNAME(PWM1_BASE, 1), |
102 |
| - PWM_1_2 = (int) NU_MODNAME(PWM1_BASE, 2), |
103 |
| - PWM_1_3 = (int) NU_MODNAME(PWM1_BASE, 3), |
104 |
| - PWM_1_4 = (int) NU_MODNAME(PWM1_BASE, 4), |
105 |
| - PWM_1_5 = (int) NU_MODNAME(PWM1_BASE, 5) |
| 106 | + PWM_1_0 = (int) NU_MODNAME(PWM1_BASE, 1, 0), |
| 107 | + PWM_1_1 = (int) NU_MODNAME(PWM1_BASE, 1, 1), |
| 108 | + PWM_1_2 = (int) NU_MODNAME(PWM1_BASE, 1, 2), |
| 109 | + PWM_1_3 = (int) NU_MODNAME(PWM1_BASE, 1, 3), |
| 110 | + PWM_1_4 = (int) NU_MODNAME(PWM1_BASE, 1, 4), |
| 111 | + PWM_1_5 = (int) NU_MODNAME(PWM1_BASE, 1, 5) |
106 | 112 | } PWMName;
|
107 | 113 |
|
108 | 114 | typedef enum {
|
109 |
| - TIMER_0 = (int) NU_MODNAME(TIMER0_BASE, 0), |
110 |
| - TIMER_1 = (int) NU_MODNAME(TIMER1_BASE, 0), |
111 |
| - TIMER_2 = (int) NU_MODNAME(TIMER2_BASE, 0), |
112 |
| - TIMER_3 = (int) NU_MODNAME(TIMER3_BASE, 0) |
| 115 | + TIMER_0 = (int) NU_MODNAME(TIMER0_BASE, 0, 0), |
| 116 | + TIMER_1 = (int) NU_MODNAME(TIMER1_BASE, 1, 0), |
| 117 | + TIMER_2 = (int) NU_MODNAME(TIMER2_BASE, 2, 0), |
| 118 | + TIMER_3 = (int) NU_MODNAME(TIMER3_BASE, 3, 0) |
113 | 119 | } TIMERName;
|
114 | 120 |
|
115 | 121 | typedef enum {
|
116 |
| - RTC_0 = (int) NU_MODNAME(RTC_BASE, 0) |
| 122 | + RTC_0 = (int) NU_MODNAME(RTC_BASE, 0, 0) |
117 | 123 | } RTCName;
|
118 | 124 |
|
119 | 125 | typedef enum {
|
120 |
| - DMA_0 = (int) NU_MODNAME(PDMA_BASE, 0) |
| 126 | + DMA_0 = (int) NU_MODNAME(PDMA_BASE, 0, 0) |
121 | 127 | } DMAName;
|
122 | 128 |
|
123 | 129 | typedef enum {
|
124 |
| - SD_0_0 = (int) NU_MODNAME(SD_BASE, 0), |
125 |
| - SD_0_1 = (int) NU_MODNAME(SD_BASE, 1) |
| 130 | + SD_0_0 = (int) NU_MODNAME(SD_BASE, 0, 0), |
| 131 | + SD_0_1 = (int) NU_MODNAME(SD_BASE, 0, 1) |
126 | 132 | } SDName;
|
127 | 133 |
|
128 | 134 | typedef enum {
|
129 |
| - CAN_0 = (int) NU_MODNAME(CAN0_BASE, 0), |
130 |
| - CAN_1 = (int) NU_MODNAME(CAN1_BASE, 0) |
| 135 | + CAN_0 = (int) NU_MODNAME(CAN0_BASE, 0, 0), |
| 136 | + CAN_1 = (int) NU_MODNAME(CAN1_BASE, 1, 0) |
131 | 137 | } CANName;
|
132 | 138 |
|
133 | 139 | #ifdef __cplusplus
|
|
0 commit comments