Fix formatting and broken links

Implmements missed pre-commit changes for all files, and fixes links broken by
cleanup in #4698
This commit is contained in:
Lucian Copeland 2021-05-10 18:04:43 -04:00
parent f59a19847c
commit 525b34b042
11 changed files with 42 additions and 47 deletions

View File

@ -102,7 +102,7 @@ bool alarm_pin_pinalarm_woke_us_up(void) {
mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) { mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *alarms) {
// For light sleep, we check if we match any existing alarms // For light sleep, we check if we match any existing alarms
uint64_t pin_status = ((uint64_t) pin_63_32_status) << 32 | pin_31_0_status; uint64_t pin_status = ((uint64_t)pin_63_32_status) << 32 | pin_31_0_status;
for (size_t i = 0; i < n_alarms; i++) { for (size_t i = 0; i < n_alarms; i++) {
if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) {
continue; continue;

View File

@ -38,12 +38,12 @@ uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self
return 0; 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) { 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")); mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return false; 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) { 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")); mp_raise_NotImplementedError(translate("Sleep Memory not available"));
return; return;
} }

View File

@ -38,7 +38,7 @@
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/port.h" #include "supervisor/port.h"
#include "supervisor/shared/workflow.h" #include "supervisor/workflow.h"
// Singleton instance of SleepMemory. // Singleton instance of SleepMemory.
const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = {
@ -167,7 +167,9 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) {
HAL_PWR_EnterSTANDBYMode(); HAL_PWR_EnterSTANDBYMode();
// The above shuts down RAM, so we should never hit this // The above shuts down RAM, so we should never hit this
while(1); while (1) {
;
}
} }
void common_hal_alarm_pretending_deep_sleep(void) { void common_hal_alarm_pretending_deep_sleep(void) {

View File

@ -94,7 +94,7 @@ mp_obj_t alarm_pin_pinalarm_get_wakeup_alarm(size_t n_alarms, const mp_obj_t *al
if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) {
continue; continue;
} }
alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]);
if (alarm_pin_triggered & (1 << alarm->pin->number)) { if (alarm_pin_triggered & (1 << alarm->pin->number)) {
return alarms[i]; return alarms[i];
} }
@ -125,7 +125,7 @@ void alarm_pin_pinalarm_reset(void) {
void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) {
for (size_t i = 0; i < n_alarms; i++) { for (size_t i = 0; i < n_alarms; i++) {
if (mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { if (mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) {
alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]);
if (deep_sleep) { if (deep_sleep) {
// Deep sleep only wakes on a rising edge from one pin, WKUP (PA00) // Deep sleep only wakes on a rising edge from one pin, WKUP (PA00)
// All pin settings are handled automatically. // All pin settings are handled automatically.

View File

@ -82,7 +82,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_
if (timealarm_set) { if (timealarm_set) {
mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); mp_raise_ValueError(translate("Only one alarm.time alarm can be set."));
} }
timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm = MP_OBJ_TO_PTR(alarms[i]);
timealarm_set = true; timealarm_set = true;
} }
if (!timealarm_set) { if (!timealarm_set) {

View File

@ -40,7 +40,7 @@
#include STM32_HAL_H #include STM32_HAL_H
#define STM32_GPIO_PORT_SIZE 16 #define STM32_GPIO_PORT_SIZE 16
STATIC pulseio_pulsein_obj_t* callback_obj_ref[STM32_GPIO_PORT_SIZE]; STATIC pulseio_pulsein_obj_t *callback_obj_ref[STM32_GPIO_PORT_SIZE];
STATIC TIM_HandleTypeDef tim_handle; STATIC TIM_HandleTypeDef tim_handle;
STATIC uint32_t overflow_count = 0; STATIC uint32_t overflow_count = 0;
@ -64,7 +64,7 @@ STATIC void pulsein_exti_event_handler(uint8_t num) {
// Interrupt register must be cleared manually // Interrupt register must be cleared manually
EXTI->PR = 1 << num; EXTI->PR = 1 << num;
pulseio_pulsein_obj_t* self = callback_obj_ref[num]; pulseio_pulsein_obj_t *self = callback_obj_ref[num];
if (!self) { if (!self) {
return; return;
} }
@ -118,7 +118,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu
// Allocate pulse buffer // Allocate pulse buffer
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false); self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
if (self->buffer == NULL) { if (self->buffer == NULL) {
//TODO: free the EXTI here? // TODO: free the EXTI here?
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"),
maxlen * sizeof(uint16_t)); maxlen * sizeof(uint16_t));
} }
@ -189,7 +189,7 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) {
if (common_hal_pulseio_pulsein_deinited(self)) { if (common_hal_pulseio_pulsein_deinited(self)) {
return; return;
} }
//Remove pulsein slot from shared array // Remove pulsein slot from shared array
callback_obj_ref[self->pin->number] = NULL; callback_obj_ref[self->pin->number] = NULL;
stm_peripherals_exti_free(self->pin->number); stm_peripherals_exti_free(self->pin->number);
reset_pin_number(self->pin->port, self->pin->number); reset_pin_number(self->pin->port, self->pin->number);
@ -201,7 +201,7 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) {
} }
} }
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) { void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
stm_peripherals_exti_disable(self->pin->number); stm_peripherals_exti_disable(self->pin->number);
self->paused = true; self->paused = true;
} }
@ -239,14 +239,14 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, uint16_t tri
stm_peripherals_exti_enable(self->pin->number); stm_peripherals_exti_enable(self->pin->number);
} }
void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) { void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) {
stm_peripherals_exti_disable(self->pin->number); stm_peripherals_exti_disable(self->pin->number);
self->start = 0; self->start = 0;
self->len = 0; self->len = 0;
stm_peripherals_exti_enable(self->pin->number); stm_peripherals_exti_enable(self->pin->number);
} }
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) { uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_t index) {
stm_peripherals_exti_disable(self->pin->number); stm_peripherals_exti_disable(self->pin->number);
if (index < 0) { if (index < 0) {
index += self->len; index += self->len;

View File

@ -39,7 +39,7 @@ STATIC bool stm_exti_never_reset[STM32_GPIO_PORT_SIZE];
STATIC void (*stm_exti_callback[STM32_GPIO_PORT_SIZE])(uint8_t num); STATIC void (*stm_exti_callback[STM32_GPIO_PORT_SIZE])(uint8_t num);
void exti_reset(void) { void exti_reset(void) {
for (size_t i = 0;i < STM32_GPIO_PORT_SIZE; i++) { for (size_t i = 0; i < STM32_GPIO_PORT_SIZE; i++) {
if (!stm_exti_never_reset[i]) { if (!stm_exti_never_reset[i]) {
stm_exti_reserved[i] = false; stm_exti_reserved[i] = false;
stm_exti_callback[i] = NULL; stm_exti_callback[i] = NULL;
@ -79,7 +79,7 @@ void stm_peripherals_exti_disable(uint8_t num) {
HAL_NVIC_DisableIRQ(stm_peripherals_exti_get_irq(num)); HAL_NVIC_DisableIRQ(stm_peripherals_exti_get_irq(num));
} }
void stm_peripherals_exti_set_callback(void(*callback)(uint8_t num), uint8_t number) { void stm_peripherals_exti_set_callback(void (*callback)(uint8_t num), uint8_t number) {
stm_exti_callback[number] = callback; stm_exti_callback[number] = callback;
} }
@ -98,7 +98,7 @@ IRQn_Type stm_peripherals_exti_get_irq(uint8_t num) {
return EXTI3_IRQn; return EXTI3_IRQn;
} else if (num == 4) { } else if (num == 4) {
return EXTI4_IRQn; return EXTI4_IRQn;
} else if (num >= 5 && num <= 9 ) { } else if (num >= 5 && num <= 9) {
return EXTI9_5_IRQn; return EXTI9_5_IRQn;
} else if (num >= 10 && num <= 15) { } else if (num >= 10 && num <= 15) {
return EXTI15_10_IRQn; return EXTI15_10_IRQn;
@ -107,42 +107,35 @@ IRQn_Type stm_peripherals_exti_get_irq(uint8_t num) {
} }
} }
void EXTI0_IRQHandler(void) void EXTI0_IRQHandler(void) {
{
stm_exti_callback[0](0); stm_exti_callback[0](0);
} }
void EXTI1_IRQHandler(void) void EXTI1_IRQHandler(void) {
{
stm_exti_callback[1](1); stm_exti_callback[1](1);
} }
void EXTI2_IRQHandler(void) void EXTI2_IRQHandler(void) {
{
stm_exti_callback[2](2); stm_exti_callback[2](2);
} }
void EXTI3_IRQHandler(void) void EXTI3_IRQHandler(void) {
{
stm_exti_callback[3](3); stm_exti_callback[3](3);
} }
void EXTI4_IRQHandler(void) void EXTI4_IRQHandler(void) {
{
stm_exti_callback[4](4); stm_exti_callback[4](4);
} }
void EXTI9_5_IRQHandler(void) void EXTI9_5_IRQHandler(void) {
{
uint32_t pending = EXTI->PR; uint32_t pending = EXTI->PR;
for (uint i = 5; i <= 9; i++) { for (uint i = 5; i <= 9; i++) {
if(pending & (1 << i)) { if (pending & (1 << i)) {
stm_exti_callback[i](i); stm_exti_callback[i](i);
} }
} }
} }
void EXTI15_10_IRQHandler(void) void EXTI15_10_IRQHandler(void) {
{
uint32_t pending = EXTI->PR; uint32_t pending = EXTI->PR;
for (uint i = 10; i <= 15; i++) { for (uint i = 10; i <= 15; i++) {
if(pending & (1 << i)) { if (pending & (1 << i)) {
stm_exti_callback[i](i); stm_exti_callback[i](i);
} }
} }

View File

@ -38,7 +38,7 @@ bool stm_peripherals_exti_is_free(uint8_t num);
bool stm_peripherals_exti_reserve(uint8_t num); bool stm_peripherals_exti_reserve(uint8_t num);
void stm_peripherals_exti_enable(uint8_t num); void stm_peripherals_exti_enable(uint8_t num);
void stm_peripherals_exti_disable(uint8_t num); void stm_peripherals_exti_disable(uint8_t num);
void stm_peripherals_exti_set_callback(void(*callback)(uint8_t num), uint8_t number); void stm_peripherals_exti_set_callback(void (*callback)(uint8_t num), uint8_t number);
void stm_peripherals_exti_free(uint8_t num); void stm_peripherals_exti_free(uint8_t num);
IRQn_Type stm_peripherals_exti_get_irq(uint8_t num); IRQn_Type stm_peripherals_exti_get_irq(uint8_t num);

View File

@ -78,7 +78,7 @@ void stm32_peripherals_rtc_init(void) {
// This function is called often for timing so we cache the seconds elapsed computation based on the // This function is called often for timing so we cache the seconds elapsed computation based on the
// register value. The STM HAL always does shifts and conversion if we use it directly. // register value. The STM HAL always does shifts and conversion if we use it directly.
uint64_t stm32_peripherals_rtc_raw_ticks(uint8_t* subticks) { uint64_t stm32_peripherals_rtc_raw_ticks(uint8_t *subticks) {
// Disable IRQs to ensure we read all of the RTC registers as close in time as possible. Read // Disable IRQs to ensure we read all of the RTC registers as close in time as possible. Read
// SSR twice to make sure we didn't read across a tick. // SSR twice to make sure we didn't read across a tick.
__disable_irq(); __disable_irq();
@ -122,16 +122,16 @@ uint64_t stm32_peripherals_rtc_raw_ticks(uint8_t* subticks) {
*subticks = subseconds % 32; *subticks = subseconds % 32;
} }
uint64_t raw_ticks = ((uint64_t) TICK_DIVISOR) * (seconds_to_date + seconds_to_minute + seconds) + subseconds / 32; uint64_t raw_ticks = ((uint64_t)TICK_DIVISOR) * (seconds_to_date + seconds_to_minute + seconds) + subseconds / 32;
return raw_ticks; return raw_ticks;
} }
void stm32_peripherals_rtc_assign_wkup_callback(void(*callback)(void)) { void stm32_peripherals_rtc_assign_wkup_callback(void (*callback)(void)) {
wkup_callback = callback; wkup_callback = callback;
} }
void stm32_peripherals_rtc_set_wakeup_mode_seconds(uint32_t seconds) { void stm32_peripherals_rtc_set_wakeup_mode_seconds(uint32_t seconds) {
//prep stuff from CubeMX // prep stuff from CubeMX
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF); __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);
@ -159,8 +159,8 @@ void stm32_peripherals_rtc_reset_alarms(void) {
HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_B); HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_B);
} }
void stm32_peripherals_rtc_assign_alarm_callback(uint8_t alarm_idx, void(*callback)(void)) { void stm32_peripherals_rtc_assign_alarm_callback(uint8_t alarm_idx, void (*callback)(void)) {
alarm_callbacks[alarm_idx] = callback; alarm_callbacks[alarm_idx] = callback;
} }
void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks) { void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks) {
@ -183,7 +183,7 @@ void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks) {
} }
alarm.AlarmTime.SubSeconds = rtc_clock_frequency - 1 - alarm.AlarmTime.SubSeconds = rtc_clock_frequency - 1 -
((raw_ticks % TICK_DIVISOR) * 32); ((raw_ticks % TICK_DIVISOR) * 32);
alarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE; alarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
alarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_SET; alarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_SET;
// Masking here means that the bits are ignored so we set none of them. // Masking here means that the bits are ignored so we set none of them.

View File

@ -35,16 +35,16 @@
uint32_t stm32_peripherals_get_rtc_freq(void); uint32_t stm32_peripherals_get_rtc_freq(void);
void stm32_peripherals_rtc_init(void); void stm32_peripherals_rtc_init(void);
uint64_t stm32_peripherals_rtc_raw_ticks(uint8_t* subticks); uint64_t stm32_peripherals_rtc_raw_ticks(uint8_t *subticks);
void stm32_peripherals_rtc_assign_wkup_callback(void(*callback)(void)); void stm32_peripherals_rtc_assign_wkup_callback(void (*callback)(void));
void stm32_peripherals_rtc_set_wakeup_mode_seconds(uint32_t seconds); void stm32_peripherals_rtc_set_wakeup_mode_seconds(uint32_t seconds);
void stm32_peripherals_rtc_set_wakeup_mode_tick(void); void stm32_peripherals_rtc_set_wakeup_mode_tick(void);
void stm32_peripherals_rtc_enable_wakeup_timer(void); void stm32_peripherals_rtc_enable_wakeup_timer(void);
void stm32_peripherals_rtc_disable_wakeup_timer(void); void stm32_peripherals_rtc_disable_wakeup_timer(void);
void stm32_peripherals_rtc_reset_alarms(void); void stm32_peripherals_rtc_reset_alarms(void);
void stm32_peripherals_rtc_assign_alarm_callback(uint8_t alarm_idx, void(*callback)(void)) ; void stm32_peripherals_rtc_assign_alarm_callback(uint8_t alarm_idx, void (*callback)(void));
void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks); void stm32_peripherals_rtc_set_alarm(uint8_t alarm_idx, uint32_t ticks);
bool stm32_peripherals_rtc_alarm_triggered(uint8_t alarm_idx); bool stm32_peripherals_rtc_alarm_triggered(uint8_t alarm_idx);

View File

@ -261,7 +261,7 @@ void reset_port(void) {
pwmout_reset(); pwmout_reset();
#endif #endif
#if CIRCUITPY_PULSEIO || CIRCUITPY_ALARM #if CIRCUITPY_PULSEIO || CIRCUITPY_ALARM
exti_reset(); exti_reset();
#endif #endif
} }
@ -334,7 +334,7 @@ __attribute__((used)) void HardFault_Handler(void) {
} }
} }
uint64_t port_get_raw_ticks(uint8_t* subticks) { uint64_t port_get_raw_ticks(uint8_t *subticks) {
return stm32_peripherals_rtc_raw_ticks(subticks); return stm32_peripherals_rtc_raw_ticks(subticks);
} }