Browse Source

update port

master
zwsd 3 years ago
parent
commit
0e89afe794
  1. 1
      main/CMakeLists.txt
  2. 7
      main/light.c
  3. 18
      main/port.c
  4. 6
      main/port.h

1
main/CMakeLists.txt

@ -2,6 +2,7 @@ set(srcs "app_main.cpp" #
"ble_spp_server_demo.c"
"camera.cpp"
"light.c"
"port.c"
)
idf_component_register(SRCS "${srcs}"#

7
main/light.c

@ -2,6 +2,7 @@
#include "driver/gpio.h"
#include "esp_log.h"
#include "port.h"
#define GPIO_DEBUG_LIGHT 12
#define GPIO_POWER_LIGHT 12
@ -95,6 +96,12 @@ void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_struc
void T_debug_light_schedule(void)
{
static uint32_t debug_light_time;
if (port_haspassedms(debug_light_time) > 300)
{
T_debug_light_toggle_level();
debug_light_time = port_get_ticket();
}
}
void T_light_schedule(void)

18
main/port.c

@ -0,0 +1,18 @@
#include "port.h"
#include "driver/gpio.h"
#include "esp_log.h"
uint32_t port_get_ticket() { return esp_log_timestamp(); }
uint32_t port_haspassedms(uint32_t ticket) { return port_get_ticket() - ticket; }
uint32_t port_delay_ms(uint32_t ms)
{
uint32_t now = port_get_ticket();
while (port_get_ticket() - now < ms)
{
}
return 0;
}

6
main/port.h

@ -0,0 +1,6 @@
#pragma once
#include <stdint.h>
uint32_t port_get_ticket();
uint32_t port_haspassedms(uint32_t ticket);
uint32_t port_delay_ms(uint32_t ms);
Loading…
Cancel
Save