git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3311 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
d3e15bccfc
commit
3db4f2d235
|
@ -21,29 +21,71 @@
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
static const EXTConfig extcfg = {
|
static VirtualTimer vt;
|
||||||
{
|
|
||||||
{EXT_CH_MODE_DISABLED, NULL},
|
|
||||||
},
|
|
||||||
EXT_MODE_EXTI(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/* LED set to OFF after 200mS.*/
|
||||||
* Red LED blinker thread, times are in milliseconds.
|
static void ledoff(void *arg) {
|
||||||
*/
|
|
||||||
static WORKING_AREA(waThread1, 128);
|
|
||||||
static msg_t Thread1(void *arg) {
|
|
||||||
|
|
||||||
(void)arg;
|
(void)arg;
|
||||||
chRegSetThreadName("blinker");
|
palSetPad(GPIOC, GPIOC_LED);
|
||||||
while (TRUE) {
|
|
||||||
palClearPad(GPIOC, GPIOC_LED);
|
|
||||||
chThdSleepMilliseconds(500);
|
|
||||||
palSetPad(GPIOC, GPIOC_LED);
|
|
||||||
chThdSleepMilliseconds(500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Triggered when the button is pressed or released. The LED is set to ON.*/
|
||||||
|
static void extcb1(EXTDriver *extp, expchannel_t channel) {
|
||||||
|
|
||||||
|
(void)extp;
|
||||||
|
(void)channel;
|
||||||
|
palClearPad(GPIOC, GPIOC_LED);
|
||||||
|
chSysLockFromIsr();
|
||||||
|
if (!chVTIsArmedI(&vt))
|
||||||
|
chVTSetI(&vt, MS2ST(200), ledoff, NULL);
|
||||||
|
chSysUnlockFromIsr();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Triggered when the LED goes OFF.*/
|
||||||
|
static void extcb2(EXTDriver *extp, expchannel_t channel) {
|
||||||
|
|
||||||
|
(void)extp;
|
||||||
|
(void)channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const EXTConfig extcfg = {
|
||||||
|
{
|
||||||
|
{EXT_CH_MODE_BOTH_EDGES, extcb1},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_RISING_EDGE, extcb2},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
{EXT_CH_MODE_DISABLED, NULL},
|
||||||
|
},
|
||||||
|
EXT_MODE_EXTI(EXT_MODE_GPIOA,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
EXT_MODE_GPIOC,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0)
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application entry point.
|
* Application entry point.
|
||||||
*/
|
*/
|
||||||
|
@ -64,11 +106,6 @@ int main(void) {
|
||||||
*/
|
*/
|
||||||
extStart(&EXTD1, &extcfg);
|
extStart(&EXTD1, &extcfg);
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates the blinker thread.
|
|
||||||
*/
|
|
||||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing except
|
* Normal main() thread activity, in this demo it does nothing except
|
||||||
* sleeping in a loop and check the button state.
|
* sleeping in a loop and check the button state.
|
||||||
|
|
Loading…
Reference in New Issue