Created
June 5, 2012 21:00
-
-
Save anonymous/2877871 to your computer and use it in GitHub Desktop.
main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include "ch.h" | |
| #include "hal.h" | |
| #include "test.h" | |
| #include "shell.h" | |
| #include "evtimer.h" | |
| #include "chprintf.h" | |
| #include "glcd.h" | |
| #include "touchpad.h" | |
| #define BKGRD Black | |
| static WORKING_AREA(waThread1, 128); | |
| static msg_t Thread1(void *arg) { | |
| (void)arg; | |
| chRegSetThreadName("blinker"); | |
| while (TRUE) { | |
| palTogglePad(GPIOD, GPIOD_LED1); | |
| chThdSleepMilliseconds(200); | |
| } | |
| return 0; | |
| } | |
| static WORKING_AREA(waThread2, 512); | |
| static msg_t Thread2(void *arg) { | |
| chRegSetThreadName("touchpad"); | |
| (void)arg; | |
| while(TRUE) { | |
| chEvtWaitAny((eventmask_t)1); | |
| palTogglePad(GPIOD, GPIOD_LED3); | |
| } | |
| } | |
| static void touchIRQ(EXTDriver *extp, expchannel_t channel) { | |
| (void)extp; | |
| (void)channel; | |
| chSysLockFromIsr(); | |
| chEvtSignalFlagsI(Thread2, (eventmask_t)1); | |
| chSysUnlockFromIsr() | |
| } | |
| int main(void) { | |
| static const EXTConfig extcfg = { | |
| { | |
| {EXT_CH_MODE_DISABLED, NULL}, | |
| {EXT_CH_MODE_DISABLED, NULL}, | |
| {EXT_CH_MODE_DISABLED, NULL}, | |
| {EXT_CH_MODE_DISABLED, NULL}, | |
| {EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOC, touchIRQ}, | |
| {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} | |
| } | |
| }; | |
| halInit(); | |
| chSysInit(); | |
| lcdInit(); | |
| tpInit(); | |
| tpCalibrate(); | |
| lcdClear(BKGRD); | |
| lcdSetOrientation(landscape); | |
| chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); | |
| chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); | |
| extStart(&EXTD1, &extcfg); | |
| while (TRUE) { | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment