Clean up comments and debugging pins

This commit is contained in:
Lucian Copeland 2021-04-02 17:25:17 -04:00
parent 9240146b22
commit 8a2143f161
5 changed files with 7 additions and 36 deletions

View File

@ -34,13 +34,16 @@ void alarm_sleep_memory_reset(void) {
}
uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return 0;
}
bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t* values, uint32_t len) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return false;
}
void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len) {
mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return;
}

View File

@ -46,10 +46,8 @@ void alarm_reset(void) {
most_recent_alarm = NULL;
// Reset the alarm flag
STM_ALARM_FLAG = 0x00;
// alarm_sleep_memory_reset();
alarm_pin_pinalarm_reset();
alarm_time_timealarm_reset();
// esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL);
}
// Kind of a hack, required as RTC is reset in port.c
@ -134,7 +132,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj
mp_obj_t wake_alarm = _get_wake_alarm(n_alarms, alarms);
// TODO: make this less roundabout
// TODO: make assignment to global array less roundabout
most_recent_alarm = wake_alarm;
shared_alarm_save_wake_alarm();
@ -149,10 +147,7 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala
_setup_sleep_alarms(true, n_alarms, alarms);
}
//#define NORETURN __attribute__((noreturn))
void NORETURN common_hal_alarm_enter_deep_sleep(void) {
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,1);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,0);
alarm_pin_pinalarm_prepare_for_deep_sleep();
alarm_time_timealarm_prepare_for_deep_sleep();
port_disable_tick();

View File

@ -64,12 +64,10 @@ STATIC void timer_callback(void) {
}
bool alarm_time_timealarm_woke_us_up(void) {
//mp_printf(&mp_plat_print,"Woke Up:%d\n",woke_up);
return woke_up;
}
void alarm_time_timealarm_reset(void) {
// mp_printf(&mp_plat_print,"timealarm reset");
woke_up = false;
}

View File

@ -164,10 +164,6 @@ void stm32_peripherals_rtc_assign_alarm_callback(uint8_t alarm_idx, void(*callba
}
void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks) {
// TEMP: ping set alarm (called by port_interrupt_after_ticks and alarm_time_timealarm_set_alarms)
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6,0);
uint64_t raw_ticks = stm32_peripherals_rtc_raw_ticks(NULL) + ticks;
RTC_AlarmTypeDef alarm;
@ -205,8 +201,6 @@ bool stm32_peripherals_rtc_alarm_triggered(uint8_t alarm_idx) {
}
void RTC_WKUP_IRQHandler(void) {
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,0);
if (wkup_callback) {
wkup_callback();
}
@ -220,10 +214,6 @@ void RTC_Alarm_IRQHandler(void) {
}
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *_hrtc) {
// TEMP
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_3,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_3,0);
if (alarm_callbacks[PERIPHERALS_ALARM_A]) {
alarm_callbacks[PERIPHERALS_ALARM_A]();
}
@ -232,10 +222,6 @@ void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *_hrtc) {
}
void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *_hrtc) {
//TEMP
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_2,1);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_2,0);
if (alarm_callbacks[PERIPHERALS_ALARM_B]) {
alarm_callbacks[PERIPHERALS_ALARM_B]();
}

View File

@ -175,6 +175,7 @@ safe_mode_t port_init(void) {
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
#if CIRCUITPY_ALARM
// TODO: don't reset RTC entirely and move this back to alarm
if (STM_ALARM_FLAG & 0x01) {
// We've woken from deep sleep. Was it the WKUP pin or the RTC?
@ -185,6 +186,8 @@ safe_mode_t port_init(void) {
alarm_set_wakeup_reason(STM_WAKEUP_GPIO);
}
}
#endif
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
@ -251,20 +254,6 @@ void reset_port(void) {
#if CIRCUITPY_PULSEIO || CIRCUITPY_ALARM
exti_reset();
#endif
// TEMP: set up interrupt logging pins
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// TEMP: ping port init
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,1);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,0);
}
void reset_to_bootloader(void) {