Transfer gpio driver into c++

This commit is contained in:
Thomas Klaehn
2020-03-29 18:05:34 +02:00
parent 44d7f39026
commit 7f1721a536
7 changed files with 125 additions and 79 deletions

View File

@@ -1,24 +1,14 @@
extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include "delay.h"
#include "platform/gpio.h"
#include "delay.h"
#include "board.h"
}
using namespace hal;
int main(void)
{
unsigned int cnt[4] = {0, 0, 0, 0};
const struct driver *leds[4] = {&led_1, &led_2, &led_3, &led_4};
for(unsigned int i = 0; i < 4; i++) {
drv_open(leds[i]);
}
Gpio led_1(17);
while(true) {
for(unsigned int i = 0; i < 4; i++) {
char c = (cnt[i]++ % 2) + 0x30;
drv_write(leds[i], &c, 1);
delay_ms(500);
}
delay_ms(200);
led_1.toggle();
}
return 0;
}