diff options
Diffstat (limited to 'lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK')
-rw-r--r-- | lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.c | 108 | ||||
-rw-r--r-- | lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.h | 93 |
2 files changed, 201 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.c b/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.c new file mode 100644 index 000000000..68420d231 --- /dev/null +++ b/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "hal.h" | ||
18 | |||
19 | /** | ||
20 | * @brief PAL setup. | ||
21 | * @details Digital I/O ports static configuration as defined in @p board.h. | ||
22 | * This variable is used by the HAL when initializing the PAL driver. | ||
23 | */ | ||
24 | #if HAL_USE_PAL || defined(__DOXYGEN__) | ||
25 | const PALConfig pal_default_config = | ||
26 | { | ||
27 | {VAL_PIOA_ODSR, VAL_PIOA_OSR, VAL_PIOA_PUSR}, | ||
28 | #if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \ | ||
29 | (SAM7_PLATFORM == SAM7X512) || (SAM7_PLATFORM == SAM7A3) | ||
30 | {VAL_PIOB_ODSR, VAL_PIOB_OSR, VAL_PIOB_PUSR} | ||
31 | #endif | ||
32 | }; | ||
33 | #endif | ||
34 | |||
35 | /* | ||
36 | * SYS IRQ handling here. | ||
37 | */ | ||
38 | static CH_IRQ_HANDLER(SYSIrqHandler) { | ||
39 | |||
40 | CH_IRQ_PROLOGUE(); | ||
41 | |||
42 | if (AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS) { | ||
43 | (void) AT91C_BASE_PITC->PITC_PIVR; | ||
44 | chSysLockFromIsr(); | ||
45 | chSysTimerHandlerI(); | ||
46 | chSysUnlockFromIsr(); | ||
47 | } | ||
48 | |||
49 | #if USE_SAM7_DBGU_UART | ||
50 | if (AT91C_BASE_DBGU->DBGU_CSR & | ||
51 | (AT91C_US_RXRDY | AT91C_US_TXRDY | AT91C_US_PARE | AT91C_US_FRAME | AT91C_US_OVRE | AT91C_US_RXBRK)) { | ||
52 | sd_lld_serve_interrupt(&SDDBG); | ||
53 | } | ||
54 | #endif | ||
55 | AT91C_BASE_AIC->AIC_EOICR = 0; | ||
56 | CH_IRQ_EPILOGUE(); | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | * Early initialization code. | ||
61 | * This initialization must be performed just after stack setup and before | ||
62 | * any other initialization. | ||
63 | */ | ||
64 | void __early_init(void) { | ||
65 | |||
66 | /* Watchdog disabled.*/ | ||
67 | AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS; | ||
68 | |||
69 | at91sam7_clock_init(); | ||
70 | } | ||
71 | |||
72 | #if HAL_USE_MMC_SPI | ||
73 | /* Board-related functions related to the MMC_SPI driver.*/ | ||
74 | bool mmc_lld_is_card_inserted(MMCDriver *mmcp) { | ||
75 | |||
76 | (void)mmcp; | ||
77 | return !palReadPad(IOPORT2, PIOB_MMC_CP); | ||
78 | } | ||
79 | |||
80 | bool mmc_lld_is_write_protected(MMCDriver *mmcp) { | ||
81 | |||
82 | (void)mmcp; | ||
83 | return palReadPad(IOPORT2, PIOB_MMC_WP); | ||
84 | } | ||
85 | #endif | ||
86 | |||
87 | /* | ||
88 | * Board-specific initialization code. | ||
89 | */ | ||
90 | void boardInit(void) { | ||
91 | |||
92 | /* | ||
93 | * PIT Initialization. | ||
94 | */ | ||
95 | AIC_ConfigureIT(AT91C_ID_SYS, | ||
96 | AT91C_AIC_SRCTYPE_HIGH_LEVEL | (AT91C_AIC_PRIOR_HIGHEST - 1), | ||
97 | SYSIrqHandler); | ||
98 | AIC_EnableIT(AT91C_ID_SYS); | ||
99 | AT91C_BASE_PITC->PITC_PIMR = (MCK / 16 / CH_FREQUENCY) - 1; | ||
100 | AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN | AT91C_PITC_PITIEN; | ||
101 | |||
102 | /* | ||
103 | * RTS/CTS pins enabled for USART0 only. | ||
104 | */ | ||
105 | AT91C_BASE_PIOA->PIO_PDR = AT91C_PA3_RTS0 | AT91C_PA4_CTS0; | ||
106 | AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA4; | ||
107 | AT91C_BASE_PIOA->PIO_PPUDR = AT91C_PIO_PA3 | AT91C_PIO_PA4; | ||
108 | } | ||
diff --git a/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.h b/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.h new file mode 100644 index 000000000..7ca472e8b --- /dev/null +++ b/lib/chibios/os/hal/boards/STUDIEL_AT91SAM7A3_EK/board.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _BOARD_H_ | ||
18 | #define _BOARD_H_ | ||
19 | |||
20 | /* | ||
21 | * Setup for the Studiel AT91SAM7A3-EK board. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | * Board identifier. | ||
26 | */ | ||
27 | #define BOARD_STUDIEL_AT91SAM7A3_EK | ||
28 | #define BOARD_NAME "Studiel AT91SAM7A3-EK eval. board" | ||
29 | |||
30 | /* | ||
31 | * Select your platform by modifying the following line. | ||
32 | */ | ||
33 | #if !defined(SAM7A3_PLATFORM) | ||
34 | #define SAM7_PLATFORM SAM7A3 | ||
35 | #endif | ||
36 | |||
37 | #include "at91sam7.h" | ||
38 | |||
39 | #define CLK 18432000 | ||
40 | #define MCK 48054857 | ||
41 | |||
42 | /* | ||
43 | * I/O definitions. | ||
44 | */ | ||
45 | #define PIOA_RXD0 2 | ||
46 | #define PIOA_RXD0_MASK (1 << PIOA_RXD0) | ||
47 | #define PIOA_TXD0 3 | ||
48 | #define PIOA_TXD0_MASK (1 << PIOA_TXD0) | ||
49 | #define PIOA_LED1 20 | ||
50 | #define PIOA_LED1_MASK (1 << PIOA_LED1) | ||
51 | #define PIOA_LED2 21 | ||
52 | #define PIOA_LED2_MASK (1 << PIOA_LED2) | ||
53 | #define PIOA_LED3 24 | ||
54 | #define PIOA_LED3_MASK (1 << PIOA_LED3) | ||
55 | #define PIOA_LED4 25 | ||
56 | #define PIOA_LED4_MASK (1 << PIOA_LED4) | ||
57 | // mmc-spi | ||
58 | #define PIOA_SPI0_NSS 14 | ||
59 | #define PIOA_SPI0_NSS_MASK (1 << PIOA_SPI0_NSS) | ||
60 | #define PIOA_SPI0_MISO 15 | ||
61 | #define PIOA_SPI0_MISO_MASK (1 << PIOA_SPI0_MISO) | ||
62 | #define PIOA_SPI0_MOSI 16 | ||
63 | #define PIOA_SPI0_MOSI_MASK (1 << PIOA_SPI0_MOSI) | ||
64 | #define PIOA_SPI0_CLK 17 | ||
65 | #define PIOA_SPI0_CLK_MASK (1 << PIOA_SPI0_CLK) | ||
66 | |||
67 | /* | ||
68 | * Initial I/O setup. | ||
69 | */ | ||
70 | /* Output data. */ | ||
71 | #define VAL_PIOA_ODSR 0x00000000 | ||
72 | /* Direction. */ | ||
73 | #define VAL_PIOA_OSR 0x00000000 | PIOA_LED1_MASK | PIOA_LED2_MASK | \ | ||
74 | PIOA_LED3_MASK | PIOA_LED4_MASK | ||
75 | /* Pull-up. */ | ||
76 | #define VAL_PIOA_PUSR 0xFFFFFFFF | ||
77 | |||
78 | #define VAL_PIOB_ODSR 0x00000000 /* Output data. */ | ||
79 | #define VAL_PIOB_OSR 0x00000000 /* Direction. */ | ||
80 | #define VAL_PIOB_PUSR 0xFFFFFFFF /* Pull-up. */ | ||
81 | |||
82 | |||
83 | #if !defined(_FROM_ASM_) | ||
84 | #ifdef __cplusplus | ||
85 | extern "C" { | ||
86 | #endif | ||
87 | void boardInit(void); | ||
88 | #ifdef __cplusplus | ||
89 | } | ||
90 | #endif | ||
91 | #endif /* _FROM_ASM_ */ | ||
92 | |||
93 | #endif /* _BOARD_H_ */ | ||