aboutsummaryrefslogtreecommitdiffstats
path: root/demos/AVR-ATmega128-GCC
diff options
context:
space:
mode:
Diffstat (limited to 'demos/AVR-ATmega128-GCC')
-rw-r--r--demos/AVR-ATmega128-GCC/halconf.h36
-rw-r--r--demos/AVR-ATmega128-GCC/lcd.c26
-rw-r--r--demos/AVR-ATmega128-GCC/main.c34
3 files changed, 47 insertions, 49 deletions
diff --git a/demos/AVR-ATmega128-GCC/halconf.h b/demos/AVR-ATmega128-GCC/halconf.h
index e3ea70d99..b4fb49092 100644
--- a/demos/AVR-ATmega128-GCC/halconf.h
+++ b/demos/AVR-ATmega128-GCC/halconf.h
@@ -38,7 +38,7 @@
* @brief Enables the PAL subsystem.
*/
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL FALSE
+#define HAL_USE_PAL TRUE
#endif
/**
@@ -56,6 +56,13 @@
#endif
/**
+ * @brief Enables the EXT subsystem.
+ */
+#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+#define HAL_USE_EXT FALSE
+#endif
+
+/**
* @brief Enables the GPT subsystem.
*/
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
@@ -98,6 +105,13 @@
#endif
/**
+ * @brief Enables the RTC subsystem.
+ */
+#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
+#define HAL_USE_RTC FALSE
+#endif
+
+/**
* @brief Enables the SDC subsystem.
*/
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
@@ -185,6 +199,13 @@
/* MAC driver related settings. */
/*===========================================================================*/
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+#define MAC_USE_EVENTS TRUE
+#endif
+
/*===========================================================================*/
/* MMC_SPI driver related settings. */
/*===========================================================================*/
@@ -235,16 +256,9 @@
#endif
/*===========================================================================*/
-/* PAL driver related settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* PWM driver related settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
/* SDC driver related settings. */
/*===========================================================================*/
+
/**
* @brief Number of initialization attempts before rejecting the card.
* @note Attempts are performed at 10mS intevals.
@@ -316,10 +330,6 @@
#define SPI_USE_MUTUAL_EXCLUSION TRUE
#endif
-/*===========================================================================*/
-/* UART driver related settings. */
-/*===========================================================================*/
-
#endif /* _HALCONF_H_ */
/** @} */
diff --git a/demos/AVR-ATmega128-GCC/lcd.c b/demos/AVR-ATmega128-GCC/lcd.c
index 5ef8fca02..cd8aa5006 100644
--- a/demos/AVR-ATmega128-GCC/lcd.c
+++ b/demos/AVR-ATmega128-GCC/lcd.c
@@ -25,10 +25,10 @@
static void e_pulse(void) {
volatile uint8_t i;
- PORTC |= PORTC_44780_E;
+ PORTC |= PORTC_44780_E_MASK;
for (i = 0; i < ELOOPVALUE; i++);
;
- PORTC &= ~PORTC_44780_E;
+ PORTC &= ~PORTC_44780_E_MASK;
}
static void wait_not_busy(void) {
@@ -41,8 +41,9 @@ static void wait_not_busy(void) {
*/
void lcdInit(void) {
- PORTC = (PORTC & ~(PORTC_44780_DATA | PORTC_44780_RS | PORTC_44780_E | PORTC_44780_RW)) |
- (LCD_CMD_INIT8 & PORTC_44780_DATA);
+ PORTC = (PORTC & ~(PORTC_44780_DATA_MASK | PORTC_44780_RS_MASK |
+ PORTC_44780_E_MASK | PORTC_44780_RW_MASK)) |
+ (LCD_CMD_INIT8 & PORTC_44780_DATA_MASK);
chThdSleep(50);
e_pulse();
chThdSleep(10);
@@ -50,8 +51,9 @@ void lcdInit(void) {
chThdSleep(2);
e_pulse();
wait_not_busy();
- PORTC = (PORTC & ~(PORTC_44780_DATA | PORTC_44780_RS | PORTC_44780_E | PORTC_44780_RW)) |
- (LCD_CMD_INIT4 & PORTC_44780_DATA);
+ PORTC = (PORTC & ~(PORTC_44780_DATA_MASK | PORTC_44780_RS_MASK |
+ PORTC_44780_E_MASK | PORTC_44780_RW_MASK)) |
+ (LCD_CMD_INIT4 & PORTC_44780_DATA_MASK);
e_pulse();
lcdCmd(LCD_CMD_INIT4);
lcdCmd(LCD_SET_DM | LCD_DM_DISPLAY_ON);
@@ -64,9 +66,11 @@ void lcdInit(void) {
void lcdCmd(uint8_t cmd) {
wait_not_busy();
- PORTC = (PORTC | PORTC_44780_DATA) & (cmd | (0x0F & ~PORTC_44780_RS));
+ PORTC = (PORTC | PORTC_44780_DATA_MASK) & (cmd |
+ (0x0F & ~PORTC_44780_RS_MASK));
e_pulse();
- PORTC = (PORTC | PORTC_44780_DATA) & ((cmd << 4) | (0x0F & ~PORTC_44780_RS));
+ PORTC = (PORTC | PORTC_44780_DATA_MASK) & ((cmd << 4) |
+ (0x0F & ~PORTC_44780_RS_MASK));
e_pulse();
}
@@ -78,9 +82,11 @@ void lcdPutc(char c) {
wait_not_busy();
b = c | 0x0F;
- PORTC = (PORTC | PORTC_44780_DATA | PORTC_44780_RS) & (c | 0x0F);
+ PORTC = (PORTC | PORTC_44780_DATA_MASK | PORTC_44780_RS_MASK) &
+ (c | 0x0F);
e_pulse();
- PORTC = (PORTC | PORTC_44780_DATA | PORTC_44780_RS) & ((c << 4) | 0x0F);
+ PORTC = (PORTC | PORTC_44780_DATA_MASK | PORTC_44780_RS_MASK) &
+ ((c << 4) | 0x0F);
e_pulse();
}
diff --git a/demos/AVR-ATmega128-GCC/main.c b/demos/AVR-ATmega128-GCC/main.c
index 0b26a9641..36b482c4b 100644
--- a/demos/AVR-ATmega128-GCC/main.c
+++ b/demos/AVR-ATmega128-GCC/main.c
@@ -20,7 +20,7 @@
#include "ch.h"
#include "hal.h"
-#include "evtimer.h"
+#include "test.h"
#include "lcd.h"
@@ -28,29 +28,17 @@ static WORKING_AREA(waThread1, 32);
static msg_t Thread1(void *arg) {
while (TRUE) {
- if (!(PINA & PORTA_BUTTON2))
- PORTA ^= PORTA_RELAY;
+ if (!palReadPad(IOPORT1, PORTA_BUTTON2))
+ palTogglePad(IOPORT1, PORTA_RELAY);
chThdSleepMilliseconds(1000);
}
return 0;
}
-static void TimerHandler(eventid_t id) {
- msg_t TestThread(void *p);
-
- if (!(PINA & PORTA_BUTTON1))
- TestThread(&SD2);
-}
-
/*
* Application entry point.
*/
int main(void) {
- static EvTimer evt;
- static evhandler_t handlers[1] = {
- TimerHandler
- };
- static EventListener el0;
/*
* System initializations.
@@ -77,19 +65,13 @@ int main(void) {
lcdPuts(LCD_LINE2, " Hello World! ");
/*
- * Event Timer initialization.
- */
- evtInit(&evt, MS2ST(500)); /* Initializes an event timer object. */
- evtStart(&evt); /* Starts the event timer. */
- chEvtRegister(&evt.et_es, &el0, 0); /* Registers on the timer event source. */
-
- /*
* Starts the LED blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
- while(TRUE)
- chEvtDispatch(handlers, chEvtWaitOne(ALL_EVENTS));
-
- return 0;
+ while(TRUE) {
+ if (!palReadPad(IOPORT1, PORTA_BUTTON1))
+ TestThread(&SD2);
+ chThdSleepMilliseconds(500);
+ }
}