summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/atmel-samd/boards/pycubed/board.c8
-rw-r--r--ports/atmel-samd/boards/pycubed_mram/board.c8
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/atmel-samd/common-hal/pwmio/PWMOut.c (renamed from ports/atmel-samd/common-hal/pulseio/PWMOut.c)30
-rw-r--r--ports/atmel-samd/common-hal/pwmio/PWMOut.h (renamed from ports/atmel-samd/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/atmel-samd/common-hal/pwmio/__init__.c1
-rw-r--r--ports/atmel-samd/supervisor/port.c4
-rw-r--r--ports/cxd56/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/cxd56/common-hal/pwmio/PWMOut.c (renamed from ports/cxd56/common-hal/pulseio/PWMOut.c)24
-rw-r--r--ports/cxd56/common-hal/pwmio/PWMOut.h (renamed from ports/cxd56/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/cxd56/common-hal/pwmio/__init__.c1
-rw-r--r--ports/cxd56/supervisor/port.c4
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseOut.c4
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseOut.h1
-rw-r--r--ports/esp32s2/common-hal/pwmio/PWMOut.c (renamed from ports/esp32s2/common-hal/pulseio/PWMOut.c)28
-rw-r--r--ports/esp32s2/common-hal/pwmio/PWMOut.h (renamed from ports/esp32s2/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/esp32s2/common-hal/pwmio/__init__.c1
-rw-r--r--ports/esp32s2/supervisor/port.c8
-rw-r--r--ports/mimxrt10xx/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/mimxrt10xx/common-hal/pwmio/PWMOut.c (renamed from ports/mimxrt10xx/common-hal/pulseio/PWMOut.c)32
-rw-r--r--ports/mimxrt10xx/common-hal/pwmio/PWMOut.h (renamed from ports/mimxrt10xx/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/mimxrt10xx/common-hal/pwmio/__init__.c1
-rw-r--r--ports/mimxrt10xx/supervisor/port.c4
-rw-r--r--ports/nrf/common-hal/audiopwmio/PWMAudioOut.c2
-rw-r--r--ports/nrf/common-hal/pulseio/PulseOut.c4
-rw-r--r--ports/nrf/common-hal/pulseio/PulseOut.h4
-rw-r--r--ports/nrf/common-hal/pwmio/PWMOut.c (renamed from ports/nrf/common-hal/pulseio/PWMOut.c)30
-rw-r--r--ports/nrf/common-hal/pwmio/PWMOut.h (renamed from ports/nrf/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/nrf/common-hal/pwmio/__init__.c1
-rw-r--r--ports/nrf/supervisor/port.c7
-rw-r--r--ports/stm/common-hal/pulseio/PulseOut.c6
-rw-r--r--ports/stm/common-hal/pulseio/PulseOut.h4
-rw-r--r--ports/stm/common-hal/pwmio/PWMOut.c (renamed from ports/stm/common-hal/pulseio/PWMOut.c)26
-rw-r--r--ports/stm/common-hal/pwmio/PWMOut.h (renamed from ports/stm/common-hal/pulseio/PWMOut.h)8
-rw-r--r--ports/stm/common-hal/pwmio/__init__.c1
-rw-r--r--ports/stm/supervisor/port.c14
-rw-r--r--py/circuitpy_defns.mk10
-rw-r--r--py/circuitpy_mpconfig.h16
-rw-r--r--py/circuitpy_mpconfig.mk15
-rw-r--r--shared-bindings/pulseio/PulseOut.c14
-rw-r--r--shared-bindings/pulseio/PulseOut.h4
-rw-r--r--shared-bindings/pulseio/__init__.c31
-rw-r--r--shared-bindings/pwmio/PWMOut.c (renamed from shared-bindings/pulseio/PWMOut.c)104
-rw-r--r--shared-bindings/pwmio/PWMOut.h (renamed from shared-bindings/pulseio/PWMOut.h)30
-rw-r--r--shared-bindings/pwmio/__init__.c73
-rw-r--r--shared-bindings/pwmio/__init__.h34
-rw-r--r--shared-module/displayio/Display.c16
-rw-r--r--shared-module/displayio/Display.h8
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.h1
-rw-r--r--supervisor/shared/rgb_led_status.c44
50 files changed, 425 insertions, 287 deletions
diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c
index 9d29d2a66..0bf586ad8 100644
--- a/ports/atmel-samd/boards/pycubed/board.c
+++ b/ports/atmel-samd/boards/pycubed/board.c
@@ -32,7 +32,7 @@
#include "shared-bindings/nvm/ByteArray.h"
#include "common-hal/microcontroller/Pin.h"
#include "hal/include/hal_gpio.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
nvm_bytearray_obj_t bootcnt = {
.base = {
@@ -44,9 +44,9 @@ nvm_bytearray_obj_t bootcnt = {
void board_init(void) {
- pulseio_pwmout_obj_t pwm;
- common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
- common_hal_pulseio_pwmout_never_reset(&pwm);
+ pwmio_pwmout_obj_t pwm;
+ common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
+ common_hal_pwmio_pwmout_never_reset(&pwm);
}
bool board_requests_safe_mode(void) {
diff --git a/ports/atmel-samd/boards/pycubed_mram/board.c b/ports/atmel-samd/boards/pycubed_mram/board.c
index 9d29d2a66..0bf586ad8 100644
--- a/ports/atmel-samd/boards/pycubed_mram/board.c
+++ b/ports/atmel-samd/boards/pycubed_mram/board.c
@@ -32,7 +32,7 @@
#include "shared-bindings/nvm/ByteArray.h"
#include "common-hal/microcontroller/Pin.h"
#include "hal/include/hal_gpio.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
nvm_bytearray_obj_t bootcnt = {
.base = {
@@ -44,9 +44,9 @@ nvm_bytearray_obj_t bootcnt = {
void board_init(void) {
- pulseio_pwmout_obj_t pwm;
- common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
- common_hal_pulseio_pwmout_never_reset(&pwm);
+ pwmio_pwmout_obj_t pwm;
+ common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
+ common_hal_pwmio_pwmout_never_reset(&pwm);
}
bool board_requests_safe_mode(void) {
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
index b53c8da2b..3463bb5e2 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
@@ -96,7 +96,7 @@ void pulseout_reset() {
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c
index e33437dad..2e538ccdc 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c
@@ -28,8 +28,8 @@
#include <stdint.h>
#include "py/runtime.h"
-#include "common-hal/pulseio/PWMOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "shared-bindings/microcontroller/Processor.h"
#include "timer_handler.h"
@@ -78,13 +78,13 @@ void timer_reset_ok(int index, bool is_tc) {
}
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
timer_never_reset(self->timer->index, self->timer->is_tc);
never_reset_pin_number(self->pin->number);
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
timer_reset_ok(self->timer->index, self->timer->is_tc);
}
@@ -137,7 +137,7 @@ bool channel_ok(const pin_timer_t* t) {
t->is_tc;
}
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
const mcu_pin_obj_t* pin,
uint16_t duty,
uint32_t frequency,
@@ -296,16 +296,16 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_E + mux_position);
- common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
return PWMOUT_OK;
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
return self->pin == NULL;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
const pin_timer_t* t = self->timer;
@@ -331,7 +331,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
self->pin = NULL;
}
-extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
+extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
// Store the unadjusted duty cycle. It turns out the the process of adjusting and calculating
// the duty cycle here and reading it back is lossy - the value will decay over time.
// Track it here so that if frequency is changed we can use this value to recalculate the
@@ -373,7 +373,7 @@ extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self,
}
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
const pin_timer_t* t = self->timer;
if (t->is_tc) {
Tc* tc = tc_insts[t->index];
@@ -411,7 +411,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self,
uint32_t frequency) {
if (frequency == 0 || frequency > 6000000) {
mp_raise_ValueError(translate("Invalid PWM frequency"));
@@ -466,10 +466,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
#endif
}
- common_hal_pulseio_pwmout_set_duty_cycle(self, self->duty_cycle);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, self->duty_cycle);
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
const pin_timer_t* t = self->timer;
uint8_t divisor;
@@ -484,6 +484,6 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
return (system_clock / prescaler[divisor]) / (top + 1);
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
return self->variable_frequency;
}
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.h b/ports/atmel-samd/common-hal/pwmio/PWMOut.h
index 09abda819..1f5e62bae 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.h
+++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
#include "common-hal/microcontroller/Pin.h"
@@ -37,8 +37,8 @@ typedef struct {
const pin_timer_t* timer;
bool variable_frequency;
uint16_t duty_cycle;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
-#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/atmel-samd/common-hal/pwmio/__init__.c b/ports/atmel-samd/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/atmel-samd/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index 591a85853..6352afb1d 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -59,7 +59,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/pulseio/PulseOut.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "common-hal/ps2io/Ps2.h"
#include "common-hal/rtc/RTC.h"
@@ -335,6 +335,8 @@ void reset_port(void) {
#if CIRCUITPY_PULSEIO
pulsein_reset();
pulseout_reset();
+#endif
+#if CIRCUITPY_PWMIO
pwmout_reset();
#endif
diff --git a/ports/cxd56/common-hal/pulseio/PulseOut.c b/ports/cxd56/common-hal/pulseio/PulseOut.c
index 08081020f..764a5860a 100644
--- a/ports/cxd56/common-hal/pulseio/PulseOut.c
+++ b/ports/cxd56/common-hal/pulseio/PulseOut.c
@@ -59,7 +59,7 @@ static bool pulseout_timer_handler(unsigned int *next_interval_us, void *arg)
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
diff --git a/ports/cxd56/common-hal/pulseio/PWMOut.c b/ports/cxd56/common-hal/pwmio/PWMOut.c
index 7e0be566b..e0eb7abde 100644
--- a/ports/cxd56/common-hal/pulseio/PWMOut.c
+++ b/ports/cxd56/common-hal/pwmio/PWMOut.c
@@ -30,7 +30,7 @@
#include "py/runtime.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
typedef struct {
const char* devpath;
@@ -46,7 +46,7 @@ STATIC pwmout_dev_t pwmout_dev[] = {
{"/dev/pwm3", &pin_PWM3, -1, true}
};
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
const mcu_pin_obj_t *pin, uint16_t duty, uint32_t frequency,
bool variable_frequency) {
self->number = -1;
@@ -85,8 +85,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
return PWMOUT_OK;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t *self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
@@ -98,21 +98,21 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t *self) {
self->pin = NULL;
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t *self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t *self) {
return pwmout_dev[self->number].fd < 0;
}
-void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16_t duty) {
+void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty) {
self->info.duty = duty;
ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info));
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t *self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self) {
return self->info.duty;
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t *self, uint32_t frequency) {
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t frequency) {
self->info.frequency = frequency;
if (ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info)) < 0) {
@@ -120,21 +120,21 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t *self, uint32_
}
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t *self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t *self) {
return self->info.frequency;
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t *self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t *self) {
return self->variable_frequency;
}
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
never_reset_pin_number(self->pin->number);
pwmout_dev[self->number].reset = false;
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
pwmout_dev[self->number].reset = true;
}
diff --git a/ports/cxd56/common-hal/pulseio/PWMOut.h b/ports/cxd56/common-hal/pwmio/PWMOut.h
index 694acc4e0..d9f3ea389 100644
--- a/ports/cxd56/common-hal/pulseio/PWMOut.h
+++ b/ports/cxd56/common-hal/pwmio/PWMOut.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
#include <nuttx/timers/pwm.h>
@@ -39,10 +39,10 @@ typedef struct {
struct pwm_info_s info;
bool variable_frequency;
int8_t number;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
void pwmout_start(uint8_t pwm_num);
void pwmout_stop(uint8_t pwm_num);
-#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/cxd56/common-hal/pwmio/__init__.c b/ports/cxd56/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/cxd56/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/cxd56/supervisor/port.c b/ports/cxd56/supervisor/port.c
index bbd864f90..7038ca478 100644
--- a/ports/cxd56/supervisor/port.c
+++ b/ports/cxd56/supervisor/port.c
@@ -43,7 +43,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/analogio/AnalogIn.h"
#include "common-hal/pulseio/PulseOut.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "common-hal/busio/UART.h"
safe_mode_t port_init(void) {
@@ -69,6 +69,8 @@ void reset_port(void) {
#endif
#if CIRCUITPY_PULSEIO
pulseout_reset();
+#endif
+#if CIRCUITPY_PWMIO
pwmout_reset();
#endif
#if CIRCUITPY_BUSIO
diff --git a/ports/esp32s2/common-hal/pulseio/PulseOut.c b/ports/esp32s2/common-hal/pulseio/PulseOut.c
index d3c163ca8..cfe750732 100644
--- a/ports/esp32s2/common-hal/pulseio/PulseOut.c
+++ b/ports/esp32s2/common-hal/pulseio/PulseOut.c
@@ -26,13 +26,13 @@
#include "common-hal/pulseio/PulseOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "py/runtime.h"
// Requires rmt.c void esp32s2_peripherals_reset_all(void) to reset
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
diff --git a/ports/esp32s2/common-hal/pulseio/PulseOut.h b/ports/esp32s2/common-hal/pulseio/PulseOut.h
index 513905992..629591af6 100644
--- a/ports/esp32s2/common-hal/pulseio/PulseOut.h
+++ b/ports/esp32s2/common-hal/pulseio/PulseOut.h
@@ -28,7 +28,6 @@
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
#include "common-hal/microcontroller/Pin.h"
-#include "common-hal/pulseio/PWMOut.h"
#include "driver/rmt.h"
#include "rmt.h"
diff --git a/ports/esp32s2/common-hal/pulseio/PWMOut.c b/ports/esp32s2/common-hal/pwmio/PWMOut.c
index 0ac42852a..d745b7789 100644
--- a/ports/esp32s2/common-hal/pulseio/PWMOut.c
+++ b/ports/esp32s2/common-hal/pwmio/PWMOut.c
@@ -25,8 +25,8 @@
*/
#include <math.h>
-#include "common-hal/pulseio/PWMOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "py/runtime.h"
#include "driver/ledc.h"
@@ -58,7 +58,7 @@ void pwmout_reset(void) {
not_first_reset = true;
}
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
const mcu_pin_obj_t* pin,
uint16_t duty,
uint32_t frequency,
@@ -140,27 +140,27 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
claim_pin(pin);
// Set initial duty
- common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
return PWMOUT_OK;
}
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
never_reset_tim[self->tim_handle.timer_num] = true;
never_reset_chan[self->chan_handle.channel] = true;
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
never_reset_tim[self->tim_handle.timer_num] = false;
never_reset_chan[self->chan_handle.channel] = false;
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
return self->deinited == true;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
@@ -186,23 +186,23 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
self->deinited = true;
}
-void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
+void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
ledc_set_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, duty >> (16 - self->duty_resolution));
ledc_update_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel);
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
return ledc_get_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel) << (16 - self->duty_resolution);
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
ledc_set_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num, frequency);
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
return ledc_get_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
return self->variable_frequency;
}
diff --git a/ports/esp32s2/common-hal/pulseio/PWMOut.h b/ports/esp32s2/common-hal/pwmio/PWMOut.h
index 90a0c3ed9..c489e5a27 100644
--- a/ports/esp32s2/common-hal/pulseio/PWMOut.h
+++ b/ports/esp32s2/common-hal/pwmio/PWMOut.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
#include "common-hal/microcontroller/Pin.h"
#include "driver/ledc.h"
@@ -38,8 +38,8 @@ typedef struct {
uint8_t duty_resolution;
bool variable_frequency: 1;
bool deinited: 1;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
-#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/esp32s2/common-hal/pwmio/__init__.c b/ports/esp32s2/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/esp32s2/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index 46590b551..03caed92e 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -38,8 +38,8 @@
#include "common-hal/busio/I2C.h"
#include "common-hal/busio/SPI.h"
#include "common-hal/busio/UART.h"
-#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/pulseio/PulseIn.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "supervisor/memory.h"
#include "supervisor/shared/tick.h"
@@ -70,9 +70,13 @@ void reset_port(void) {
#if CIRCUITPY_PULSEIO
esp32s2_peripherals_rmt_reset();
- pwmout_reset();
pulsein_reset();
#endif
+
+#if CIRCUITPY_PWMIO
+ pwmout_reset();
+#endif
+
#if CIRCUITPY_BUSIO
i2c_reset();
spi_reset();
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
index 3aefd8766..d3a1a897f 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
+++ b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
@@ -94,7 +94,7 @@ void pulseout_reset() {
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
index 50dd477ea..dd464ef84 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c
+++ b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c
@@ -29,8 +29,8 @@
#include <stdint.h>
#include "py/runtime.h"
-#include "common-hal/pulseio/PWMOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "shared-bindings/microcontroller/Processor.h"
#include "fsl_pwm.h"
@@ -64,7 +64,7 @@
//
//static uint8_t never_reset_tc_or_tcc[TC_INST_NUM + TCC_INST_NUM];
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
// if (self->timer->is_tc) {
// never_reset_tc_or_tcc[self->timer->index] += 1;
// } else {
@@ -74,7 +74,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
// never_reset_pin_number(self->pin->number);
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
// if (self->timer->is_tc) {
// never_reset_tc_or_tcc[self->timer->index] -= 1;
// } else {
@@ -133,7 +133,7 @@ void pwmout_reset(void) {
#define PWM_SRC_CLK_FREQ CLOCK_GetFreq(kCLOCK_IpgClk)
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
const mcu_pin_obj_t *pin,
uint16_t duty,
uint32_t frequency,
@@ -359,17 +359,17 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
//
// gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_E + mux_position);
- common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
return PWMOUT_OK;
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
return self->pin == NULL;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
@@ -396,7 +396,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
self->pin = NULL;
}
-void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16_t duty) {
+void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty) {
PWM_UpdatePwmDutycycle(PWM1, self->pwm->submodule, self->pwm->channel, kPWM_SignedCenterAligned, duty);
// const pin_timer_t* t = self->timer;
@@ -433,7 +433,7 @@ void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16
// }
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
return 0;
// const pin_timer_t* t = self->timer;
// if (t->is_tc) {
@@ -471,7 +471,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
// }
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self,
uint32_t frequency) {
// if (frequency == 0 || frequency > 6000000) {
// mp_raise_ValueError(translate("Invalid PWM frequency"));
@@ -492,7 +492,7 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
// break;
// }
// }
-// uint16_t old_duty = common_hal_pulseio_pwmout_get_duty_cycle(self);
+// uint16_t old_duty = common_hal_pwmio_pwmout_get_duty_cycle(self);
// if (t->is_tc) {
// Tc* tc = tc_insts[t->index];
// uint8_t old_divisor = tc->COUNT16.CTRLA.bit.PRESCALER;
@@ -527,10 +527,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
// #endif
// }
-// common_hal_pulseio_pwmout_set_duty_cycle(self, old_duty);
+// common_hal_pwmio_pwmout_set_duty_cycle(self, old_duty);
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
// uint32_t system_clock = common_hal_mcu_processor_get_frequency();
// const pin_timer_t* t = self->timer;
// uint8_t divisor;
@@ -546,6 +546,6 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
return 0;
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
return self->variable_frequency;
}
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.h b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.h
index 2f0fe94c4..d3954de40 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.h
+++ b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.h
@@ -25,8 +25,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
#include "common-hal/microcontroller/Pin.h"
#include "periph.h"
@@ -37,8 +37,8 @@ typedef struct {
const mcu_pin_obj_t *pin;
const mcu_pwm_obj_t *pwm;
bool variable_frequency;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
-#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/mimxrt10xx/common-hal/pwmio/__init__.c b/ports/mimxrt10xx/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/mimxrt10xx/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/mimxrt10xx/supervisor/port.c b/ports/mimxrt10xx/supervisor/port.c
index 0b53a79f0..38cf16a49 100644
--- a/ports/mimxrt10xx/supervisor/port.c
+++ b/ports/mimxrt10xx/supervisor/port.c
@@ -39,7 +39,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/pulseio/PulseOut.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "common-hal/rtc/RTC.h"
#include "common-hal/busio/SPI.h"
@@ -289,6 +289,8 @@ void reset_port(void) {
#if CIRCUITPY_PULSEIO
pulseout_reset();
+#endif
+#if CIRCUITPY_PWMIO
pwmout_reset();
#endif
diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
index 7fec766fb..ed1bf81e4 100644
--- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
+++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
@@ -32,7 +32,7 @@
#include "py/mperrno.h"
#include "py/runtime.h"
#include "common-hal/audiopwmio/PWMAudioOut.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c
index bdc5cfbef..9f301a730 100644
--- a/ports/nrf/common-hal/pulseio/PulseOut.c
+++ b/ports/nrf/common-hal/pulseio/PulseOut.c
@@ -34,7 +34,7 @@
#include "py/gc.h"
#include "py/runtime.h"
#include "shared-bindings/pulseio/PulseOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "supervisor/shared/translate.h"
// A single timer is shared amongst all PulseOut objects under the assumption that
@@ -100,7 +100,7 @@ void pulseout_reset() {
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
diff --git a/ports/nrf/common-hal/pulseio/PulseOut.h b/ports/nrf/common-hal/pulseio/PulseOut.h
index 42ec52e30..714f740b2 100644
--- a/ports/nrf/common-hal/pulseio/PulseOut.h
+++ b/ports/nrf/common-hal/pulseio/PulseOut.h
@@ -28,13 +28,13 @@
#define MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PULSEOUT_H
#include "common-hal/microcontroller/Pin.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
- const pulseio_pwmout_obj_t *pwmout;
+ const pwmio_pwmout_obj_t *pwmout;
} pulseio_pulseout_obj_t;
void pulseout_reset(void);
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pwmio/PWMOut.c
index 9d42ccca0..a9d896488 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pwmio/PWMOut.c
@@ -28,8 +28,8 @@
#include "nrf.h"
#include "py/runtime.h"
-#include "common-hal/pulseio/PWMOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "supervisor/shared/translate.h"
#include "nrf_gpio.h"
@@ -63,7 +63,7 @@ STATIC int pwm_idx(NRF_PWM_Type *pwm) {
return -1;
}
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
NRF_PWM_Type* pwm = pwms[i];
if (pwm == self->pwm) {
@@ -74,7 +74,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
never_reset_pin_number(self->pin_number);
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
NRF_PWM_Type* pwm = pwms[i];
if (pwm == self->pwm) {
@@ -204,7 +204,7 @@ void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel) {
nrf_pwm_disable(pwm);
}
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
const mcu_pin_obj_t* pin,
uint16_t duty,
uint32_t frequency,
@@ -251,16 +251,16 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
nrf_pwm_enable(self->pwm);
- common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
return PWMOUT_OK;
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
return self->pwm == NULL;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
@@ -275,7 +275,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
self->pin_number = NO_PIN;
}
-void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty_cycle) {
+void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty_cycle) {
self->duty_cycle = duty_cycle;
uint16_t* p_value = ((uint16_t*)self->pwm->SEQ[0].PTR) + self->channel;
@@ -284,11 +284,11 @@ void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16
self->pwm->TASKS_SEQSTART[0] = 1;
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
return self->duty_cycle;
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
// COUNTERTOP is 3..32767, so highest available frequency is PWM_MAX_FREQ / 3.
uint16_t countertop;
nrf_pwm_clk_t base_clock;
@@ -300,13 +300,13 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_
nrf_pwm_configure(self->pwm, base_clock, NRF_PWM_MODE_UP, countertop);
// Set the duty cycle again, because it depends on COUNTERTOP, which probably changed.
// Setting the duty cycle will also do a SEQSTART.
- common_hal_pulseio_pwmout_set_duty_cycle(self, self->duty_cycle);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, self->duty_cycle);
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
return self->frequency;
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
return self->variable_frequency;
}
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.h b/ports/nrf/common-hal/pwmio/PWMOut.h
index a0c2d8747..e910baa76 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.h
+++ b/ports/nrf/common-hal/pwmio/PWMOut.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
#include "nrfx_pwm.h"
#include "py/obj.h"
@@ -38,7 +38,7 @@ typedef struct {
bool variable_frequency: 1;
uint16_t duty_cycle;
uint32_t frequency;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock,
@@ -46,4 +46,4 @@ NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock,
IRQn_Type *irq);
void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel);
-#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/nrf/common-hal/pwmio/__init__.c b/ports/nrf/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/nrf/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c
index 87a4d7396..2945f244d 100644
--- a/ports/nrf/supervisor/port.c
+++ b/ports/nrf/supervisor/port.c
@@ -45,9 +45,9 @@
#include "common-hal/busio/I2C.h"
#include "common-hal/busio/SPI.h"
#include "common-hal/busio/UART.h"
-#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PulseIn.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "common-hal/rtc/RTC.h"
#include "common-hal/neopixel_write/__init__.h"
#include "common-hal/watchdog/WatchDogTimer.h"
@@ -196,11 +196,14 @@ void reset_port(void) {
#if CIRCUITPY_PULSEIO
- pwmout_reset();
pulseout_reset();
pulsein_reset();
#endif
+#if CIRCUITPY_PWMIO
+ pwmout_reset();
+#endif
+
#if CIRCUITPY_RTC
rtc_reset();
#endif
diff --git a/ports/stm/common-hal/pulseio/PulseOut.c b/ports/stm/common-hal/pulseio/PulseOut.c
index eec1049dd..3bf23ad14 100644
--- a/ports/stm/common-hal/pulseio/PulseOut.c
+++ b/ports/stm/common-hal/pulseio/PulseOut.c
@@ -32,7 +32,7 @@
#include "py/gc.h"
#include "py/runtime.h"
#include "shared-bindings/pulseio/PulseOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "supervisor/shared/translate.h"
#include STM32_HAL_H
@@ -113,7 +113,7 @@ void pulseout_reset() {
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle) {
@@ -143,7 +143,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
tim_handle.Instance->SR = 0;
// The HAL can't work with const, recast required.
- self->pwmout = (pulseio_pwmout_obj_t*)carrier;
+ self->pwmout = (pwmio_pwmout_obj_t*)carrier;
turn_off(self);
}
diff --git a/ports/stm/common-hal/pulseio/PulseOut.h b/ports/stm/common-hal/pulseio/PulseOut.h
index aa97396d0..29894f27d 100644
--- a/ports/stm/common-hal/pulseio/PulseOut.h
+++ b/ports/stm/common-hal/pulseio/PulseOut.h
@@ -28,13 +28,13 @@
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PULSEOUT_H
#include "common-hal/microcontroller/Pin.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
- pulseio_pwmout_obj_t *pwmout;
+ pwmio_pwmout_obj_t *pwmout;
} pulseio_pulseout_obj_t;
void pulseout_reset(void);
diff --git a/ports/stm/common-hal/pulseio/PWMOut.c b/ports/stm/common-hal/pwmio/PWMOut.c
index c9768f4f6..5427a39c7 100644
--- a/ports/stm/common-hal/pulseio/PWMOut.c
+++ b/ports/stm/common-hal/pwmio/PWMOut.c
@@ -27,8 +27,8 @@
#include <stdint.h>
#include "py/runtime.h"
-#include "common-hal/pulseio/PWMOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "supervisor/shared/translate.h"
#include "shared-bindings/microcontroller/__init__.h"
@@ -75,7 +75,7 @@ void pwmout_reset(void) {
}
}
-pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
const mcu_pin_obj_t* pin,
uint16_t duty,
uint32_t frequency,
@@ -204,7 +204,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
return PWMOUT_OK;
}
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
for (size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) {
if (mcu_tim_banks[i] == self->handle.Instance) {
never_reset_tim[i] = true;
@@ -214,7 +214,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
}
}
-void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
for(size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) {
if (mcu_tim_banks[i] == self->handle.Instance) {
never_reset_tim[i] = false;
@@ -223,12 +223,12 @@ void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
}
}
-bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
return self->tim == NULL;
}
-void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
return;
}
//var freq shuts down entire timer, others just their channel
@@ -248,17 +248,17 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
}
}
-void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
+void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
uint32_t internal_duty_cycle = timer_get_internal_duty(duty, self->period);
__HAL_TIM_SET_COMPARE(&self->handle, self->channel, internal_duty_cycle);
self->duty_cycle = duty;
}
-uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
return self->duty_cycle;
}
-void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
+void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
//don't halt setup for the same frequency
if (frequency == self->frequency) {
return;
@@ -295,10 +295,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_
self->period = period;
}
-uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
return self->frequency;
}
-bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
return self->variable_frequency;
}
diff --git a/ports/stm/common-hal/pulseio/PWMOut.h b/ports/stm/common-hal/pwmio/PWMOut.h
index 57ab143b9..5d8001202 100644
--- a/ports/stm/common-hal/pulseio/PWMOut.h
+++ b/ports/stm/common-hal/pwmio/PWMOut.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
#include "common-hal/microcontroller/Pin.h"
@@ -44,8 +44,8 @@ typedef struct {
uint16_t duty_cycle;
uint32_t frequency;
uint32_t period;
-} pulseio_pwmout_obj_t;
+} pwmio_pwmout_obj_t;
void pwmout_reset(void);
-#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
diff --git a/ports/stm/common-hal/pwmio/__init__.c b/ports/stm/common-hal/pwmio/__init__.c
new file mode 100644
index 000000000..9e551a107
--- /dev/null
+++ b/ports/stm/common-hal/pwmio/__init__.c
@@ -0,0 +1 @@
+// No pwmio module functions.
diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c
index 5ce92f70a..e21105001 100644
--- a/ports/stm/supervisor/port.c
+++ b/ports/stm/supervisor/port.c
@@ -38,9 +38,13 @@
#include "common-hal/busio/UART.h"
#endif
#if CIRCUITPY_PULSEIO
-#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PulseIn.h"
+#endif
+#if CIRCUITPY_PWMIO
+#include "common-hal/pwmio/PWMOut.h"
+#endif
+#if CIRCUITPY_PULSEIO || CIRCUITPY_PWMIO
#include "timers.h"
#endif
#if CIRCUITPY_SDIOIO
@@ -230,12 +234,16 @@ void reset_port(void) {
#if CIRCUITPY_SDIOIO
sdioio_reset();
#endif
-#if CIRCUITPY_PULSEIO
+#if CIRCUITPY_PULSEIO || CIRCUITPY_PWMIO
timers_reset();
- pwmout_reset();
+#endif
+#if CIRCUITPY_PULSEIO
pulseout_reset();
pulsein_reset();
#endif
+#if CIRCUITPY_PWMIO
+ pwmout_reset();
+#endif
}
void reset_to_bootloader(void) {
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index b70ae64a8..ab7a3af60 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -198,11 +198,14 @@ endif
ifeq ($(CIRCUITPY_RGBMATRIX),1)
SRC_PATTERNS += rgbmatrix/%
endif
+ifeq ($(CIRCUITPY_PS2IO),1)
+SRC_PATTERNS += ps2io/%
+endif
ifeq ($(CIRCUITPY_PULSEIO),1)
SRC_PATTERNS += pulseio/%
endif
-ifeq ($(CIRCUITPY_PS2IO),1)
-SRC_PATTERNS += ps2io/%
+ifeq ($(CIRCUITPY_PWMIO),1)
+SRC_PATTERNS += pwmio/%
endif
ifeq ($(CIRCUITPY_RANDOM),1)
SRC_PATTERNS += random/%
@@ -316,10 +319,11 @@ SRC_COMMON_HAL_ALL = \
os/__init__.c \
ps2io/Ps2.c \
ps2io/__init__.c \
- pulseio/PWMOut.c \
pulseio/PulseIn.c \
pulseio/PulseOut.c \
pulseio/__init__.c \
+ pwmio/PWMOut.c \
+ pwmio/__init__.c \
rgbmatrix/RGBMatrix.c \
rgbmatrix/__init__.c \
rotaryio/IncrementalEncoder.c \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 12d667d8f..76b91defa 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -503,6 +503,13 @@ extern const struct _mp_obj_module_t pixelbuf_module;
#define PIXELBUF_MODULE
#endif
+#if CIRCUITPY_PS2IO
+extern const struct _mp_obj_module_t ps2io_module;
+#define PS2IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ps2io), (mp_obj_t)&ps2io_module },
+#else
+#define PS2IO_MODULE
+#endif
+
#if CIRCUITPY_PULSEIO
extern const struct _mp_obj_module_t pulseio_module;
#define PULSEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module },
@@ -510,11 +517,11 @@ extern const struct _mp_obj_module_t pulseio_module;
#define PULSEIO_MODULE
#endif
-#if CIRCUITPY_PS2IO
-extern const struct _mp_obj_module_t ps2io_module;
-#define PS2IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ps2io), (mp_obj_t)&ps2io_module },
+#if CIRCUITPY_PWMIO
+extern const struct _mp_obj_module_t pwmio_module;
+#define PWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pwmio), (mp_obj_t)&pwmio_module },
#else
-#define PS2IO_MODULE
+#define PWMIO_MODULE
#endif
#if CIRCUITPY_RGBMATRIX
@@ -740,6 +747,7 @@ extern const struct _mp_obj_module_t watchdog_module;
PIXELBUF_MODULE \
PS2IO_MODULE \
PULSEIO_MODULE \
+ PWMIO_MODULE \
RANDOM_MODULE \
RE_MODULE \
RGBMATRIX_MODULE \
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index bdc1e77d5..379c3850e 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -148,19 +148,24 @@ CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
CIRCUITPY_PIXELBUF ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
-CIRCUITPY_RGBMATRIX ?= 0
-CFLAGS += -DCIRCUITPY_RGBMATRIX=$(CIRCUITPY_RGBMATRIX)
+# Only for SAMD boards for the moment
+CIRCUITPY_PS2IO ?= 0
+CFLAGS += -DCIRCUITPY_PS2IO=$(CIRCUITPY_PS2IO)
CIRCUITPY_PULSEIO ?= 1
CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
-# Only for SAMD boards for the moment
-CIRCUITPY_PS2IO ?= 0
-CFLAGS += -DCIRCUITPY_PS2IO=$(CIRCUITPY_PS2IO)
+# For now we tie PWMIO to PULSEIO so they always both exist. In CircuitPython 7
+# we can enable and disable them separately once PWMOut is removed from `pulseio`.
+CIRCUITPY_PWMIO = $(CIRCUITPY_PULSEIO)
+CFLAGS += -DCIRCUITPY_PWMIO=$(CIRCUITPY_PWMIO)
CIRCUITPY_RANDOM ?= 1
CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
+CIRCUITPY_RGBMATRIX ?= 0
+CFLAGS += -DCIRCUITPY_RGBMATRIX=$(CIRCUITPY_RGBMATRIX)
+
CIRCUITPY_ROTARYIO ?= 1
CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO)
diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c
index 3fd722558..2b787df4f 100644
--- a/shared-bindings/pulseio/PulseOut.c
+++ b/shared-bindings/pulseio/PulseOut.c
@@ -32,7 +32,7 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/pulseio/PulseOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
@@ -41,19 +41,20 @@
//| pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration
//| for on and off pairs."""
//|
-//| def __init__(self, carrier: PWMOut) -> None:
+//| def __init__(self, carrier: pwmio.PWMOut) -> None:
//| """Create a PulseOut object associated with the given PWMout object.
//|
-//| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin.
+//| :param ~pwmio.PWMOut carrier: PWMOut that is set to output on the desired pin.
//|
//| Send a short series of pulses::
//|
//| import array
//| import pulseio
+//| import pwmio
//| import board
//|
//| # 50% duty cycle at 38kHz.
-//| pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768)
+//| pwm = pwmio.PWMOut(board.D13, frequency=38000, duty_cycle=32768)
//| pulse = pulseio.PulseOut(pwm)
//| # on off on off on
//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000])
@@ -65,15 +66,14 @@
//| ...
//|
STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
-
pulseio_pulseout_obj_t *self = m_new_obj(pulseio_pulseout_obj_t);
self->base.type = &pulseio_pulseout_type;
mp_obj_t carrier_obj = pos_args[0];
- if (MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) {
+ if (MP_OBJ_IS_TYPE(carrier_obj, &pwmio_pwmout_type)) {
// Use a PWMOut Carrier
mp_arg_check_num(n_args, kw_args, 1, 1, false);
- common_hal_pulseio_pulseout_construct(self, (pulseio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
+ common_hal_pulseio_pulseout_construct(self, (pwmio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
} else {
// Use a Pin, frequency, and duty cycle
enum { ARG_pin, ARG_frequency};
diff --git a/shared-bindings/pulseio/PulseOut.h b/shared-bindings/pulseio/PulseOut.h
index 9d4778e93..49dc555fe 100644
--- a/shared-bindings/pulseio/PulseOut.h
+++ b/shared-bindings/pulseio/PulseOut.h
@@ -29,12 +29,12 @@
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/pulseio/PulseOut.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
extern const mp_obj_type_t pulseio_pulseout_type;
extern void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
- const pulseio_pwmout_obj_t* carrier,
+ const pwmio_pwmout_obj_t* carrier,
const mcu_pin_obj_t* pin,
uint32_t frequency,
uint16_t duty_cycle);
diff --git a/shared-bindings/pulseio/__init__.c b/shared-bindings/pulseio/__init__.c
index 87946e5f0..bfe9635f0 100644
--- a/shared-bindings/pulseio/__init__.c
+++ b/shared-bindings/pulseio/__init__.c
@@ -33,40 +33,29 @@
#include "shared-bindings/pulseio/__init__.h"
#include "shared-bindings/pulseio/PulseIn.h"
#include "shared-bindings/pulseio/PulseOut.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
-//| """Support for pulse based protocols
+//| """Support for individual pulse based protocols
//|
//| The `pulseio` module contains classes to provide access to basic pulse IO.
+//| Individual pulses are commonly used in infrared remotes and in DHT
+//| temperature sensors.
+//|
+//|
+//| .. warning:: PWMOut is moving to `pwmio` and will be removed from `pulseio`
+//| in CircuitPython 7.
//|
-
//| All classes change hardware state and should be deinitialized when they
//| are no longer needed if the program continues after use. To do so, either
//| call :py:meth:`!deinit` or use a context manager. See
-//| :ref:`lifetime-and-contextmanagers` for more info.
-//|
-//| For example::
-//|
-//| import pulseio
-//| import time
-//| from board import *
-//|
-//| pwm = pulseio.PWMOut(D13)
-//| pwm.duty_cycle = 2 ** 15
-//| time.sleep(0.1)
-//|
-//| This example will initialize the the device, set
-//| :py:data:`~pulseio.PWMOut.duty_cycle`, and then sleep 0.1 seconds.
-//| CircuitPython will automatically turn off the PWM when it resets all
-//| hardware after program completion. Use ``deinit()`` or a ``with`` statement
-//| to do it yourself."""
+//| :ref:`lifetime-and-contextmanagers` for more info."""
//|
STATIC const mp_rom_map_elem_t pulseio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pulseio) },
{ MP_ROM_QSTR(MP_QSTR_PulseIn), MP_ROM_PTR(&pulseio_pulsein_type) },
{ MP_ROM_QSTR(MP_QSTR_PulseOut), MP_ROM_PTR(&pulseio_pulseout_type) },
- { MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pulseio_pwmout_type) },
+ { MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pwmio_pwmout_type) },
};
STATIC MP_DEFINE_CONST_DICT(pulseio_module_globals, pulseio_module_globals_table);
diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c
index e9b6c45d2..da0755592 100644
--- a/shared-bindings/pulseio/PWMOut.c
+++ b/shared-bindings/pwmio/PWMOut.c
@@ -31,7 +31,7 @@
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
@@ -55,33 +55,33 @@
//|
//| Simple LED fade::
//|
-//| import pulseio
+//| import pwmio
//| import board
//|
-//| pwm = pulseio.PWMOut(board.D13) # output on D13
+//| pwm = pwmio.PWMOut(board.D13) # output on D13
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz
//|
//| PWM at specific frequency (servos and motors)::
//|
-//| import pulseio
+//| import pwmio
//| import board
//|
-//| pwm = pulseio.PWMOut(board.D13, frequency=50)
+//| pwm = pwmio.PWMOut(board.D13, frequency=50)
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz
//|
//| Variable frequency (usually tones)::
//|
-//| import pulseio
+//| import pwmio
//| import board
//| import time
//|
-//| pwm = pulseio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True)
+//| pwm = pwmio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True)
//| time.sleep(0.2)
//| pwm.frequency = 880
//| time.sleep(0.1)"""
//| ...
//|
-STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
+STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
enum { ARG_pin, ARG_duty_cycle, ARG_frequency, ARG_variable_frequency };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ, },
@@ -99,9 +99,9 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
bool variable_frequency = parsed_args[ARG_variable_frequency].u_bool;
// create PWM object from the given pin
- pulseio_pwmout_obj_t *self = m_new_obj(pulseio_pwmout_obj_t);
- self->base.type = &pulseio_pwmout_type;
- pwmout_result_t result = common_hal_pulseio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
+ pwmio_pwmout_obj_t *self = m_new_obj(pwmio_pwmout_obj_t);
+ self->base.type = &pwmio_pwmout_type;
+ pwmout_result_t result = common_hal_pwmio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
if (result == PWMOUT_INVALID_PIN) {
mp_raise_ValueError(translate("Invalid pin"));
} else if (result == PWMOUT_INVALID_FREQUENCY) {
@@ -119,15 +119,15 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
//| """Deinitialises the PWMOut and releases any hardware resources for reuse."""
//| ...
//|
-STATIC mp_obj_t pulseio_pwmout_deinit(mp_obj_t self_in) {
- pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
- common_hal_pulseio_pwmout_deinit(self);
+STATIC mp_obj_t pwmio_pwmout_deinit(mp_obj_t self_in) {
+ pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ common_hal_pwmio_pwmout_deinit(self);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_deinit_obj, pulseio_pwmout_deinit);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_deinit_obj, pwmio_pwmout_deinit);
-STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
- if (common_hal_pulseio_pwmout_deinited(self)) {
+STATIC void check_for_deinit(pwmio_pwmout_obj_t *self) {
+ if (common_hal_pwmio_pwmout_deinited(self)) {
raise_deinited_error();
}
}
@@ -143,12 +143,12 @@ STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
//|
-STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t pwmio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
- common_hal_pulseio_pwmout_deinit(args[0]);
+ common_hal_pwmio_pwmout_deinit(args[0]);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pulseio_pwmout_obj___exit__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pwmio_pwmout___exit___obj, 4, 4, pwmio_pwmout_obj___exit__);
//| duty_cycle: int
//| """16 bit value that dictates how much of one cycle is high (1) versus low
@@ -160,29 +160,29 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pu
//| Reading this property will return the value from the internal representation,
//| so it may differ from the value set."""
//|
-STATIC mp_obj_t pulseio_pwmout_obj_get_duty_cycle(mp_obj_t self_in) {
- pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+STATIC mp_obj_t pwmio_pwmout_obj_get_duty_cycle(mp_obj_t self_in) {
+ pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
- return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_duty_cycle(self));
+ return MP_OBJ_NEW_SMALL_INT(common_hal_pwmio_pwmout_get_duty_cycle(self));
}
-MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_duty_cycle_obj, pulseio_pwmout_obj_get_duty_cycle);
+MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_get_duty_cycle_obj, pwmio_pwmout_obj_get_duty_cycle);
-STATIC mp_obj_t pulseio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_cycle) {
- pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+STATIC mp_obj_t pwmio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_cycle) {
+ pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
mp_int_t duty = mp_obj_get_int(duty_cycle);
if (duty < 0 || duty > 0xffff) {
mp_raise_ValueError(translate("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)"));
}
- common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+ common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pwmout_set_duty_cycle_obj, pulseio_pwmout_obj_set_duty_cycle);
+MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_duty_cycle_obj, pwmio_pwmout_obj_set_duty_cycle);
-const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
+const mp_obj_property_t pwmio_pwmout_duty_cycle_obj = {
.base.type = &mp_type_property,
- .proxy = {(mp_obj_t)&pulseio_pwmout_get_duty_cycle_obj,
- (mp_obj_t)&pulseio_pwmout_set_duty_cycle_obj,
+ .proxy = {(mp_obj_t)&pwmio_pwmout_get_duty_cycle_obj,
+ (mp_obj_t)&pwmio_pwmout_set_duty_cycle_obj,
(mp_obj_t)&mp_const_none_obj},
};
@@ -196,50 +196,50 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
//| from the original duty cycle value. This should happen without any need
//| to manually re-set the duty cycle."""
//|
-STATIC mp_obj_t pulseio_pwmout_obj_get_frequency(mp_obj_t self_in) {
- pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+STATIC mp_obj_t pwmio_pwmout_obj_get_frequency(mp_obj_t self_in) {
+ pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
- return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_frequency(self));
+ return MP_OBJ_NEW_SMALL_INT(common_hal_pwmio_pwmout_get_frequency(self));
}
-MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_frequency_obj, pulseio_pwmout_obj_get_frequency);
+MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_get_frequency_obj, pwmio_pwmout_obj_get_frequency);
-STATIC mp_obj_t pulseio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t frequency) {
- pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t frequency) {
+ pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
- if (!common_hal_pulseio_pwmout_get_variable_frequency(self)) {
+ if (!common_hal_pwmio_pwmout_get_variable_frequency(self)) {
mp_raise_AttributeError(translate(
"PWM frequency not writable when variable_frequency is False on "
"construction."));
}
- common_hal_pulseio_pwmout_set_frequency(self, mp_obj_get_int(frequency));
+ common_hal_pwmio_pwmout_set_frequency(self, mp_obj_get_int(frequency));
return mp_const_none;
}
-MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pwmout_set_frequency_obj, pulseio_pwmout_obj_set_frequency);
+MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_frequency_obj, pwmio_pwmout_obj_set_frequency);
-const mp_obj_property_t pulseio_pwmout_frequency_obj = {
+const mp_obj_property_t pwmio_pwmout_frequency_obj = {
.base.type = &mp_type_property,
- .proxy = {(mp_obj_t)&pulseio_pwmout_get_frequency_obj,
- (mp_obj_t)&pulseio_pwmout_set_frequency_obj,
+ .proxy = {(mp_obj_t)&pwmio_pwmout_get_frequency_obj,
+ (mp_obj_t)&pwmio_pwmout_set_frequency_obj,
(mp_obj_t)&mp_const_none_obj},
};
-STATIC const mp_rom_map_elem_t pulseio_pwmout_locals_dict_table[] = {
+STATIC const mp_rom_map_elem_t pwmio_pwmout_locals_dict_table[] = {
// Methods
- { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pulseio_pwmout_deinit_obj) },
+ { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pwmio_pwmout_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
- { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pulseio_pwmout___exit___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pwmio_pwmout___exit___obj) },
// Properties
- { MP_ROM_QSTR(MP_QSTR_duty_cycle), MP_ROM_PTR(&pulseio_pwmout_duty_cycle_obj) },
- { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&pulseio_pwmout_frequency_obj) },
+ { MP_ROM_QSTR(MP_QSTR_duty_cycle), MP_ROM_PTR(&pwmio_pwmout_duty_cycle_obj) },
+ { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&pwmio_pwmout_frequency_obj) },
// TODO(tannewt): Add enabled to determine whether the signal is output
// without giving up the resources. Useful for IR output.
};
-STATIC MP_DEFINE_CONST_DICT(pulseio_pwmout_locals_dict, pulseio_pwmout_locals_dict_table);
+STATIC MP_DEFINE_CONST_DICT(pwmio_pwmout_locals_dict, pwmio_pwmout_locals_dict_table);
-const mp_obj_type_t pulseio_pwmout_type = {
+const mp_obj_type_t pwmio_pwmout_type = {
{ &mp_type_type },
.name = MP_QSTR_PWMOut,
- .make_new = pulseio_pwmout_make_new,
- .locals_dict = (mp_obj_dict_t*)&pulseio_pwmout_locals_dict,
+ .make_new = pwmio_pwmout_make_new,
+ .locals_dict = (mp_obj_dict_t*)&pwmio_pwmout_locals_dict,
};
diff --git a/shared-bindings/pulseio/PWMOut.h b/shared-bindings/pwmio/PWMOut.h
index c72278e0e..1a99914ea 100644
--- a/shared-bindings/pulseio/PWMOut.h
+++ b/shared-bindings/pwmio/PWMOut.h
@@ -24,13 +24,13 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
-#define MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
#include "common-hal/microcontroller/Pin.h"
-#include "common-hal/pulseio/PWMOut.h"
+#include "common-hal/pwmio/PWMOut.h"
-extern const mp_obj_type_t pulseio_pwmout_type;
+extern const mp_obj_type_t pwmio_pwmout_type;
typedef enum {
PWMOUT_OK,
@@ -40,19 +40,19 @@ typedef enum {
PWMOUT_ALL_TIMERS_IN_USE
} pwmout_result_t;
-extern pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+extern pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency,
bool variable_frequency);
-extern void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self);
-extern bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self);
-extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty);
-extern uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self);
-extern void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency);
-extern uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self);
-extern bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self);
+extern void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self);
+extern bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self);
+extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty);
+extern uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self);
+extern void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency);
+extern uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self);
+extern bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self);
// This is used by the supervisor to claim PWMOut devices indefinitely.
-extern void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self);
-extern void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self);
+extern void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self);
+extern void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self);
-#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
diff --git a/shared-bindings/pwmio/__init__.c b/shared-bindings/pwmio/__init__.c
new file mode 100644
index 000000000..a51383703
--- /dev/null
+++ b/shared-bindings/pwmio/__init__.c
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/pwmio/__init__.h"
+#include "shared-bindings/pwmio/PWMOut.h"
+
+//| """Support for PWM based protocols
+//|
+//| The `pwmio` module contains classes to provide access to basic pulse IO.
+//|
+
+//| All classes change hardware state and should be deinitialized when they
+//| are no longer needed if the program continues after use. To do so, either
+//| call :py:meth:`!deinit` or use a context manager. See
+//| :ref:`lifetime-and-contextmanagers` for more info.
+//|
+//| For example::
+//|
+//| import pwmio
+//| import time
+//| from board import *
+//|
+//| pwm = pwmio.PWMOut(D13)
+//| pwm.duty_cycle = 2 ** 15
+//| time.sleep(0.1)
+//|
+//| This example will initialize the the device, set
+//| :py:data:`~pwmio.PWMOut.duty_cycle`, and then sleep 0.1 seconds.
+//| CircuitPython will automatically turn off the PWM when it resets all
+//| hardware after program completion. Use ``deinit()`` or a ``with`` statement
+//| to do it yourself."""
+//|
+
+STATIC const mp_rom_map_elem_t pwmio_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pwmio) },
+ { MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pwmio_pwmout_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(pwmio_module_globals, pwmio_module_globals_table);
+
+const mp_obj_module_t pwmio_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&pwmio_module_globals,
+};
diff --git a/shared-bindings/pwmio/__init__.h b/shared-bindings/pwmio/__init__.h
new file mode 100644
index 000000000..93c70377d
--- /dev/null
+++ b/shared-bindings/pwmio/__init__.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
+
+#include "py/obj.h"
+
+// Nothing now.
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index 46bb6fdb5..4f92f249f 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -111,14 +111,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) {
// Avoid PWM types and functions when the module isn't enabled
#if (CIRCUITPY_PULSEIO)
- pwmout_result_t result = common_hal_pulseio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
+ pwmout_result_t result = common_hal_pwmio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
if (result != PWMOUT_OK) {
self->backlight_inout.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin);
common_hal_never_reset_pin(backlight_pin);
} else {
- self->backlight_pwm.base.type = &pulseio_pwmout_type;
- common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
+ self->backlight_pwm.base.type = &pwmio_pwmout_type;
+ common_hal_pwmio_pwmout_never_reset(&self->backlight_pwm);
}
#else
// Otherwise default to digital
@@ -173,14 +173,14 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
// Avoid PWM types and functions when the module isn't enabled
#if (CIRCUITPY_PULSEIO)
- bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false;
+ bool ispwm = (self->backlight_pwm.base.type == &pwmio_pwmout_type) ? true : false;
#else
bool ispwm = false;
#endif
if (ispwm) {
#if (CIRCUITPY_PULSEIO)
- common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
+ common_hal_pwmio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
ok = true;
#else
ok = false;
@@ -419,9 +419,9 @@ void release_display(displayio_display_obj_t* self) {
common_hal_displayio_display_set_auto_refresh(self, false);
release_display_core(&self->core);
#if (CIRCUITPY_PULSEIO)
- if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
- common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm);
- common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
+ if (self->backlight_pwm.base.type == &pwmio_pwmout_type) {
+ common_hal_pwmio_pwmout_reset_ok(&self->backlight_pwm);
+ common_hal_pwmio_pwmout_deinit(&self->backlight_pwm);
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
}
diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h
index 861a38fd7..bdb861aa0 100644
--- a/shared-module/displayio/Display.h
+++ b/shared-module/displayio/Display.h
@@ -29,8 +29,8 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/displayio/Group.h"
-#if CIRCUITPY_PULSEIO
-#include "shared-bindings/pulseio/PWMOut.h"
+#if CIRCUITPY_PWMIO
+#include "shared-bindings/pwmio/PWMOut.h"
#endif
#include "shared-module/displayio/area.h"
@@ -41,8 +41,8 @@ typedef struct {
displayio_display_core_t core;
union {
digitalio_digitalinout_obj_t backlight_inout;
- #if CIRCUITPY_PULSEIO
- pulseio_pwmout_obj_t backlight_pwm;
+ #if CIRCUITPY_PWMIO
+ pwmio_pwmout_obj_t backlight_pwm;
#endif
};
uint64_t last_backlight_refresh;
diff --git a/shared-module/framebufferio/FramebufferDisplay.h b/shared-module/framebufferio/FramebufferDisplay.h
index 89df0d27c..d73d4b9a9 100644
--- a/shared-module/framebufferio/FramebufferDisplay.h
+++ b/shared-module/framebufferio/FramebufferDisplay.h
@@ -33,7 +33,6 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/displayio/Group.h"
-#include "shared-bindings/pulseio/PWMOut.h"
#include "shared-module/displayio/area.h"
#include "shared-module/displayio/display_core.h"
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c
index 2f23e3125..283b9da12 100644
--- a/supervisor/shared/rgb_led_status.c
+++ b/supervisor/shared/rgb_led_status.c
@@ -66,22 +66,22 @@ busio_spi_obj_t status_apa102 = {
#if defined(CP_RGB_STATUS_R) || defined(CP_RGB_STATUS_G) || defined(CP_RGB_STATUS_B)
#define CP_RGB_STATUS_LED
-#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/pwmio/PWMOut.h"
#include "shared-bindings/microcontroller/Pin.h"
-pulseio_pwmout_obj_t rgb_status_r = {
+pwmio_pwmout_obj_t rgb_status_r = {
.base = {
- .type = &pulseio_pwmout_type,
+ .type = &pwmio_pwmout_type,
},
};
-pulseio_pwmout_obj_t rgb_status_g = {
+pwmio_pwmout_obj_t rgb_status_g = {
.base = {
- .type = &pulseio_pwmout_type,
+ .type = &pwmio_pwmout_type,
},
};
-pulseio_pwmout_obj_t rgb_status_b = {
+pwmio_pwmout_obj_t rgb_status_b = {
.base = {
- .type = &pulseio_pwmout_type,
+ .type = &pwmio_pwmout_type,
},
};
@@ -147,26 +147,26 @@ void rgb_led_status_init() {
#if defined(CP_RGB_STATUS_LED)
if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_R)) {
- pwmout_result_t red_result = common_hal_pulseio_pwmout_construct(&rgb_status_r, CP_RGB_STATUS_R, 0, 50000, false);
+ pwmout_result_t red_result = common_hal_pwmio_pwmout_construct(&rgb_status_r, CP_RGB_STATUS_R, 0, 50000, false);
if (PWMOUT_OK == red_result) {
- common_hal_pulseio_pwmout_never_reset(&rgb_status_r);
+ common_hal_pwmio_pwmout_never_reset(&rgb_status_r);
}
}
if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_G)) {
- pwmout_result_t green_result = common_hal_pulseio_pwmout_construct(&rgb_status_g, CP_RGB_STATUS_G, 0, 50000, false);
+ pwmout_result_t green_result = common_hal_pwmio_pwmout_construct(&rgb_status_g, CP_RGB_STATUS_G, 0, 50000, false);
if (PWMOUT_OK == green_result) {
- common_hal_pulseio_pwmout_never_reset(&rgb_status_g);
+ common_hal_pwmio_pwmout_never_reset(&rgb_status_g);
}
}
if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_B)) {
- pwmout_result_t blue_result = common_hal_pulseio_pwmout_construct(&rgb_status_b, CP_RGB_STATUS_B, 0, 50000, false);
+ pwmout_result_t blue_result = common_hal_pwmio_pwmout_construct(&rgb_status_b, CP_RGB_STATUS_B, 0, 50000, false);
if (PWMOUT_OK == blue_result) {
- common_hal_pulseio_pwmout_never_reset(&rgb_status_b);
+ common_hal_pwmio_pwmout_never_reset(&rgb_status_b);
}
}
#endif
@@ -242,9 +242,9 @@ void new_status_color(uint32_t rgb) {
status_rgb_color[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
#endif
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, status_rgb_color[0]);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, status_rgb_color[1]);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, status_rgb_color[2]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, status_rgb_color[0]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, status_rgb_color[1]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, status_rgb_color[2]);
#endif
}
@@ -288,9 +288,9 @@ void temp_status_color(uint32_t rgb) {
temp_status_color_rgb[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
#endif
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, temp_status_color_rgb[0]);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, temp_status_color_rgb[1]);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, temp_status_color_rgb[2]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, temp_status_color_rgb[0]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, temp_status_color_rgb[1]);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, temp_status_color_rgb[2]);
#endif
}
@@ -327,9 +327,9 @@ void clear_temp_status() {
blue = status_rgb_color[2];
#endif
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, red);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, green);
- common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, blue);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_r, red);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_g, green);
+ common_hal_pwmio_pwmout_set_duty_cycle(&rgb_status_b, blue);
#endif
}