From 43def70685c2b8cfc998a4a906d6b209aeb974ac Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 11 Jul 2009 14:36:20 +0000 Subject: Completed PAL support for AT91SAM7X. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1057 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7X-GCC/Makefile | 1 + demos/ARM7-AT91SAM7X-GCC/board.c | 33 ++++++++++++++++++++++----------- demos/ARM7-AT91SAM7X-GCC/board.h | 13 +++++++++++-- 3 files changed, 34 insertions(+), 13 deletions(-) (limited to 'demos/ARM7-AT91SAM7X-GCC') diff --git a/demos/ARM7-AT91SAM7X-GCC/Makefile b/demos/ARM7-AT91SAM7X-GCC/Makefile index 728167a6d..db19978c8 100644 --- a/demos/ARM7-AT91SAM7X-GCC/Makefile +++ b/demos/ARM7-AT91SAM7X-GCC/Makefile @@ -49,6 +49,7 @@ include ../../test/test.mk # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. CSRC = ../../ports/ARM7/chcore.c \ + ../../ports/ARM7-AT91SAM7X/pal_lld.c \ ../../ports/ARM7-AT91SAM7X/sam7x_serial.c \ ${KERNSRC} \ ${TESTSRC} \ diff --git a/demos/ARM7-AT91SAM7X-GCC/board.c b/demos/ARM7-AT91SAM7X-GCC/board.c index 02ac5046d..aac51cf0c 100644 --- a/demos/ARM7-AT91SAM7X-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-GCC/board.c @@ -57,6 +57,15 @@ static CH_IRQ_HANDLER(SYSIrqHandler) { CH_IRQ_EPILOGUE(); } +/* + * Digital I/O ports static configuration as defined in @p board.h. + */ +static const AT91SAM7XPIOConfig config = +{ + {VAL_PIOA_ODSR, VAL_PIOA_OSR, VAL_PIOA_PUSR}, + {VAL_PIOB_ODSR, VAL_PIOB_OSR, VAL_PIOB_PUSR} +}; + /* * Early initialization code. * This initialization is performed just after reset before BSS and DATA @@ -100,7 +109,7 @@ void hwinit0(void) { /* * PIO initialization. */ - palInit(); + palInit(&config); } /* @@ -126,24 +135,26 @@ void hwinit1(void) { * LCD pins setup. */ palClearPad(IOPORT_B, PIOB_LCD_BL); - AT91C_BASE_PIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure as output. - AT91C_BASE_PIOB->PIO_PPUDR = PIOB_LCD_BL_MASK; // Disable internal pullup resistor. + palSetPadMode(IOPORT_B, PIOB_LCD_BL, PAL_MODE_OUTPUT_PUSHPULL); palSetPad(IOPORT_A, PIOA_LCD_RESET); - AT91C_BASE_PIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure as output. - AT91C_BASE_PIOA->PIO_PPUDR = PIOA_LCD_RESET_MASK; // Disable internal pullup resistor. + palSetPadMode(IOPORT_A, PIOA_LCD_RESET, PAL_MODE_OUTPUT_PUSHPULL); /* - * Joystick and buttons, disable pullups, already inputs. + * Joystick and buttons setup. */ - AT91C_BASE_PIOA->PIO_PPUDR = PIOA_B1_MASK | PIOA_B2_MASK | PIOA_B3_MASK | - PIOA_B4_MASK | PIOA_B5_MASK; - AT91C_BASE_PIOB->PIO_PPUDR = PIOB_SW1_MASK | PIOB_SW2_MASK; + palSetGroupMode(IOPORT_A, + PIOA_B1_MASK | PIOA_B2_MASK | PIOA_B3_MASK | + PIOA_B4_MASK | PIOA_B5_MASK, + PAL_MODE_INPUT); + palSetGroupMode(IOPORT_B, PIOB_SW1_MASK | PIOB_SW2_MASK, PAL_MODE_INPUT); /* - * MMC/SD slot, disable pullups, already inputs. + * MMC/SD slot setup. */ - AT91C_BASE_SYS->PIOB_PPUDR = PIOB_MMC_WP_MASK | PIOB_MMC_CP_MASK; + palSetGroupMode(IOPORT_B, + PIOB_MMC_WP_MASK | PIOB_MMC_CP_MASK, + PAL_MODE_INPUT); /* * PIT Initialization. diff --git a/demos/ARM7-AT91SAM7X-GCC/board.h b/demos/ARM7-AT91SAM7X-GCC/board.h index fe9219aa3..c56f50258 100644 --- a/demos/ARM7-AT91SAM7X-GCC/board.h +++ b/demos/ARM7-AT91SAM7X-GCC/board.h @@ -20,15 +20,24 @@ #ifndef _BOARD_H_ #define _BOARD_H_ -#ifndef AT91SAM7X256_H #include "at91lib/AT91SAM7X256.h" -#endif #define BOARD_OLIMEX_SAM7_EX256 #define CLK 18432000 #define MCK 48054857 +/* + * Initial I/O setup. + */ +#define VAL_PIOA_ODSR 0x00000000 /* Output data. */ +#define VAL_PIOA_OSR 0x00000000 /* Direction. */ +#define VAL_PIOA_PUSR 0xFFFFFFFF /* Pull-up. */ + +#define VAL_PIOB_ODSR 0x00000000 /* Output data. */ +#define VAL_PIOB_OSR 0x00000000 /* Direction. */ +#define VAL_PIOB_PUSR 0xFFFFFFFF /* Pull-up. */ + /* * I/O definitions. */ -- cgit v1.2.3