wip:
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
#define SYSTEM_SETUP_STACK 175 + 5
|
||||
#define ENCODER_STACK 166 + 5
|
||||
#define PCF8574_STACK 109 + 7
|
||||
#define SYSTEM_SETUP_STACK 173
|
||||
#define ENCODER_STACK 171
|
||||
#define PCF8574_STACK 116
|
||||
|
||||
const char *component_cmm[] = {component_1_cmm, component_2_cmm, component_3_cmm, component_4_cmm, component_5_cmm};
|
||||
const char *component_line_1[] = {component_1_line_1, component_2_line_1, component_3_line_1, component_4_line_1, component_5_line_1};
|
||||
@@ -71,6 +71,14 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Task %s Remaining Stack Size %d.\n", pcTaskName, uxTaskGetStackHighWaterMark(xTask));
|
||||
printf("Free Heap %d.\n", xPortGetFreeHeapSize());
|
||||
#endif
|
||||
}
|
||||
|
||||
void system_setup_task(void *pvParameters)
|
||||
{
|
||||
char text_buffer[LCD_TEXT_BUFFER];
|
||||
@@ -144,7 +152,7 @@ void system_setup_task(void *pvParameters)
|
||||
encoder_init_config.b_gpio_number = PORTC1;
|
||||
encoder_init_config.encoder_min_value = 0;
|
||||
encoder_init_config.encoder_max_value = 100;
|
||||
encoder_init_config.encoder_step = 5;
|
||||
encoder_init_config.encoder_step = 1;
|
||||
encoder_init_config.encoder_number = POWER_ENCODER;
|
||||
zh_avr_encoder_init(&encoder_init_config, &power_encoder_handle);
|
||||
zh_avr_encoder_set(&power_encoder_handle, 100);
|
||||
@@ -158,7 +166,7 @@ void system_setup_task(void *pvParameters)
|
||||
zh_avr_encoder_set(&component_encoder_handle, 0);
|
||||
//** AC dimmer init **/
|
||||
zh_avr_ac_dimmer_init_config_t ac_dimmer_init_config = ZH_AVR_AC_DIMMER_INIT_CONFIG_DEFAULT();
|
||||
ac_dimmer_init_config.ac_dimmer_frequency = ZH_400HZ;
|
||||
ac_dimmer_init_config.ac_dimmer_frequency = ZH_50HZ;
|
||||
ac_dimmer_init_config.zero_cross_port = AVR_PORTD;
|
||||
ac_dimmer_init_config.zero_cross_gpio = PORTD3;
|
||||
ac_dimmer_init_config.triac_port = AVR_PORTD;
|
||||
@@ -167,8 +175,7 @@ void system_setup_task(void *pvParameters)
|
||||
zh_avr_ac_dimmer_set(100);
|
||||
is_initialized = true;
|
||||
#ifdef DEBUG
|
||||
printf("System Setup Task Remaining Stack Size %d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
printf("Free Heap %d.\n", xPortGetFreeHeapSize());
|
||||
printf("%d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
#endif
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
@@ -231,7 +238,7 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
}
|
||||
else
|
||||
{
|
||||
is_work = false;
|
||||
// is_work = false;
|
||||
if (is_fix == true)
|
||||
{
|
||||
is_num1_fixed = true;
|
||||
@@ -243,6 +250,7 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
vTaskDelay(1); // Temporary.
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, L1_RELAY, RELAY_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF); // Temporary.
|
||||
is_work = false;
|
||||
is_num1_fixed = false;
|
||||
}
|
||||
break;
|
||||
@@ -261,9 +269,9 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_GREEN, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, L2_RELAY, RELAY_ON);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON); // Temporary.
|
||||
vTaskDelay(10); // Temporary.
|
||||
zh_avr_ac_dimmer_start(); // Temporary.
|
||||
// zh_avr_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_ON); // Temporary.
|
||||
// vTaskDelay(10); // Temporary.
|
||||
// zh_avr_ac_dimmer_start(); // Temporary.
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -275,10 +283,10 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
}
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_GREEN, LED_OFF);
|
||||
zh_avr_ac_dimmer_stop(); // Temporary.
|
||||
vTaskDelay(1); // Temporary.
|
||||
// zh_avr_ac_dimmer_stop(); // Temporary.
|
||||
// vTaskDelay(1); // Temporary.
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, L2_RELAY, RELAY_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF); // Temporary.
|
||||
// zh_avr_pcf8574_write_gpio(&relay_handle, GROUND_RELAY, RELAY_OFF); // Temporary.
|
||||
is_num2_fixed = false;
|
||||
}
|
||||
break;
|
||||
@@ -346,8 +354,7 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("PCF8574 Interrupt Task Remaining Stack Size %d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
printf("Free Heap %d.\n", xPortGetFreeHeapSize());
|
||||
printf("%d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -368,8 +375,7 @@ void zh_avr_encoder_event_handler(zh_avr_encoder_event_on_isr_t *event)
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("Encoder Interrupt Task Remaining Stack Size %d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
printf("Free Heap %d.\n", xPortGetFreeHeapSize());
|
||||
printf("%d.\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -379,22 +385,24 @@ ISR(PCINT1_vect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
if (zh_avr_encoder_isr_handler(&power_encoder_handle) == pdTRUE)
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdTRUE;
|
||||
}
|
||||
// BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
zh_avr_encoder_isr_handler(&power_encoder_handle);
|
||||
// if (zh_avr_encoder_isr_handler(&power_encoder_handle) == pdTRUE)
|
||||
// {
|
||||
// xHigherPriorityTaskWoken = pdTRUE;
|
||||
// }
|
||||
if (is_work == false)
|
||||
{
|
||||
if (zh_avr_encoder_isr_handler(&component_encoder_handle) == pdTRUE)
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdTRUE;
|
||||
}
|
||||
}
|
||||
if (xHigherPriorityTaskWoken == pdTRUE)
|
||||
{
|
||||
portYIELD();
|
||||
zh_avr_encoder_isr_handler(&component_encoder_handle);
|
||||
// if (zh_avr_encoder_isr_handler(&component_encoder_handle) == pdTRUE)
|
||||
// {
|
||||
// xHigherPriorityTaskWoken = pdTRUE;
|
||||
// }
|
||||
}
|
||||
// if (xHigherPriorityTaskWoken == pdTRUE)
|
||||
// {
|
||||
// portYIELD();
|
||||
// }
|
||||
}
|
||||
|
||||
ISR(PCINT2_vect)
|
||||
@@ -403,16 +411,18 @@ ISR(PCINT2_vect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
// BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
zh_avr_pcf8574_isr_handler();
|
||||
zh_avr_ac_dimmer_isr_handler();
|
||||
if (zh_avr_pcf8574_isr_handler() == pdTRUE)
|
||||
{
|
||||
xHigherPriorityTaskWoken = pdTRUE;
|
||||
}
|
||||
if (xHigherPriorityTaskWoken == pdTRUE)
|
||||
{
|
||||
portYIELD();
|
||||
}
|
||||
// zh_avr_pcf8574_isr_handler();
|
||||
// if (zh_avr_pcf8574_isr_handler() == pdTRUE)
|
||||
// {
|
||||
// xHigherPriorityTaskWoken = pdTRUE;
|
||||
// }
|
||||
// if (xHigherPriorityTaskWoken == pdTRUE)
|
||||
// {
|
||||
// portYIELD();
|
||||
// }
|
||||
}
|
||||
|
||||
void component_setup_function(uint8_t component)
|
||||
|
||||
Reference in New Issue
Block a user