stash
This commit is contained in:
parent
cb1fd6e485
commit
c31bff2b33
1 changed files with 15 additions and 1 deletions
|
@ -20,6 +20,12 @@ extern "C" void signal_led(bool state) {
|
||||||
gpio_write(signal_led_pin, !state);
|
gpio_write(signal_led_pin, !state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void int_to_hex(uint8_t i, char buf[2]) {
|
||||||
|
uint8_t hex_charset[] = "0123456789ABCDEF";
|
||||||
|
buf[0] = hex_charset[i >> 4];
|
||||||
|
buf[1] = hex_charset[i & 0x0F];
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void lux_task(void *pvParameters) {
|
extern "C" void lux_task(void *pvParameters) {
|
||||||
|
|
||||||
gpio_enable(signal_led_pin, GPIO_OUTPUT);
|
gpio_enable(signal_led_pin, GPIO_OUTPUT);
|
||||||
|
@ -33,13 +39,21 @@ extern "C" void lux_task(void *pvParameters) {
|
||||||
uint8_t cnt = 0;
|
uint8_t cnt = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
uint8_t buf[2];
|
||||||
spi_transfer_8(1, charset[cnt++]);
|
spi_transfer_8(1, charset[cnt++]);
|
||||||
for(volatile int i = 0; i < 100; i++);
|
for(volatile int i = 0; i < 100; i++);
|
||||||
spi_transfer_8(1, 0x00);
|
spi_read(1, 0x00, buf, 2, 1);
|
||||||
|
|
||||||
|
char hex[5];
|
||||||
|
int_to_hex(buf[0], hex);
|
||||||
|
int_to_hex(buf[1], hex + 2);
|
||||||
|
hex[4] = '\0';
|
||||||
|
printf("lux_task output: %s\n", hex);
|
||||||
|
|
||||||
vTaskDelay(1000/portTICK_PERIOD_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
cnt %= sizeof(charset);
|
cnt %= sizeof(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vTaskDelete(nullptr);
|
vTaskDelete(nullptr);
|
||||||
}
|
}
|
Loading…
Reference in a new issue