Using existing atmel led routines

There is a config file called led.c in the atmel softpack source code
which provides routines for configuring, setting and clearing the LEDs.
This commit is contained in:
Christina Quast
2014-12-16 10:54:59 +01:00
parent 0aca529375
commit 0f1b36f0ae
3 changed files with 20 additions and 20 deletions

View File

@@ -48,7 +48,7 @@ MEMORIES = flash
# TRACE_LEVEL_ERROR 2
# TRACE_LEVEL_FATAL 1
# TRACE_LEVEL_NO_TRACE 0
TRACE_LEVEL = 4
TRACE_LEVEL = 5
# Optimization level, put in comment for debugging
OPTIMIZATION = -O0
@@ -126,7 +126,7 @@ VPATH += src_board src_sam3s cmsis
# Objects built from C source files
C_CMSIS = core_cm3.o
C_LOWLEVEL = board_cstartup_gnu.o board_lowlevel.o syscalls.o exceptions.o
C_LIBLEVEL = spi.o pio.o pmc.o usart.o pio_it.o pio_capture.o uart_console.o iso7816_4.o wdt.o
C_LIBLEVEL = spi.o pio.o pmc.o usart.o pio_it.o pio_capture.o uart_console.o iso7816_4.o wdt.o led.o
C_APPLEVEL = main.o
C_OBJECTS = $(C_CMSIS) $(C_LOWLEVEL) $(C_LIBLEVEL) $(C_APPLEVEL)

View File

@@ -8,6 +8,7 @@
#include "board_lowlevel.h"
#include "uart_console.h"
#include "iso7816_4.h"
#include "led.h"
/** Highlevel */
#include "trace.h"
@@ -34,6 +35,13 @@
#define LED_RED PIO_PA17
#define LED_GREEN PIO_PA18
#define PIN_LED_RED {LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
#define PIN_LED_GREEN {LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
#define LED_NUM_RED 0
#define LED_NUM_GREEN 1
/** USART0 pin RX */
#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
/** USART0 pin TX */

View File

@@ -5,33 +5,25 @@
extern void UART_PutString(const char *str, int len);
/*----------------------------------------------------------------------------
* * Variables
* *----------------------------------------------------------------------------*/
const Pin redled = {LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT};
const Pin greenled = {LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT};
static const Pin *led;
void Configure_LED() {
PIO_Configure(&greenled, PIO_LISTSIZE(greenled));
PIO_Configure(&redled, PIO_LISTSIZE(redled));
PIO_Set(&redled);
PIO_Set(&greenled);
led = &redled;
void Configure_LEDs() {
LED_Configure(LED_NUM_RED);
LED_Configure(LED_NUM_GREEN);
}
int main() {
size_t ret = 0;
Configure_LED();
Configure_LEDs();
ret = printf("Clockval: %d\r\n", BOARD_MCK);
if (ret < 0){
PIO_Clear(&redled);
LED_Clear(LED_NUM_GREEN);
LED_Set(LED_NUM_RED);
} else {
PIO_Clear(&greenled);
LED_Clear(LED_NUM_RED);
LED_Set(LED_NUM_GREEN);
while (1) {
printf("Clockval**++????: %d\r\n", BOARD_MCK);
}