wip:
This commit is contained in:
		
							
								
								
									
										27
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/main.c
									
									
									
									
									
								
							@@ -3,7 +3,7 @@
 | 
			
		||||
#include "avr/io.h"
 | 
			
		||||
#include "zh_avr_160x_i2c.h"
 | 
			
		||||
 | 
			
		||||
// #define DEBUG
 | 
			
		||||
#define DEBUG
 | 
			
		||||
 | 
			
		||||
#define BUTTON_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);
 | 
			
		||||
#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 led1_handle = {0};
 | 
			
		||||
zh_avr_pcf8574_handle_t led2_handle = {0};
 | 
			
		||||
@@ -52,6 +56,13 @@ int main(void)
 | 
			
		||||
    UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
 | 
			
		||||
    stdout = &uart;
 | 
			
		||||
#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_pcf8574_init_config_t pcf8574_init_config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT();
 | 
			
		||||
    pcf8574_init_config.i2c_address = LED1_I2C_ADDRESS;
 | 
			
		||||
@@ -85,14 +96,18 @@ int main(void)
 | 
			
		||||
    zh_avr_160x_print_char(&lcd_handle, "Loading: ");
 | 
			
		||||
    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_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);
 | 
			
		||||
    vTaskStartScheduler();
 | 
			
		||||
    return 0;
 | 
			
		||||
    printf("Ok\n");
 | 
			
		||||
    vTaskDelete(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user