MCPcopy Create free account
hub / github.com/OpenEarable/open-earable / initVariant

Function initVariant

resources/variant/variant.cpp:140–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138#include "nrf_uart.h"
139
140void initVariant() {
141 // Errata Nano33BLE - I2C pullup is controlled by the SWO pin.
142 // Configure the TRACEMUX to disable routing SWO signal to pin.
143 NRF_CLOCK->TRACECONFIG = 0;
144
145 // FIXME: bootloader enables interrupt on COMPARE[0], which we don't handle
146 // Disable it here to avoid getting stuck when OVERFLOW irq is triggered
147 nrf_rtc_event_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
148 nrf_rtc_int_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
149
150 // FIXME: always enable I2C pullup and power @startup
151 // Change for maximum powersave
152 pinMode(PIN_ENABLE_SENSORS_3V3, OUTPUT);
153 // pinMode(PIN_ENABLE_I2C_PULLUP, OUTPUT);
154
155 digitalWrite(PIN_ENABLE_SENSORS_3V3, HIGH);
156 // digitalWrite(PIN_ENABLE_I2C_PULLUP, HIGH);
157
158 // Disable UARTE0 which is initially enabled by the bootloader
159 nrf_uarte_task_trigger(NRF_UARTE0, NRF_UARTE_TASK_STOPRX);
160 while (!nrf_uarte_event_check(NRF_UARTE0, NRF_UARTE_EVENT_RXTO)) ;
161 NRF_UARTE0->ENABLE = 0;
162 NRF_UART0->ENABLE = 0;
163
164 NRF_PWM_Type* PWM[] = {
165 NRF_PWM0, NRF_PWM1, NRF_PWM2
166#ifdef NRF_PWM3
167 ,NRF_PWM3
168#endif
169 };
170
171 for (unsigned int i = 0; i < (sizeof(PWM)/sizeof(PWM[0])); i++) {
172 PWM[i]->ENABLE = 0;
173 PWM[i]->PSEL.OUT[0] = 0xFFFFFFFFUL;
174 }
175}
176
177#ifdef SERIAL_CDC
178

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected