From c731a9477bd4fbbadb4ac7c19726c4d5f812f461 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 13 Jun 2009 07:06:38 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1029 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7X-GCC/board.c | 3 -- demos/ARM7-AT91SAM7X-GCC/main.c | 9 +++--- demos/ARM7-AT91SAM7X-WEB-GCC/board.c | 28 ++++++++--------- demos/ARM7-AT91SAM7X-WEB-GCC/board.h | 59 ++++++++++++++++++++---------------- demos/ARM7-AT91SAM7X-WEB-GCC/main.c | 9 +++--- 5 files changed, 57 insertions(+), 51 deletions(-) (limited to 'demos') diff --git a/demos/ARM7-AT91SAM7X-GCC/board.c b/demos/ARM7-AT91SAM7X-GCC/board.c index 2b53c87b7..02ac5046d 100644 --- a/demos/ARM7-AT91SAM7X-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-GCC/board.c @@ -101,9 +101,6 @@ void hwinit0(void) { * PIO initialization. */ palInit(); -/* AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_PIOB); - AT91C_BASE_PIOA->PIO_PER = 0xFFFFFFFF; - AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF;*/ } /* diff --git a/demos/ARM7-AT91SAM7X-GCC/main.c b/demos/ARM7-AT91SAM7X-GCC/main.c index c51c911c9..614b649cd 100644 --- a/demos/ARM7-AT91SAM7X-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-GCC/main.c @@ -18,6 +18,7 @@ */ #include +#include #include #include "board.h" @@ -27,9 +28,9 @@ static WORKING_AREA(waThread1, 64); static msg_t Thread1(void *arg) { while (TRUE) { - AT91C_BASE_PIOB->PIO_SODR = PIOB_LCD_BL; // LCD on. + palSetPad(IOPORT_B, PIOB_LCD_BL); chThdSleepMilliseconds(100); - AT91C_BASE_PIOB->PIO_CODR = PIOB_LCD_BL; // LCD off. + palClearPad(IOPORT_B, PIOB_LCD_BL); chThdSleepMilliseconds(900); } return 0; @@ -51,9 +52,9 @@ int main(int argc, char **argv) { */ while (TRUE) { chThdSleepMilliseconds(500); - if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW1)) + if (!palReadPad(IOPORT_B, PIOB_SW1)) chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14); - if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW2)) + if (!palReadPad(IOPORT_B, PIOB_SW2)) TestThread(&COM1); } diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c index 630a0ad5d..e0b170120 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/board.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/board.c @@ -18,6 +18,7 @@ */ #include +#include #include "board.h" #include "at91lib/aic.h" @@ -26,7 +27,7 @@ #include /* - * FIQ Handler weak symbol defined in vectors.s. + * FIQ Handler weak symbol defined in vectors.s. */ void FiqHandler(void); @@ -98,11 +99,9 @@ void hwinit0(void) { ; /* - * I/O setup, enable clocks, initially all pins are inputs with pullups. + * PIO initialization. */ - AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_PIOA) | (1 << AT91C_ID_PIOB); - AT91C_BASE_PIOA->PIO_PER = 0xFFFFFFFF; - AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF; + palInit(); } /* @@ -127,24 +126,25 @@ void hwinit1(void) { /* * LCD pins setup. */ - AT91C_BASE_PIOB->PIO_CODR = PIOB_LCD_BL; // Set to low. - AT91C_BASE_PIOB->PIO_OER = PIOB_LCD_BL; // Configure as output. - AT91C_BASE_PIOB->PIO_PPUDR = PIOB_LCD_BL; // Disable internal pullup resistor. + 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. - AT91C_BASE_PIOA->PIO_SODR = PIOA_LCD_RESET; // Set to high. - AT91C_BASE_PIOA->PIO_OER = PIOA_LCD_RESET; // Configure as output. - AT91C_BASE_PIOA->PIO_PPUDR = PIOA_LCD_RESET; // Disable internal pullup resistor. + 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. /* * Joystick and buttons, disable pullups, already inputs. */ - AT91C_BASE_PIOA->PIO_PPUDR = PIOA_B1 | PIOA_B2 | PIOA_B3 | PIOA_B4 | PIOA_B5; - AT91C_BASE_PIOB->PIO_PPUDR = PIOB_SW1 | PIOB_SW2; + 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; /* * MMC/SD slot, disable pullups, already inputs. */ - AT91C_BASE_SYS->PIOB_PPUDR = PIOB_MMC_WP | PIOB_MMC_CP; + AT91C_BASE_SYS->PIOB_PPUDR = PIOB_MMC_WP_MASK | PIOB_MMC_CP_MASK; /* * PIT Initialization. diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/board.h b/demos/ARM7-AT91SAM7X-WEB-GCC/board.h index 57629be2f..fe9219aa3 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/board.h +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/board.h @@ -32,31 +32,38 @@ /* * I/O definitions. */ -#define PIOA_LCD_RESET (1 << 2) -#define PIOA_B1 (1 << 7) -#define PIOA_B2 (1 << 8) -#define PIOA_B3 (1 << 9) -#define PIOA_B4 (1 << 14) -#define PIOA_B5 (1 << 15) -#define PIOA_USB_PUP (1 << 25) -#define PIOA_USB_PR (1 << 26) -#define PIOA_PA27 (1 << 27) -#define PIOA_PA28 (1 << 28) -#define PIOA_PA29 (1 << 29) -#define PIOA_PA30 (1 << 30) - -#define PIOB_PHY_PD (1 << 18) -#define PIOB_AUDIO_OUT (1 << 19) -#define PIOB_LCD_BL (1 << 20) -#define PIOB_PB21 (1 << 21) -#define PIOB_MMC_WP (1 << 22) -#define PIOB_MMC_CP (1 << 23) -#define PIOB_SW1 (1 << 24) -#define PIOB_SW2 (1 << 25) -#define PIOB_PHY_IRQ (1 << 26) -#define PIOB_PB27_AD0 (1 << 27) -#define PIOB_PB28_AD1 (1 << 28) -#define PIOB_PB29_AD2 (1 << 29) -#define PIOB_PB30_AD3 (1 << 30) +#define PIOA_LCD_RESET 2 +#define PIOA_LCD_RESET_MASK (1 << PIOA_LCD_RESET) +#define PIOA_B1 7 +#define PIOA_B1_MASK (1 << PIOA_B1) +#define PIOA_B2 8 +#define PIOA_B2_MASK (1 << PIOA_B2) +#define PIOA_B3 9 +#define PIOA_B3_MASK (1 << PIOA_B3) +#define PIOA_B4 14 +#define PIOA_B4_MASK (1 << PIOA_B4) +#define PIOA_B5 15 +#define PIOA_B5_MASK (1 << PIOA_B5) +#define PIOA_USB_PUP 25 +#define PIOA_USB_PUP_MASK (1 << PIOA_USB_PUP) +#define PIOA_USB_PR 26 +#define PIOA_USB_PR_MASK (1 << PIOA_USB_PR) + +#define PIOB_PHY_PD 18 +#define PIOB_PHY_PD_MASK (1 << PIOB_PHY_PD) +#define PIOB_AUDIO_OUT 19 +#define PIOB_AUDIO_OUT_MASK (1 << PIOB_AUDIO_OUT) +#define PIOB_LCD_BL 20 +#define PIOB_LCD_BL_MASK (1 << PIOB_LCD_BL) +#define PIOB_MMC_WP 22 +#define PIOB_MMC_WP_MASK (1 << PIOB_MMC_WP) +#define PIOB_MMC_CP 23 +#define PIOB_MMC_CP_MASK (1 << PIOB_MMC_CP) +#define PIOB_SW1 24 +#define PIOB_SW1_MASK (1 << PIOB_SW1) +#define PIOB_SW2 25 +#define PIOB_SW2_MASK (1 << PIOB_SW2) +#define PIOB_PHY_IRQ 26 +#define PIOB_PHY_IRQ_MASK (1 << PIOB_PHY_IRQ) #endif /* _BOARD_H_ */ diff --git a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c index 07af9b0bd..0eafb2260 100644 --- a/demos/ARM7-AT91SAM7X-WEB-GCC/main.c +++ b/demos/ARM7-AT91SAM7X-WEB-GCC/main.c @@ -18,6 +18,7 @@ */ #include +#include #include #include "board.h" @@ -32,9 +33,9 @@ static WORKING_AREA(waThread1, 64); static msg_t Thread1(void *arg) { while (TRUE) { - AT91C_BASE_PIOB->PIO_SODR = PIOB_LCD_BL; // LCD on. + palSetPad(IOPORT_B, PIOB_LCD_BL); chThdSleepMilliseconds(100); - AT91C_BASE_PIOB->PIO_CODR = PIOB_LCD_BL; // LCD off. + palClearPad(IOPORT_B, PIOB_LCD_BL); chThdSleepMilliseconds(900); } return 0; @@ -57,9 +58,9 @@ int main(int argc, char **argv) { */ while (TRUE) { chThdSleepMilliseconds(500); - if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW1)) + if (!palReadPad(IOPORT_B, PIOB_SW1)) chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14); - if (!(AT91C_BASE_PIOB->PIO_PDSR & PIOB_SW2)) + if (!palReadPad(IOPORT_B, PIOB_SW2)) TestThread(&COM1); } -- cgit v1.2.3