void LED_setValue(uint8_t value) { uint32_t old_port = GPIO_getPort(GPIO1); value &= 0x0F; // mask 4 lsb old_port &= ~(0x0F<<21); // set to 0 old_port |= (value<<21); GPIO_setPort(GPIO1,old_port); }
void GPIO::open(int port, int DDR) { uint8_t pin; PORT_t * p = GPIO_getPort(port,&pin); if (DDR==0) { p->DIRCLR=pin; }else if (DDR==1) { p->DIRSET = pin; } }
void GPIO::write(int port,int value) { uint8_t pin; PORT_t * p = GPIO_getPort(port,&pin); if (value==0) { p->OUTCLR=pin; }else if (value==1) { p->OUTSET = pin; } }
int read(int port) { uint8_t pin; PORT_t * p = GPIO_getPort(port,&pin); return p->IN; }