2021-10-14 06:41:33 +01:00
|
|
|
#include <stdint.h>
|
2021-10-17 15:06:53 +01:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include <esp_log.h>
|
|
|
|
#include <driver/gpio.h>
|
|
|
|
#include <rom/ets_sys.h>
|
2021-10-14 06:41:33 +01:00
|
|
|
|
|
|
|
uint32_t swd_delay_cnt = 0;
|
2021-10-17 15:06:53 +01:00
|
|
|
static const char* TAG = "gdb-platform";
|
2021-10-14 06:41:33 +01:00
|
|
|
|
|
|
|
void platform_swdio_mode_float(void) {
|
2021-10-17 15:06:53 +01:00
|
|
|
// ESP_LOGI(TAG, "swdio_mode_float");
|
|
|
|
gpio_set_direction(SWDIO_PIN, GPIO_MODE_INPUT);
|
|
|
|
gpio_set_pull_mode(SWDIO_PIN, GPIO_FLOATING);
|
2021-10-14 06:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform_swdio_mode_drive(void) {
|
2021-10-17 15:06:53 +01:00
|
|
|
// ESP_LOGI(TAG, "swdio_mode_drive");
|
|
|
|
gpio_set_direction(SWDIO_PIN, GPIO_MODE_OUTPUT);
|
2021-10-14 06:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform_gpio_set_level(int32_t gpio_num, uint32_t value) {
|
2021-10-17 15:06:53 +01:00
|
|
|
// ESP_LOGI(TAG, "pin %d set %d", gpio_num, value);
|
|
|
|
gpio_set_level(gpio_num, value);
|
|
|
|
ets_delay_us(2);
|
2021-10-14 06:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform_gpio_set(int32_t gpio_num) {
|
2021-10-17 15:06:53 +01:00
|
|
|
// ESP_LOGI(TAG, "pin %d set 1", gpio_num);
|
|
|
|
platform_gpio_set_level(gpio_num, 1);
|
2021-10-14 06:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void platform_gpio_clear(int32_t gpio_num) {
|
2021-10-17 15:06:53 +01:00
|
|
|
// ESP_LOGI(TAG, "pin %d set 0", gpio_num);
|
|
|
|
platform_gpio_set_level(gpio_num, 0);
|
2021-10-14 06:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int platform_gpio_get_level(int32_t gpio_num) {
|
2021-10-17 15:06:53 +01:00
|
|
|
int level = gpio_get_level(gpio_num);
|
|
|
|
// ESP_LOGI(TAG, "pin %d get %d", gpio_num, level);
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
|
|
|
// init platform
|
|
|
|
void platform_init() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// set reset target pin level
|
|
|
|
void platform_srst_set_val(bool assert) {
|
|
|
|
(void)assert;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get reset target pin level
|
|
|
|
bool platform_srst_get_val(void) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// target voltage
|
|
|
|
const char* platform_target_voltage(void) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// platform time counter
|
|
|
|
uint32_t platform_time_ms(void) {
|
|
|
|
int64_t time_milli = esp_timer_get_time() / 1000;
|
|
|
|
return ((uint32_t)time_milli);
|
|
|
|
}
|
|
|
|
|
|
|
|
// delay ms
|
|
|
|
void platform_delay(uint32_t ms) {
|
|
|
|
vTaskDelay((ms) / portTICK_PERIOD_MS);
|
|
|
|
}
|
|
|
|
|
|
|
|
// hardware version
|
|
|
|
int platform_hwversion(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set timeout
|
|
|
|
void platform_timeout_set(platform_timeout* t, uint32_t ms) {
|
|
|
|
t->time = platform_time_ms() + ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check timeout
|
|
|
|
bool platform_timeout_is_expired(platform_timeout* t) {
|
|
|
|
return platform_time_ms() > t->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set interface freq
|
|
|
|
void platform_max_frequency_set(uint32_t freq) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// get interface freq
|
|
|
|
uint32_t platform_max_frequency_get(void) {
|
2021-10-14 06:41:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|