led driver

This commit is contained in:
tkl 2016-07-27 16:28:46 +02:00
parent cdb315da32
commit f4bc903172
2 changed files with 9 additions and 2 deletions

View File

@ -21,10 +21,17 @@ struct thread_context tc_1;
void task1(void *arg) void task1(void *arg)
{ {
char rd = '0';
open(&led_4); open(&led_4);
write(&led_4, 0, 1); write(&led_4, &rd, 1);
while(1) { while(1) {
sleep_ms(1000); sleep_ms(1000);
read(&led_4, &rd, 1);
if(rd == '0')
rd = '1';
else
rd = '0';
write(&led_4, &rd, 1);
write(&uart_1, "Driver test\r\n", 13); write(&uart_1, "Driver test\r\n", 13);
} }
} }

View File

@ -110,7 +110,7 @@ int write(const struct driver *driver, const char *buffer, int len)
case DRIVER_TYPE_GPIO: case DRIVER_TYPE_GPIO:
if(len > 0) { if(len > 0) {
char send = 0; char send = 0;
if(buffer[0]) if((buffer[0] - 0x30) > 0)
send = 1; send = 1;
gpio_write((const struct gpio *)(driver->device_driver), send); gpio_write((const struct gpio *)(driver->device_driver), send);
ret = 1; ret = 1;