summaryrefslogtreecommitdiff
path: root/ports/nrf
diff options
context:
space:
mode:
Diffstat (limited to 'ports/nrf')
-rwxr-xr-xports/nrf/Makefile6
-rw-r--r--ports/nrf/common-hal/pulseio/PWMOut.c40
-rw-r--r--ports/nrf/mpconfigport.h1
3 files changed, 38 insertions, 9 deletions
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 2f762e2a3..a75d45f1f 100755
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -226,8 +226,10 @@ SRC_SHARED_MODULE = \
displayio/OnDiskBitmap.c \
displayio/Palette.c \
displayio/Shape.c \
- displayio/Sprite.c \
- storage/__init__.c
+ displayio/TileGrid.c \
+ storage/__init__.c \
+ terminalio/__init__.c \
+ terminalio/Terminal.c
ifndef EXCLUDE_PIXELBUF
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c
index f321f848d..cf2330934 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pulseio/PWMOut.c
@@ -55,8 +55,33 @@ STATIC NRF_PWM_Type* pwms[] = {
STATIC uint16_t pwm_seq[MP_ARRAY_SIZE(pwms)][CHANNELS_PER_PWM];
+static uint8_t never_reset_pwm[MP_ARRAY_SIZE(pwms)];
+
+void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+ for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
+ NRF_PWM_Type* pwm = pwms[i];
+ if (pwm == self->pwm) {
+ never_reset_pwm[i] += 1;
+ }
+ }
+
+ never_reset_pin_number(self->pin_number);
+}
+
+void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+ for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
+ NRF_PWM_Type* pwm = pwms[i];
+ if (pwm == self->pwm) {
+ never_reset_pwm[i] -= 1;
+ }
+ }
+}
+
void pwmout_reset(void) {
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
+ if (never_reset_pwm[i] > 0) {
+ continue;
+ }
NRF_PWM_Type* pwm = pwms[i];
pwm->ENABLE = 0;
@@ -104,11 +129,11 @@ bool convert_frequency(uint32_t frequency, uint16_t *countertop, nrf_pwm_clk_t *
return false;
}
-void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
- const mcu_pin_obj_t* pin,
- uint16_t duty,
- uint32_t frequency,
- bool variable_frequency) {
+pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+ const mcu_pin_obj_t* pin,
+ uint16_t duty,
+ uint32_t frequency,
+ bool variable_frequency) {
// We don't use the nrfx driver here because we want to dynamically allocate channels
// as needed in an already-enabled PWM.
@@ -116,7 +141,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
uint16_t countertop;
nrf_pwm_clk_t base_clock;
if (frequency == 0 || !convert_frequency(frequency, &countertop, &base_clock)) {
- mp_raise_ValueError(translate("Invalid PWM frequency"));
+ return PWMOUT_INVALID_FREQUENCY;
}
self->pwm = NULL;
@@ -158,7 +183,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
}
if (self->pwm == NULL) {
- mp_raise_ValueError(translate("All PWM peripherals are in use"));
+ return PWMOUT_ALL_TIMERS_IN_USE;
}
self->pin_number = pin->number;
@@ -183,6 +208,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
nrf_pwm_enable(pwm);
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ return PWMOUT_OK;
}
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h
index f63265129..e97c13d81 100644
--- a/ports/nrf/mpconfigport.h
+++ b/ports/nrf/mpconfigport.h
@@ -229,6 +229,7 @@ extern const struct _mp_obj_module_t touchio_module;
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[8]; \
mp_obj_t gamepad_singleton; \
+ mp_obj_t terminal_tilegrid_tiles; \
FLASH_ROOT_POINTERS \
// We need to provide a declaration/definition of alloca()