aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/ARM7-AT91SAM7X-GCC/board.c27
-rw-r--r--demos/ARM7-AT91SAM7X-GCC/board.h59
2 files changed, 48 insertions, 38 deletions
diff --git a/demos/ARM7-AT91SAM7X-GCC/board.c b/demos/ARM7-AT91SAM7X-GCC/board.c
index 43c624d9a..2b53c87b7 100644
--- a/demos/ARM7-AT91SAM7X-GCC/board.c
+++ b/demos/ARM7-AT91SAM7X-GCC/board.c
@@ -18,6 +18,7 @@
*/
#include <ch.h>
+#include <pal.h>
#include "board.h"
#include "at91lib/aic.h"
@@ -97,11 +98,12 @@ 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);
+ 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;
+ AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF;*/
}
/*
@@ -126,24 +128,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-GCC/board.h b/demos/ARM7-AT91SAM7X-GCC/board.h
index 57629be2f..fe9219aa3 100644
--- a/demos/ARM7-AT91SAM7X-GCC/board.h
+++ b/demos/ARM7-AT91SAM7X-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_ */