Code: Select all
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include "ulp_riscv.h"
#include "ulp_riscv_utils.h"
#include "ulp_riscv_gpio.h"
#include "ulp_riscv_adc_ulp_core.h"
#include "hal/adc_types.h"
#define ADC_CHANNEL ADC_CHANNEL_1
#define ADC_UNIT ADC_UNIT_1
#define ADC_TRESHOLD 9.0*1000 // mV
#define TAMPER_GPIO GPIO_NUM_5
gpio_num_t tamper_gpio = TAMPER_GPIO;
bool tamper_detected = false;
int32_t adc_read = 0;
int32_t bus_voltage = 0;
int main (void)
{
if(ulp_riscv_gpio_get_level(tamper_gpio) == 1)
tamper_detected = true;
adc_read = ulp_riscv_adc_read_channel(ADC_UNIT, ADC_CHANNEL);
bus_voltage = adc_read * (1010 / 100);
if (bus_voltage > ADC_TRESHOLD)
ulp_riscv_wakeup_main_processor();
return 0;
}
The device is working fine for the most part however, rarely the device does not wakeup from sleep but goes into the firmware download mode and becomes bricked until I reset the reset
From observing the logs on the serial UART, I have attached the screenshot of the error
Using DMM, I have verified that my Boot GPIO 0 is pulled high i.e. 3.3V