aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c')
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c48
1 files changed, 9 insertions, 39 deletions
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c
index efb9af267..c0fa19e5f 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED/main.c
@@ -16,30 +16,20 @@
#include "ch.h"
#include "hal.h"
-#include "chprintf.h"
-
-#define AICREDIR_KEY 0x5B6C0E26u
/*
- * Blinker thread.
+ * LED blinker thread, times are in milliseconds.
*/
-static THD_WORKING_AREA(waThread1, 128);
+static THD_WORKING_AREA(waThread1, 512);
static THD_FUNCTION(Thread1, arg) {
(void)arg;
- bool ld = true;
chRegSetThreadName("blinker");
while (true) {
- /* TODO: Replace with toggle function of GPIO */
- if(ld){
- PIOA->PIO_PIO_[1].S_PIO_CODR = S_PIO_CODR_P5;
- ld = false;
- }
- else{
- PIOA->PIO_PIO_[1].S_PIO_SODR = S_PIO_SODR_P5;
- ld = true;
- }
+ PIOA->PIO_PIO_[1].S_PIO_CODR = S_PIO_CODR_P5;
+ chThdSleepMilliseconds(500);
+ PIOA->PIO_PIO_[1].S_PIO_SODR = S_PIO_SODR_P5;
chThdSleepMilliseconds(500);
}
}
@@ -59,39 +49,19 @@ int main(void) {
halInit();
chSysInit();
- /* Redirect interrupts */
- uint32_t aicredir = SFR_AICREDIR_AICREDIRKEY((uint32_t)(AICREDIR_KEY));
- SFR->SFR_AICREDIR = (aicredir ^ SFR->SFR_SN1);
-
- /*
- * TODO: Replace with PAL functions
- * Led green
- */
- PIOA->PIO_PIO_[1].S_PIO_SIOSR |= S_PIO_SIOSR_P5;
- PIOA->PIO_PIO_[1].S_PIO_MSKR = S_PIO_MSKR_MSK5_ENABLED;
- PIOA->PIO_PIO_[1].S_PIO_CFGR = S_PIO_CFGR_DIR_OUTPUT;
- PIOA->PIO_PIO_[1].S_PIO_SODR = S_PIO_SODR_P5 ;
-
/*
- * TODO: Replace with PAL functions
- * Uart0 pins PB26 rx and PB27 tx (J18)
+ * Activates the serial driver 0 using the driver default configuration.
*/
- PIOA->PIO_PIO_[1].S_PIO_SIOSR |= S_PIO_SIOSR_P26 | S_PIO_SIOSR_P27;
- /* select pins */
- PIOA->PIO_PIO_[1].S_PIO_MSKR = S_PIO_MSKR_MSK26 | S_PIO_MSKR_MSK27;
- /* pins are driven by func_periph_c (uart0 mode) */
- PIOA->PIO_PIO_[1].S_PIO_CFGR = S_PIO_CFGR_FUNC_PERIPH_C;
-
sdStart(&SD0, NULL);
- chprintf((BaseSequentialStream *)&SD0, "ChibiOS is running!\r\n\n");
+
/*
- * Creates the example thread.
+ * Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
* Normal main() thread activity, in this demo it does nothing except
- * increasing the minutes counter.
+ * sleeping in a loop and check the button state.
*/
while (true) {
chThdSleepMilliseconds(500);