|
|
@ -37,7 +37,21 @@ void StartDefaultTask(void const* argument) { umain(); } |
|
|
|
|
|
|
|
xs_gpio_t m_debug_led; |
|
|
|
xs_gpio_t m_factory_reset_key; |
|
|
|
xs_gpio_t m_power_led; |
|
|
|
xs_gpio_t m_power_led0; |
|
|
|
xs_gpio_t m_power_led1; |
|
|
|
xs_gpio_t m_power_led2; |
|
|
|
|
|
|
|
void power_light_init() { |
|
|
|
xs_gpio_init_as_output(&m_power_led0, PB6, kxs_gpio_nopull, false, true); // r
|
|
|
|
xs_gpio_init_as_output(&m_power_led1, PB7, kxs_gpio_nopull, false, true); // g
|
|
|
|
xs_gpio_init_as_output(&m_power_led2, PB8, kxs_gpio_nopull, false, true); // b
|
|
|
|
} |
|
|
|
void power_light_ctrl(bool state) { |
|
|
|
xs_gpio_write(&m_power_led0, 0); |
|
|
|
xs_gpio_write(&m_power_led1, state); |
|
|
|
xs_gpio_write(&m_power_led2, state); |
|
|
|
} |
|
|
|
|
|
|
|
extern "C" { |
|
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { ReportGeneratorService_irq_trigger(GPIO_Pin); } |
|
|
|
} |
|
|
@ -49,9 +63,9 @@ void debug_light_ctrl() { |
|
|
|
light_status = !light_status; |
|
|
|
xs_gpio_write(&m_debug_led, light_status); |
|
|
|
if (network_service_network_is_ready()) { |
|
|
|
xs_gpio_write(&m_power_led, 1); |
|
|
|
power_light_ctrl(1); |
|
|
|
} else { |
|
|
|
xs_gpio_write(&m_power_led, light_status); |
|
|
|
power_light_ctrl(light_status); |
|
|
|
} |
|
|
|
lastcall = xs_get_ticket(); |
|
|
|
} |
|
|
@ -77,9 +91,9 @@ void factory_reset_key_detect() { |
|
|
|
|
|
|
|
// m_power_led
|
|
|
|
while (xs_gpio_read(&m_factory_reset_key)) { |
|
|
|
xs_gpio_write(&m_power_led, false); |
|
|
|
power_light_ctrl(false); |
|
|
|
osDelay(1000); |
|
|
|
xs_gpio_write(&m_power_led, true); |
|
|
|
power_light_ctrl(true); |
|
|
|
osDelay(1000); |
|
|
|
} |
|
|
|
ZLOGI(TAG, "system reset"); |
|
|
@ -90,8 +104,12 @@ void factory_reset_key_detect() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// PB6
|
|
|
|
// PB7
|
|
|
|
// PB8
|
|
|
|
|
|
|
|
void umain() { |
|
|
|
XS_LOGI(TAG, "%s:%d", PC_PROJECT_NAME, PC_VERSION); |
|
|
|
XS_LOGI(TAG, "%s:%d-%d-%d", PC_PROJECT_NAME, VERSION_MAIN, VERSION_SUB, VERSION_FIX); |
|
|
|
XS_LOGI(TAG, "sn: %02d%02d%04d", xs_device_info_get()->year, xs_device_info_get()->weak, xs_device_info_get()->index); |
|
|
|
// XS_LOGI(TAG, "sn: %x:%x:%x", sn.sn0, sn.sn1, sn.sn2);
|
|
|
|
|
|
|
@ -102,7 +120,8 @@ void umain() { |
|
|
|
* 3. 初始化工厂复位按键 |
|
|
|
*/ |
|
|
|
xs_gpio_init_as_output(&m_debug_led, PC_DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false); |
|
|
|
xs_gpio_init_as_output(&m_power_led, POWER_LED_PIN, kxs_gpio_nopull, false, true); |
|
|
|
// xs_gpio_init_as_output(&m_power_led, POWER_LED_PIN, kxs_gpio_nopull, false, true);
|
|
|
|
power_light_init(); |
|
|
|
xs_gpio_init_as_input(&m_factory_reset_key, FACTORY_RESET_KEY, kxs_gpio_pullup, kxs_gpio_no_irq, true); |
|
|
|
// m_power_led
|
|
|
|
/**
|
|
|
@ -147,6 +166,10 @@ void umain() { |
|
|
|
network_service_schedule(); |
|
|
|
HAL_IWDG_Refresh(&hiwdg); |
|
|
|
|
|
|
|
// uint32_t val;
|
|
|
|
// fpga_if_spi_read_data_02(0x0020, &val);
|
|
|
|
// ZLOGI(TAG, "fpga_if_spi_read_data_02 %x", val);
|
|
|
|
|
|
|
|
// if (xs_has_passedms(0) >= * 60 * 60 * 1000) {
|
|
|
|
// 限制客户使用时长
|
|
|
|
// reset_pin_io
|
|
|
|