Finalized AVR PAL driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3441 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2011-10-10 18:08:37 +00:00
parent 977abf0c51
commit 36d1e0978a
7 changed files with 61 additions and 88 deletions

View File

@ -21,6 +21,32 @@
#include "ch.h"
#include "hal.h"
/**
* @brief PAL setup.
* @details Digital I/O ports static configuration as defined in @p board.h.
* This variable is used by the HAL when initializing the PAL driver.
*/
#if HAL_USE_PAL || defined(__DOXYGEN__)
const PALConfig pal_default_config =
{
#if defined(PORTA)
{VAL_PORTA, VAL_DDRA},
#endif
#if defined(PORTA)
{VAL_PORTB, VAL_DDRB},
#endif
#if defined(PORTA)
{VAL_PORTC, VAL_DDRC},
#endif
#if defined(PORTA)
{VAL_PORTD, VAL_DDRD},
#endif
#if defined(PORTA)
{VAL_PORTE, VAL_DDRE},
#endif
};
#endif /* HAL_USE_PAL */
CH_IRQ_HANDLER(TIMER0_COMP_vect) {
CH_IRQ_PROLOGUE();
@ -37,24 +63,6 @@ CH_IRQ_HANDLER(TIMER0_COMP_vect) {
*/
void boardInit(void) {
/*
* I/O ports setup.
*/
DDRA = VAL_DDRA;
PORTA = VAL_PORTA;
DDRB = VAL_DDRB;
PORTB = VAL_PORTB;
DDRC = VAL_DDRC;
PORTC = VAL_PORTC;
DDRD = VAL_DDRD;
PORTD = VAL_PORTD;
DDRE = VAL_DDRE;
PORTE = VAL_PORTE;
DDRF = VAL_DDRF;
PORTF = VAL_PORTF;
DDRG = VAL_DDRG;
PORTG = VAL_PORTG;
/*
* External interrupts setup, all disabled initially.
*/

View File

@ -87,8 +87,8 @@
#define VAL_DDRG 0x00
#define VAL_PORTG 0x07
#define PORTE_LED (1 << 4)
#define PORTE_BUTTON (1 << 5)
#define PORTE_LED 4
#define PORTE_BUTTON 5
#if !defined(_FROM_ASM_)
#ifdef __cplusplus

View File

@ -20,34 +20,22 @@
#include "ch.h"
#include "hal.h"
#include "evtimer.h"
#include "test.h"
static WORKING_AREA(waThread1, 32);
static msg_t Thread1(void *arg) {
while (TRUE) {
PORTE ^= PORTE_LED;
chThdSleepMilliseconds(500);
palTogglePad(IOPORT5, PORTE_LED);
chThdSleepMilliseconds(500);
}
return 0;
}
static void TimerHandler(eventid_t id) {
msg_t TestThread(void *p);
if (!(PORTE & PORTE_BUTTON))
TestThread(&SD2);
}
/*
* Application entry point.
*/
int main(void) {
static EvTimer evt;
static evhandler_t handlers[1] = {
TimerHandler
};
static EventListener el0;
/*
* System initializations.
@ -64,20 +52,16 @@ int main(void) {
*/
sdStart(&SD2, NULL);
/*
* 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));
while(TRUE) {
if (!palReadPad(IOPORT5, PORTE_BUTTON))
TestThread(&SD2);
chThdSleepMilliseconds(500);
}
return 0;
}

View File

@ -20,7 +20,7 @@
#include "ch.h"
#include "hal.h"
#include "evtimer.h"
#include "test.h"
#include "lcd.h"
@ -35,22 +35,10 @@ static msg_t Thread1(void *arg) {
return 0;
}
static void TimerHandler(eventid_t id) {
msg_t TestThread(void *p);
if (!palReadPad(IOPORT1, PORTA_BUTTON1))
TestThread(&SD2);
}
/*
* Application entry point.
*/
int main(void) {
static EvTimer evt;
static evhandler_t handlers[1] = {
TimerHandler
};
static EventListener el0;
/*
* System initializations.
@ -76,20 +64,14 @@ int main(void) {
lcdPuts(LCD_LINE1, " ChibiOS/RT ");
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);
}
}

View File

@ -5,10 +5,12 @@ Settings: F_CPU=16000000
*** ChibiOS/RT test suite
***
*** Kernel: 2.1.6unstable
*** GCC Version: 4.3.0
*** Kernel: 2.3.4unstable
*** Compiled: Oct 9 2011 - 10:47:27
*** Compiler: GCC 4.3.0
*** Architecture: AVR
*** Core Variant: MegaAVR
*** Port Info: None
*** Platform: ATmega128
*** Test Board: Olimex AVR-MT-128
@ -83,31 +85,31 @@ Settings: F_CPU=16000000
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
--- Score : 31125 msgs/S, 62250 ctxswc/S
--- Score : 31561 msgs/S, 63122 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
--- Score : 24979 msgs/S, 49958 ctxswc/S
--- Score : 24980 msgs/S, 49960 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
--- Score : 24979 msgs/S, 49958 ctxswc/S
--- Score : 24980 msgs/S, 49960 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
--- Score : 89904 ctxswc/S
--- Score : 88896 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
--- Score : 21054 threads/S
--- Score : 19766 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
--- Score : 27121 threads/S
--- Score : 25179 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
--- Score : 7970 reschedules/S, 47820 ctxswc/S
--- Score : 7891 reschedules/S, 47346 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
@ -115,31 +117,31 @@ Settings: F_CPU=16000000
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
--- Score : 80180 bytes/S
--- Score : 96364 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
--- Score : 81522 timers/S
--- Score : 85724 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
--- Score : 227560 wait+signal/S
--- Score : 227568 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
--- Score : 116720 lock+unlock/S
--- Score : 116724 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)
--- System: 230 bytes
--- Thread: 29 bytes
--- System: 234 bytes
--- Thread: 31 bytes
--- Timer : 10 bytes
--- Semaph: 5 bytes
--- EventS: 2 bytes
--- EventL: 5 bytes
--- Mutex : 8 bytes
--- CondV.: 4 bytes
--- Queue : 15 bytes
--- Queue : 16 bytes
--- MailB.: 18 bytes
--- Result: SUCCESS
----------------------------------------------------------------------------

View File

@ -103,8 +103,6 @@ void _pal_lld_init(const PALConfig *config) {
* with pull-up by default.
*
* @notapi
*
* TODO: check PAL_MODE_UNCONNECTED mode recommended for AVR
*/
void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask,
@ -113,8 +111,6 @@ void _pal_lld_setgroupmode(ioportid_t port,
switch (mode) {
case PAL_MODE_RESET:
case PAL_MODE_INPUT:
port->dir &= ~mask;
break;
case PAL_MODE_INPUT_ANALOG:
port->dir &= ~mask;
port->out &= ~mask;

View File

@ -82,6 +82,7 @@
together with sources, also implemented a simplified output log mode.
Now makefiles and load script files are requirements and trigger a
rebuild if touched.
- NEW: Updated AVR demos to use the new PAL driver.
- CHANGE: Moved the STM32 DMA helper drivers files under the sub-family
specific directories because documentation issues.