This commit is contained in:
2025-09-06 09:59:59 +03:00
parent c99f82eee9
commit e51603693b
2 changed files with 23 additions and 7 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.pio .pio
.vscode .vscode
.DS_Store

View File

@@ -3,7 +3,7 @@
#include "avr/io.h" #include "avr/io.h"
#include "zh_avr_160x_i2c.h" #include "zh_avr_160x_i2c.h"
// #define DEBUG #define DEBUG
#define BUTTON_I2C_ADDRESS 0x00 #define BUTTON_I2C_ADDRESS 0x00
#define LED1_I2C_ADDRESS 0x00 #define LED1_I2C_ADDRESS 0x00
@@ -26,6 +26,10 @@ int usart(char byte, FILE *stream)
FILE uart = FDEV_SETUP_STREAM(usart, NULL, _FDEV_SETUP_WRITE); FILE uart = FDEV_SETUP_STREAM(usart, NULL, _FDEV_SETUP_WRITE);
#endif #endif
void system_setup_task(void *pvParameters);
TaskHandle_t system_setup_task_handle = {0};
zh_avr_pcf8574_handle_t button_handle = {0}; zh_avr_pcf8574_handle_t button_handle = {0};
zh_avr_pcf8574_handle_t led1_handle = {0}; zh_avr_pcf8574_handle_t led1_handle = {0};
zh_avr_pcf8574_handle_t led2_handle = {0}; zh_avr_pcf8574_handle_t led2_handle = {0};
@@ -52,6 +56,13 @@ int main(void)
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
stdout = &uart; stdout = &uart;
#endif #endif
xTaskCreate(system_setup_task, "system_setup_task", 107, NULL, tskIDLE_PRIORITY, &system_setup_task_handle);
vTaskStartScheduler();
return 0;
}
void system_setup_task(void *pvParameters)
{
zh_avr_i2c_master_init(false); zh_avr_i2c_master_init(false);
zh_avr_pcf8574_init_config_t pcf8574_init_config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT(); zh_avr_pcf8574_init_config_t pcf8574_init_config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT();
pcf8574_init_config.i2c_address = LED1_I2C_ADDRESS; pcf8574_init_config.i2c_address = LED1_I2C_ADDRESS;
@@ -85,14 +96,18 @@ int main(void)
zh_avr_160x_print_char(&lcd_handle, "Loading: "); zh_avr_160x_print_char(&lcd_handle, "Loading: ");
for (uint8_t i = 0; i <= 100; ++i) for (uint8_t i = 0; i <= 100; ++i)
{ {
zh_avr_160x_set_cursor(&lcd_handle, 3, 10); // For LCD 16X4. zh_avr_160x_set_cursor(&lcd_handle, 3, 10);
zh_avr_160x_print_int(&lcd_handle, i); zh_avr_160x_print_int(&lcd_handle, i);
zh_avr_160x_print_char(&lcd_handle, "%"); zh_avr_160x_print_char(&lcd_handle, "%");
_delay_ms(50); vTaskDelay(50 / portTICK_PERIOD_MS);
} }
// xTaskCreate(led_flash_task, "led flash task", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL); printf("Ok\n");
vTaskStartScheduler(); vTaskDelete(NULL);
return 0; }
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
{
printf("Task %s Remaining Stack Size %d.\n", pcTaskName, uxTaskGetStackHighWaterMark(xTask));
} }
void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event) void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)