Skip to content
Permalink
Browse files

feature: added machine.PWM class

  • Loading branch information...
boochow committed Oct 12, 2018
1 parent bca5cd8 commit 9c545dc3cb2b5b99a3db38d02424ecc152af0d5a
Showing with 10 additions and 1 deletion.
  1. +2 −0 raspberrypi/Makefile
  2. +1 −0 raspberrypi/modmachine.c
  3. +1 −0 raspberrypi/modmachine.h
  4. +6 −1 raspberrypi/rpi.c
@@ -71,6 +71,8 @@ SRC_C = \
machine_spi.c \
vc_property.c \
gpu_vc_property.c \
bcm283x_clockmgr.c \
machine_pwm.c \

SRC_LIB = $(addprefix lib/,\
utils/stdout_helpers.c \
@@ -27,6 +27,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SD), MP_ROM_PTR(&machine_sdcard_type) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_spi_type) },
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_pwm_type) },

{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) },
@@ -6,5 +6,6 @@ extern const mp_obj_type_t machine_timer_type;
extern const mp_obj_type_t machine_sdcard_type;
extern const mp_obj_type_t machine_i2c_type;
extern const mp_obj_type_t machine_spi_type;
extern const mp_obj_type_t machine_pwm_type;

#endif // MICROPY_INCLUDED_RPI_MODMACHINE_H
@@ -7,6 +7,7 @@
#include "bcm283x_gpio.h"
#include "bcm283x_aux.h"
#include "bcm283x_mailbox.h"
#include "bcm283x_clockmgr.h"
#include "vc_property.h"
#include "rpi.h"

@@ -106,7 +107,11 @@ static void get_clock_value() {
}

void rpi_init() {
// read values of freq_cpu, freq_core
get_clock_value();
// any initialization
// set PWM clock to 960KHz (19.2MHz / 20) as a default value
clockmgr_config_ctl((clockmgr_t *) CM_PWM, CM_CTL_MASH_1STG | CM_CTL_ENAB | CM_CTL_SRC_OSC);
clockmgr_config_div((clockmgr_t *) CM_PWM, 20, 0);
// any additional initialization
}

0 comments on commit 9c545dc

Please sign in to comment.
You can’t perform that action at this time.