Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class gpioTask : public scheduler_task
- {
- public:
- gpioTask(uint8_t priority) :
- scheduler_task("gpio", 512, priority)
- {
- /* Nothing to init */
- }
- bool init(void){
- LPC_PINCON->PINSEL2 &= ~((1<<28)|(1<<29)); // Set SW1.14
- LPC_PINCON->PINSEL2 &= ~((1<<8)|(1<<9)); // Set LED 1.4
- LPC_GPIO1->FIODIR &= ~(1 << 14); // make input sw 0
- LPC_GPIO1->FIODIR |= (1 << 4); // make output led 1
- LPC_PINCON->PINSEL0 &= ~((1<<0)|(1<<1)); // set GPIO 0.0 input sw
- LPC_PINCON->PINSEL0 &= ~((1<<2)|(1<<3)); // set GPIO 0.1 output led
- LPC_GPIO0->FIODIR &= ~(1 << 0);; // make input sw by setting 0
- LPC_GPIO0->FIODIR |= (1 << 1); // make output led by setting 1
- return true;
- }
- bool run(void *p)
- {
- //Onboard LED/Switch
- if(LPC_GPIO1->FIOPIN & (1 << 14) ){
- LPC_GPIO1->FIOCLR = (1 << 4 ); // LED On
- }
- else{
- LPC_GPIO1->FIOSET = (1 << 4 ); // LED Off
- }
- //External Switch/LED
- if(LPC_GPIO0->FIOPIN & (1 << 0) ) { // check if P0.0 is on
- //Active High Config
- LPC_GPIO0->FIOSET = (1 << 1 ); // Button Pressed LED ON
- }
- else{
- LPC_GPIO0->FIOCLR = (1<< 1); // Button Not Pressed LED OFF
- }
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement