all: Remove the "STATIC" macro and just use "static" instead.

The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2024-02-27 15:32:29 +11:00
committed by Damien George
parent b3f2f18f92
commit decf8e6a8b
482 changed files with 6287 additions and 6293 deletions

View File

@@ -32,7 +32,7 @@
#include "led.h"
#include "usrsw.h"
STATIC void flash_error(int n) {
static void flash_error(int n) {
for (int i = 0; i < n; i++) {
led_state(RA_LED1, 1);
mp_hal_delay_ms(250);
@@ -42,7 +42,7 @@ STATIC void flash_error(int n) {
}
#if !MICROPY_HW_USES_BOOTLOADER
STATIC uint update_reset_mode(uint reset_mode) {
static uint update_reset_mode(uint reset_mode) {
#if MICROPY_HW_HAS_SWITCH
bool press_status;

View File

@@ -91,8 +91,8 @@ typedef struct {
mp_int_t irq_no;
} extint_obj_t;
STATIC uint8_t pyb_extint_mode[EXTI_NUM_VECTORS];
STATIC bool pyb_extint_hard_irq[EXTI_NUM_VECTORS];
static uint8_t pyb_extint_mode[EXTI_NUM_VECTORS];
static bool pyb_extint_hard_irq[EXTI_NUM_VECTORS];
// The callback arg is a small-int or a ROM Pin object, so no need to scan by GC
mp_obj_t pyb_extint_callback_arg[EXTI_NUM_VECTORS];
@@ -270,7 +270,7 @@ void extint_trigger_mode(uint line, uint32_t mode) {
/// \method irq_no()
/// Return the irq_no number that the pin is mapped to.
STATIC mp_obj_t extint_obj_irq_no(mp_obj_t self_in) {
static mp_obj_t extint_obj_irq_no(mp_obj_t self_in) {
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
uint8_t irq_no;
bool find = ra_icu_find_irq_no(self->pin_idx, &irq_no);
@@ -280,45 +280,45 @@ STATIC mp_obj_t extint_obj_irq_no(mp_obj_t self_in) {
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_irq_no_obj, extint_obj_irq_no);
static MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_irq_no_obj, extint_obj_irq_no);
/// \method enable()
/// Enable a disabled interrupt.
STATIC mp_obj_t extint_obj_enable(mp_obj_t self_in) {
static mp_obj_t extint_obj_enable(mp_obj_t self_in) {
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
ra_icu_enable_pin(self->pin_idx);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_enable_obj, extint_obj_enable);
static MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_enable_obj, extint_obj_enable);
/// \method disable()
/// Disable the interrupt associated with the ExtInt object.
/// This could be useful for debouncing.
STATIC mp_obj_t extint_obj_disable(mp_obj_t self_in) {
static mp_obj_t extint_obj_disable(mp_obj_t self_in) {
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
ra_icu_disable_pin(self->pin_idx);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_disable_obj, extint_obj_disable);
static MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_disable_obj, extint_obj_disable);
/// \method swint()
/// Trigger the callback from software.
STATIC mp_obj_t extint_obj_swint(mp_obj_t self_in) {
static mp_obj_t extint_obj_swint(mp_obj_t self_in) {
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
ra_icu_swint(self->irq_no);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
static MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
// TODO document as a staticmethod
/// \classmethod regs()
/// Dump the values of the EXTI registers.
STATIC mp_obj_t extint_regs(void) {
static mp_obj_t extint_regs(void) {
printf("Not Implemented\n");
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(extint_regs_fun_obj, extint_regs);
STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(extint_regs_obj, MP_ROM_PTR(&extint_regs_fun_obj));
static MP_DEFINE_CONST_FUN_OBJ_0(extint_regs_fun_obj, extint_regs);
static MP_DEFINE_CONST_STATICMETHOD_OBJ(extint_regs_obj, MP_ROM_PTR(&extint_regs_fun_obj));
/// \classmethod \constructor(pin, mode, pull, callback)
/// Create an ExtInt object:
@@ -335,7 +335,7 @@ STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(extint_regs_obj, MP_ROM_PTR(&extint_regs
/// - `callback` is the function to call when the interrupt triggers. The
/// callback function must accept exactly 1 argument, which is the irq_no that
/// triggered the interrupt.
STATIC const mp_arg_t pyb_extint_make_new_args[] = {
static const mp_arg_t pyb_extint_make_new_args[] = {
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_pull, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
@@ -343,7 +343,7 @@ STATIC const mp_arg_t pyb_extint_make_new_args[] = {
};
#define PYB_EXTINT_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(pyb_extint_make_new_args)
STATIC mp_obj_t extint_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t extint_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// type_in == extint_obj_type
// parse args
@@ -358,12 +358,12 @@ STATIC mp_obj_t extint_make_new(const mp_obj_type_t *type, size_t n_args, size_t
return MP_OBJ_FROM_PTR(self);
}
STATIC void extint_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void extint_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
extint_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<ExtInt irq_no=%u>", self->irq_no);
}
STATIC const mp_rom_map_elem_t extint_locals_dict_table[] = {
static const mp_rom_map_elem_t extint_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_irq_no), MP_ROM_PTR(&extint_obj_irq_no_obj) },
{ MP_ROM_QSTR(MP_QSTR_line), MP_ROM_PTR(&extint_obj_irq_no_obj) },
{ MP_ROM_QSTR(MP_QSTR_enable), MP_ROM_PTR(&extint_obj_enable_obj) },
@@ -372,7 +372,7 @@ STATIC const mp_rom_map_elem_t extint_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_regs), MP_ROM_PTR(&extint_regs_obj) },
};
STATIC MP_DEFINE_CONST_DICT(extint_locals_dict, extint_locals_dict_table);
static MP_DEFINE_CONST_DICT(extint_locals_dict, extint_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
extint_type,

View File

@@ -66,7 +66,7 @@ extern uint8_t _micropy_hw_internal_flash_storage_end;
#error "no internal flash storage support for this MCU"
#endif
STATIC byte flash_cache_mem[FLASH_SECTOR_SIZE_MAX] __attribute__((aligned(16)));
static byte flash_cache_mem[FLASH_SECTOR_SIZE_MAX] __attribute__((aligned(16)));
#define CACHE_MEM_START_ADDR (&flash_cache_mem[0])
#if !defined(FLASH_MEM_SEG2_START_ADDR)

View File

@@ -36,7 +36,7 @@ uint32_t irq_stats[IRQ_STATS_MAX] = {0};
// disable_irq()
// Disable interrupt requests.
// Returns the previous IRQ state which can be passed to enable_irq.
STATIC mp_obj_t machine_disable_irq(void) {
static mp_obj_t machine_disable_irq(void) {
return mp_obj_new_bool(disable_irq() == IRQ_STATE_ENABLED);
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
@@ -44,7 +44,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
// enable_irq(state=True)
// Enable interrupt requests, based on the argument, which is usually the
// value returned by a previous call to disable_irq.
STATIC mp_obj_t machine_enable_irq(uint n_args, const mp_obj_t *arg) {
static mp_obj_t machine_enable_irq(uint n_args, const mp_obj_t *arg) {
enable_irq((n_args == 0 || mp_obj_is_true(arg[0])) ? IRQ_STATE_ENABLED : IRQ_STATE_DISABLED);
return mp_const_none;
}
@@ -52,7 +52,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_enable_irq_obj, 0, 1, machine_enable
#if IRQ_ENABLE_STATS
// return a memoryview of the irq statistics array
STATIC mp_obj_t pyb_irq_stats(void) {
static mp_obj_t pyb_irq_stats(void) {
return mp_obj_new_memoryview(0x80 | 'I', MP_ARRAY_SIZE(irq_stats), &irq_stats[0]);
}
MP_DEFINE_CONST_FUN_OBJ_0(pyb_irq_stats_obj, pyb_irq_stats);

View File

@@ -51,7 +51,7 @@ typedef struct _ra_led_obj_t {
const machine_pin_obj_t *led_pin;
} ra_led_obj_t;
STATIC const ra_led_obj_t ra_led_obj[] = {
static const ra_led_obj_t ra_led_obj[] = {
{{&ra_led_type}, 1, MICROPY_HW_LED1},
#if defined(MICROPY_HW_LED2)
{{&ra_led_type}, 2, MICROPY_HW_LED2},
@@ -118,7 +118,7 @@ void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
/// Create an LED object associated with the given LED:
///
/// - `id` is the LED number, 1-4.
STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 1, 1, false);
@@ -158,17 +158,17 @@ mp_obj_t led_obj_toggle(mp_obj_t self_in) {
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(led_obj_on_obj, led_obj_on);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(led_obj_toggle_obj, led_obj_toggle);
static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_on_obj, led_obj_on);
static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off);
static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_toggle_obj, led_obj_toggle);
STATIC const mp_rom_map_elem_t led_locals_dict_table[] = {
static const mp_rom_map_elem_t led_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&led_obj_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&led_obj_off_obj) },
{ MP_ROM_QSTR(MP_QSTR_toggle), MP_ROM_PTR(&led_obj_toggle_obj) },
};
STATIC MP_DEFINE_CONST_DICT(led_locals_dict, led_locals_dict_table);
static MP_DEFINE_CONST_DICT(led_locals_dict, led_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
ra_led_type,

View File

@@ -70,14 +70,14 @@ typedef struct _machine_adc_obj_t {
uint32_t sample_time;
} machine_adc_obj_t;
STATIC void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
uint8_t resolution = (uint8_t)ra_adc_get_resolution();
mp_printf(print, "<ADC%u channel=%u>", resolution, self->channel);
}
// ADC(id)
STATIC mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
// Check number of arguments
mp_arg_check_num(n_args, n_kw, 1, 1, false);
@@ -110,11 +110,11 @@ STATIC mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args
return MP_OBJ_FROM_PTR(o);
}
STATIC mp_int_t mp_machine_adc_read(machine_adc_obj_t *self) {
static mp_int_t mp_machine_adc_read(machine_adc_obj_t *self) {
return ra_adc_read((uint32_t)(self->pin));
}
STATIC mp_int_t mp_machine_adc_read_u16(machine_adc_obj_t *self) {
static mp_int_t mp_machine_adc_read_u16(machine_adc_obj_t *self) {
mp_uint_t raw = (mp_uint_t)ra_adc_read((uint32_t)(self->pin));
mp_int_t bits = (mp_int_t)ra_adc_get_resolution();
// Scale raw reading to 16 bit value using a Taylor expansion (for 8 <= bits <= 16)

View File

@@ -43,7 +43,7 @@ typedef struct _machine_dac_obj_t {
mp_hal_pin_obj_t dac;
} machine_dac_obj_t;
STATIC machine_dac_obj_t machine_dac_obj[] = {
static machine_dac_obj_t machine_dac_obj[] = {
#if defined(MICROPY_HW_DAC0)
{{&machine_dac_type}, 0, 0, 0, MICROPY_HW_DAC0},
#endif
@@ -52,12 +52,12 @@ STATIC machine_dac_obj_t machine_dac_obj[] = {
#endif
};
STATIC void machine_dac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_dac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in); // const char *qstr_str(qstr q);
mp_printf(print, "DAC(DA%d [#%d], active=%u, out=%u mV)", self->ch, self->dac->pin, self->active, self->mv);
}
STATIC mp_obj_t machine_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t machine_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_hal_pin_obj_t pin_id = MP_OBJ_NULL;
machine_dac_obj_t *self = MP_OBJ_NULL;
@@ -99,7 +99,7 @@ STATIC mp_obj_t machine_dac_make_new(const mp_obj_type_t *type, size_t n_args, s
}
// DAC.deinit()
STATIC mp_obj_t machine_dac_deinit(mp_obj_t self_in) {
static mp_obj_t machine_dac_deinit(mp_obj_t self_in) {
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in);
ra_dac_deinit(self->dac->pin, self->ch);
@@ -108,10 +108,10 @@ STATIC mp_obj_t machine_dac_deinit(mp_obj_t self_in) {
self->mv = 0;
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_deinit_obj, machine_dac_deinit);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_deinit_obj, machine_dac_deinit);
// DAC.write(value)
STATIC mp_obj_t machine_dac_write(mp_obj_t self_in, mp_obj_t data) { // mp_obj_t value_in
static mp_obj_t machine_dac_write(mp_obj_t self_in, mp_obj_t data) { // mp_obj_t value_in
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t value = mp_obj_get_int(data);
@@ -124,18 +124,18 @@ STATIC mp_obj_t machine_dac_write(mp_obj_t self_in, mp_obj_t data) { // mp_obj_t
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_dac_write_obj, machine_dac_write);
static MP_DEFINE_CONST_FUN_OBJ_2(machine_dac_write_obj, machine_dac_write);
// DAC.read()
STATIC mp_obj_t machine_dac_read(mp_obj_t self_in) {
static mp_obj_t machine_dac_read(mp_obj_t self_in) {
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_NEW_SMALL_INT(ra_dac_read(self->ch));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_read_obj, machine_dac_read);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_read_obj, machine_dac_read);
// DAC.write_mv(Vout)
STATIC mp_obj_t machine_dac_write_mv(mp_obj_t self_in, mp_obj_t data) { // mp_obj_t self_in, mp_obj_t value_in
static mp_obj_t machine_dac_write_mv(mp_obj_t self_in, mp_obj_t data) { // mp_obj_t self_in, mp_obj_t value_in
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t Vout = mp_obj_get_int(data);
@@ -149,19 +149,19 @@ STATIC mp_obj_t machine_dac_write_mv(mp_obj_t self_in, mp_obj_t data) { // mp_o
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_dac_write_mv_obj, machine_dac_write_mv);
static MP_DEFINE_CONST_FUN_OBJ_2(machine_dac_write_mv_obj, machine_dac_write_mv);
// DAC.read_mv()
STATIC mp_obj_t machine_dac_read_mv(mp_obj_t self_in) {
static mp_obj_t machine_dac_read_mv(mp_obj_t self_in) {
machine_dac_obj_t *self = MP_OBJ_TO_PTR(self_in);
return MP_OBJ_NEW_SMALL_INT(self->mv);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_read_mv_obj, machine_dac_read_mv);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_dac_read_mv_obj, machine_dac_read_mv);
// MP_DEFINE_CONST_FUN_OBJ_2(mp_machine_dac_write_obj, mp_machine_dac_write);
STATIC const mp_rom_map_elem_t machine_dac_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_dac_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_dac_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&machine_dac_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&machine_dac_write_obj) },
@@ -169,7 +169,7 @@ STATIC const mp_rom_map_elem_t machine_dac_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_write_mv), MP_ROM_PTR(&machine_dac_write_mv_obj) }
};
STATIC MP_DEFINE_CONST_DICT(machine_dac_locals_dict, machine_dac_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_dac_locals_dict, machine_dac_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
machine_dac_type,

View File

@@ -49,7 +49,7 @@ typedef struct _machine_i2c_obj_t {
uint32_t freq;
} machine_i2c_obj_t;
STATIC machine_i2c_obj_t machine_i2c_obj[] = {
static machine_i2c_obj_t machine_i2c_obj[] = {
#if defined(MICROPY_HW_I2C0_SCL)
{{&machine_i2c_type}, R_IIC0, 0, MICROPY_HW_I2C0_SCL, MICROPY_HW_I2C0_SDA, 0},
#endif
@@ -61,10 +61,10 @@ STATIC machine_i2c_obj_t machine_i2c_obj[] = {
#endif
};
STATIC int i2c_read(machine_i2c_obj_t *self, uint16_t addr, uint8_t *dest, size_t len, bool stop);
STATIC int i2c_write(machine_i2c_obj_t *self, uint16_t addr, const uint8_t *src, size_t len, bool stop);
static int i2c_read(machine_i2c_obj_t *self, uint16_t addr, uint8_t *dest, size_t len, bool stop);
static int i2c_write(machine_i2c_obj_t *self, uint16_t addr, const uint8_t *src, size_t len, bool stop);
STATIC int i2c_read(machine_i2c_obj_t *self, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
static int i2c_read(machine_i2c_obj_t *self, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
bool flag;
xaction_t action;
xaction_unit_t unit;
@@ -74,7 +74,7 @@ STATIC int i2c_read(machine_i2c_obj_t *self, uint16_t addr, uint8_t *dest, size_
return flag? len:-1;
}
STATIC int i2c_write(machine_i2c_obj_t *self, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
static int i2c_write(machine_i2c_obj_t *self, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
bool flag;
xaction_t action;
xaction_unit_t unit;
@@ -86,18 +86,18 @@ STATIC int i2c_write(machine_i2c_obj_t *self, uint16_t addr, const uint8_t *src,
// MicroPython bindings for machine API
STATIC void machine_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "I2C(%u, freq=%u, scl=%q, sda=%q)",
self->i2c_id, self->freq, self->scl->name, self->sda->name);
}
STATIC void machine_i2c_init(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static void machine_i2c_init(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_raise_NotImplementedError(MP_ERROR_TEXT("init is not supported."));
return;
}
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
// parse args
enum { ARG_id, ARG_freq, ARG_scl, ARG_sda };
static const mp_arg_t allowed_args[] = {
@@ -136,7 +136,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
return MP_OBJ_FROM_PTR(self);
}
STATIC int machine_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, size_t len, uint8_t *buf, unsigned int flags) {
static int machine_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, size_t len, uint8_t *buf, unsigned int flags) {
machine_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
int ret;
bool stop;
@@ -149,7 +149,7 @@ STATIC int machine_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, si
return ret;
}
STATIC const mp_machine_i2c_p_t machine_i2c_p = {
static const mp_machine_i2c_p_t machine_i2c_p = {
.init = machine_i2c_init,
.transfer = mp_machine_i2c_transfer_adaptor,
.transfer_single = machine_i2c_transfer_single,

View File

@@ -71,7 +71,7 @@ const machine_pin_obj_t *machine_pin_find(mp_obj_t user_obj) {
}
/// Return a string describing the pin object.
STATIC void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
// pin name
@@ -142,7 +142,7 @@ STATIC void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_prin
}
// pin.init(mode=-1, pull=-1, *, value=None, drive=0, alt=-1)
STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_mode, ARG_pull, ARG_value, ARG_drive, ARG_alt };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
@@ -222,7 +222,7 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
}
// fast method for getting/setting pin value
STATIC mp_obj_t machine_pin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t machine_pin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (n_args == 0) {
@@ -236,35 +236,35 @@ STATIC mp_obj_t machine_pin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, c
}
// pin.init(mode, pull)
STATIC mp_obj_t machine_pin_obj_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
static mp_obj_t machine_pin_obj_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return machine_pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args);
}
MP_DEFINE_CONST_FUN_OBJ_KW(machine_pin_init_obj, 1, machine_pin_obj_init);
// pin.value([value])
STATIC mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args) {
static mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args) {
return machine_pin_call(args[0], n_args - 1, 0, args + 1);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_pin_value_obj, 1, 2, machine_pin_value);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_pin_value_obj, 1, 2, machine_pin_value);
// pin.low()
STATIC mp_obj_t machine_pin_low(mp_obj_t self_in) {
static mp_obj_t machine_pin_low(mp_obj_t self_in) {
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_hal_pin_write(self, false);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_low_obj, machine_pin_low);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_low_obj, machine_pin_low);
// pin.high()
STATIC mp_obj_t machine_pin_high(mp_obj_t self_in) {
static mp_obj_t machine_pin_high(mp_obj_t self_in) {
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_hal_pin_write(self, true);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_high_obj, machine_pin_high);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_high_obj, machine_pin_high);
// pin.irq(handler=None, trigger=IRQ_FALLING|IRQ_RISING, hard=False)
STATIC mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_handler, ARG_trigger, ARG_hard };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_handler, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
@@ -288,9 +288,9 @@ STATIC mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
// TODO should return an IRQ object
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_pin_irq_obj, 1, machine_pin_irq);
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_pin_irq_obj, 1, machine_pin_irq);
STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
// instance methods
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_pin_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&machine_pin_value_obj) },
@@ -323,9 +323,9 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_IRQ_LOW_LEVEL), MP_ROM_INT(MP_HAL_PIN_TRIGGER_LOWLEVEL) },
{ MP_ROM_QSTR(MP_QSTR_IRQ_HIGH_LEVEL), MP_ROM_INT(MP_HAL_PIN_TRIGGER_HIGHLEVEL) },
};
STATIC MP_DEFINE_CONST_DICT(machine_pin_locals_dict, machine_pin_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_pin_locals_dict, machine_pin_locals_dict_table);
STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
static mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -341,7 +341,7 @@ STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
return -1;
}
STATIC const mp_pin_p_t machine_pin_pin_p = {
static const mp_pin_p_t machine_pin_pin_p = {
.ioctl = machine_pin_ioctl,
};

View File

@@ -44,7 +44,7 @@ typedef struct _machine_pwm_obj_t {
mp_hal_pin_obj_t pwm;
} machine_pwm_obj_t;
STATIC machine_pwm_obj_t machine_pwm_obj[] = {
static machine_pwm_obj_t machine_pwm_obj[] = {
#if defined(MICROPY_HW_PWM_0A)
{{&machine_pwm_type}, R_GPT0, 0, 0, 'A', 0, 0ul, MICROPY_HW_PWM_0A},
#endif
@@ -134,12 +134,12 @@ STATIC machine_pwm_obj_t machine_pwm_obj[] = {
/******************************************************************************/
// MicroPython bindings for PWM
STATIC void mp_machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void mp_machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_pwm_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "PWM(GTIOC %d%c[#%d], active=%u, freq=%u, duty=%u)", self->ch, self->id, self->pwm->pin, self->active, self->freq, self->duty);
}
STATIC void mp_machine_pwm_init_helper(machine_pwm_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static void mp_machine_pwm_init_helper(machine_pwm_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
uint32_t D = 0ul;
enum { ARG_freq, ARG_duty };
@@ -178,7 +178,7 @@ STATIC void mp_machine_pwm_init_helper(machine_pwm_obj_t *self, size_t n_args, c
}
}
STATIC mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_hal_pin_obj_t pin_id = MP_OBJ_NULL;
machine_pwm_obj_t *self = MP_OBJ_NULL;
@@ -223,7 +223,7 @@ STATIC mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args
return MP_OBJ_FROM_PTR(self);
}
STATIC void mp_machine_pwm_deinit(machine_pwm_obj_t *self) {
static void mp_machine_pwm_deinit(machine_pwm_obj_t *self) {
ra_gpt_timer_deinit(self->pwm->pin, self->ch, self->id);
self->active = 0;
self->ch = 0;
@@ -232,11 +232,11 @@ STATIC void mp_machine_pwm_deinit(machine_pwm_obj_t *self) {
self->freq = 0;
}
STATIC mp_obj_t mp_machine_pwm_freq_get(machine_pwm_obj_t *self) {
static mp_obj_t mp_machine_pwm_freq_get(machine_pwm_obj_t *self) {
return MP_OBJ_NEW_SMALL_INT((uint32_t)ra_gpt_timer_get_freq(self->ch));
}
STATIC void mp_machine_pwm_freq_set(machine_pwm_obj_t *self, mp_int_t freq) {
static void mp_machine_pwm_freq_set(machine_pwm_obj_t *self, mp_int_t freq) {
if (freq) {
ra_gpt_timer_set_freq(self->ch, (float)freq);
self->freq = (uint32_t)ra_gpt_timer_get_freq(self->ch);
@@ -255,13 +255,13 @@ STATIC void mp_machine_pwm_freq_set(machine_pwm_obj_t *self, mp_int_t freq) {
}
}
STATIC mp_obj_t mp_machine_pwm_duty_get(machine_pwm_obj_t *self) {
static mp_obj_t mp_machine_pwm_duty_get(machine_pwm_obj_t *self) {
// give the result in %
uint64_t Dc = ra_gpt_timer_get_duty(self->ch, self->id) * 100;
return MP_OBJ_NEW_SMALL_INT(Dc / ra_gpt_timer_get_period(self->ch));
}
STATIC void mp_machine_pwm_duty_set(machine_pwm_obj_t *self, mp_int_t duty) {
static void mp_machine_pwm_duty_set(machine_pwm_obj_t *self, mp_int_t duty) {
// assume duty is in %
if (duty < 0 || duty > 100) {
mp_raise_ValueError(MP_ERROR_TEXT("duty should be 0-100"));
@@ -286,13 +286,13 @@ STATIC void mp_machine_pwm_duty_set(machine_pwm_obj_t *self, mp_int_t duty) {
}
}
STATIC mp_obj_t mp_machine_pwm_duty_get_u16(machine_pwm_obj_t *self) {
static mp_obj_t mp_machine_pwm_duty_get_u16(machine_pwm_obj_t *self) {
// give the result in ratio (u16 / 65535)
uint64_t Dc = ra_gpt_timer_get_duty(self->ch, self->id) * 65535;
return MP_OBJ_NEW_SMALL_INT(Dc / ra_gpt_timer_get_period(self->ch));
}
STATIC void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_int_t duty_u16) {
static void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_int_t duty_u16) {
// assume duty is a ratio (u16 / 65535)
if (duty_u16 < 0 || duty_u16 > 65535) {
mp_raise_ValueError(MP_ERROR_TEXT("duty should be 0-65535"));
@@ -317,14 +317,14 @@ STATIC void mp_machine_pwm_duty_set_u16(machine_pwm_obj_t *self, mp_int_t duty_u
}
}
STATIC mp_obj_t mp_machine_pwm_duty_get_ns(machine_pwm_obj_t *self) {
static mp_obj_t mp_machine_pwm_duty_get_ns(machine_pwm_obj_t *self) {
// give the result in ns
float ns = ra_gpt_timer_tick_time(self->ch);
ns *= (float)ra_gpt_timer_get_duty(self->ch, self->id);
return MP_OBJ_NEW_SMALL_INT(ns);
}
STATIC void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_int_t duty_ns) {
static void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_int_t duty_ns) {
// assume duty is ns
uint32_t ns_min = (uint32_t)ra_gpt_timer_tick_time(self->ch);
uint32_t ns_max = ns_min * ra_gpt_timer_get_period(self->ch);

View File

@@ -62,11 +62,11 @@
// it's a bit of a hack at the moment
static mp_uint_t rtc_info;
STATIC uint32_t rtc_startup_tick;
STATIC bool rtc_need_init_finalise = false;
STATIC uint32_t rtc_wakeup_param;
static uint32_t rtc_startup_tick;
static bool rtc_need_init_finalise = false;
static uint32_t rtc_wakeup_param;
STATIC void rtc_calendar_config(void) {
static void rtc_calendar_config(void) {
ra_rtc_t tm;
tm.year = RTC_INIT_YEAR - 2000;
tm.month = RTC_INIT_MONTH;
@@ -155,11 +155,11 @@ typedef struct _machine_rtc_obj_t {
mp_obj_base_t base;
} machine_rtc_obj_t;
STATIC const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
static const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
/// \classmethod \constructor()
/// Create an RTC object.
STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 0, 0, false);
@@ -333,14 +333,14 @@ mp_obj_t machine_rtc_calibration(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_calibration_obj, 1, 2, machine_rtc_calibration);
STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
static const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_rtc_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&machine_rtc_info_obj) },
{ MP_ROM_QSTR(MP_QSTR_datetime), MP_ROM_PTR(&machine_rtc_datetime_obj) },
{ MP_ROM_QSTR(MP_QSTR_wakeup), MP_ROM_PTR(&machine_rtc_wakeup_obj) },
{ MP_ROM_QSTR(MP_QSTR_calibration), MP_ROM_PTR(&machine_rtc_calibration_obj) },
};
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
static MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
machine_rtc_type,

View File

@@ -47,7 +47,7 @@ typedef struct _machine_sdcard_obj_t {
uint32_t block_count;
} machine_sdcard_obj_t;
STATIC machine_sdcard_obj_t machine_sdcard_objs[] = {
static machine_sdcard_obj_t machine_sdcard_objs[] = {
{{&machine_sdcard_type}, {false, false, false}, 0, 0}
};
@@ -78,7 +78,7 @@ void sdhi_ISR(sdmmc_callback_args_t *p_args) {
}
}
STATIC mp_obj_t machine_sdcard_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t machine_sdcard_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
fsp_err_t err = FSP_SUCCESS;
machine_sdcard_obj_t *self = mp_const_none;
@@ -117,9 +117,9 @@ STATIC mp_obj_t machine_sdcard_init(size_t n_args, const mp_obj_t *pos_args, mp_
return MP_OBJ_FROM_PTR(self);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_sdcard_init_obj, 1, machine_sdcard_init);
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_sdcard_init_obj, 1, machine_sdcard_init);
STATIC mp_obj_t sdcard_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static mp_obj_t sdcard_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
mp_map_t kw_args;
mp_arg_check_num(n_args, n_kw, 0, 0, true);
@@ -128,17 +128,17 @@ STATIC mp_obj_t sdcard_obj_make_new(const mp_obj_type_t *type, size_t n_args, si
}
// deinit()
STATIC mp_obj_t machine_sdcard_deinit(mp_obj_t self_in) {
static mp_obj_t machine_sdcard_deinit(mp_obj_t self_in) {
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
R_SDHI_Close(&g_sdmmc0_ctrl);
self->block_count = self->block_len = 0;
self->status.card_inserted = self->status.initialized = self->status.transfer_in_progress = false;
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_deinit_obj, machine_sdcard_deinit);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_deinit_obj, machine_sdcard_deinit);
// present()
STATIC mp_obj_t machine_sdcard_present(mp_obj_t self_in) {
static mp_obj_t machine_sdcard_present(mp_obj_t self_in) {
fsp_err_t err = FSP_SUCCESS;
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
if ((err = R_SDHI_StatusGet(&g_sdmmc0_ctrl, &self->status)) == FSP_SUCCESS) {
@@ -147,9 +147,9 @@ STATIC mp_obj_t machine_sdcard_present(mp_obj_t self_in) {
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("can't get SDHI Status, %d"), err);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_present_obj, machine_sdcard_present);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_present_obj, machine_sdcard_present);
STATIC mp_obj_t machine_sdcard_info(mp_obj_t self_in) {
static mp_obj_t machine_sdcard_info(mp_obj_t self_in) {
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (self->status.card_inserted && self->status.initialized) {
@@ -165,10 +165,10 @@ STATIC mp_obj_t machine_sdcard_info(mp_obj_t self_in) {
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_info_obj, machine_sdcard_info);
static MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_info_obj, machine_sdcard_info);
// readblocks(block_num, buf)
STATIC mp_obj_t machine_sdcard_readblocks(mp_obj_t self_in, mp_obj_t block_num, mp_obj_t buf) {
static mp_obj_t machine_sdcard_readblocks(mp_obj_t self_in, mp_obj_t block_num, mp_obj_t buf) {
mp_buffer_info_t bufinfo;
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE);
@@ -188,10 +188,10 @@ STATIC mp_obj_t machine_sdcard_readblocks(mp_obj_t self_in, mp_obj_t block_num,
return MP_OBJ_NEW_SMALL_INT(-MP_EIO);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_readblocks_obj, machine_sdcard_readblocks);
static MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_readblocks_obj, machine_sdcard_readblocks);
// writeblocks(block_num, buf)
STATIC mp_obj_t machine_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t block_num, mp_obj_t buf) {
static mp_obj_t machine_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t block_num, mp_obj_t buf) {
mp_buffer_info_t bufinfo;
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE);
@@ -211,10 +211,10 @@ STATIC mp_obj_t machine_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t block_num,
return MP_OBJ_NEW_SMALL_INT(-MP_EIO);
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_writeblocks_obj, machine_sdcard_writeblocks);
static MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_writeblocks_obj, machine_sdcard_writeblocks);
// ioctl(op, arg)
STATIC mp_obj_t machine_sdcard_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
static mp_obj_t machine_sdcard_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
machine_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t cmd = mp_obj_get_int(cmd_in);
@@ -313,9 +313,9 @@ STATIC mp_obj_t machine_sdcard_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t
break;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_ioctl_obj, machine_sdcard_ioctl);
static MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_ioctl_obj, machine_sdcard_ioctl);
STATIC const mp_rom_map_elem_t sdcard_locals_dict_table[] = {
static const mp_rom_map_elem_t sdcard_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_sdcard_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_sdcard_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_present), MP_ROM_PTR(&machine_sdcard_present_obj) },
@@ -325,7 +325,7 @@ STATIC const mp_rom_map_elem_t sdcard_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&machine_sdcard_writeblocks_obj) },
{ MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&machine_sdcard_ioctl_obj) },
};
STATIC MP_DEFINE_CONST_DICT(sdcard_locals_dict, sdcard_locals_dict_table);
static MP_DEFINE_CONST_DICT(sdcard_locals_dict, sdcard_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
machine_sdcard_type,

View File

@@ -66,7 +66,7 @@ typedef struct _machine_hard_spi_obj_t {
/******************************************************************************/
// Implementation of hard SPI for machine module
STATIC machine_hard_spi_obj_t machine_hard_spi_obj[] = {
static machine_hard_spi_obj_t machine_hard_spi_obj[] = {
#if defined(MICROPY_HW_SPI0_RSPCK)
{
{&machine_spi_type}, 0,
@@ -85,7 +85,7 @@ STATIC machine_hard_spi_obj_t machine_hard_spi_obj[] = {
#endif
};
STATIC void spi_init(machine_hard_spi_obj_t *self) {
static void spi_init(machine_hard_spi_obj_t *self) {
const machine_pin_obj_t *pins[4] = { NULL, NULL, NULL, NULL };
if (0) {
@@ -126,7 +126,7 @@ STATIC void spi_init(machine_hard_spi_obj_t *self) {
ra_spi_init(self->spi_id, pins[3]->pin, pins[2]->pin, pins[1]->pin, pins[0]->pin, self->baudrate, self->bits, self->polarity, self->phase, self->firstbit);
}
STATIC void machine_hard_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void machine_hard_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_hard_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "SPI(%u, baudrate=%u, polarity=%u, phase=%u, bits=%u, firstbit=%u, sck=%q, mosi=%q, miso=%q)",
self->spi_id, self->baudrate, self->polarity, self->phase, self->bits,
@@ -233,7 +233,7 @@ mp_obj_t machine_hard_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz
return MP_OBJ_FROM_PTR(self);
}
STATIC void machine_hard_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static void machine_hard_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
machine_hard_spi_obj_t *self = (machine_hard_spi_obj_t *)self_in;
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
@@ -315,17 +315,17 @@ STATIC void machine_hard_spi_init(mp_obj_base_t *self_in, size_t n_args, const m
spi_init(self);
}
STATIC void machine_hard_spi_deinit(mp_obj_base_t *self_in) {
static void machine_hard_spi_deinit(mp_obj_base_t *self_in) {
machine_hard_spi_obj_t *self = (machine_hard_spi_obj_t *)self_in;
spi_deinit(self->spi_id);
}
STATIC void machine_hard_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
static void machine_hard_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
machine_hard_spi_obj_t *self = (machine_hard_spi_obj_t *)self_in;
spi_transfer(self->spi_id, self->bits, len, src, dest, SPI_TRANSFER_TIMEOUT(len));
}
STATIC const mp_machine_spi_p_t machine_hard_spi_p = {
static const mp_machine_spi_p_t machine_hard_spi_p = {
.init = machine_hard_spi_init,
.deinit = machine_hard_spi_deinit,
.transfer = machine_hard_spi_transfer,

View File

@@ -42,9 +42,9 @@
{ MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_INT(UART_HWCONTROL_RTS) }, \
{ MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_INT(UART_HWCONTROL_CTS) }, \
STATIC const char *_parity_name[] = {"None", "ODD", "EVEN"};
static const char *_parity_name[] = {"None", "ODD", "EVEN"};
STATIC void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (!self->is_enabled) {
mp_printf(print, "UART(%u)", self->uart_id);
@@ -82,7 +82,7 @@ STATIC void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_
/// - `timeout_char` is the timeout in milliseconds to wait between characters.
/// - `flow` is RTS | CTS where RTS == 256, CTS == 512
/// - `read_buf_len` is the character length of the read buffer (0 to disable).
STATIC void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_baudrate, MP_ARG_INT | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_bits, MP_ARG_INT, {.u_int = 8} },
@@ -221,7 +221,7 @@ STATIC void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
/// - `UART(6)` is on `YA`: `(TX, RX) = (Y1, Y2) = (PC6, PC7)`
/// - `UART(3)` is on `YB`: `(TX, RX) = (Y9, Y10) = (PB10, PB11)`
/// - `UART(2)` is on: `(TX, RX) = (X3, X4) = (PA2, PA3)`
STATIC mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
@@ -306,27 +306,27 @@ STATIC mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_arg
}
// Turn off the UART bus.
STATIC void mp_machine_uart_deinit(machine_uart_obj_t *self) {
static void mp_machine_uart_deinit(machine_uart_obj_t *self) {
uart_deinit(self);
}
// Return number of characters waiting.
STATIC mp_int_t mp_machine_uart_any(machine_uart_obj_t *self) {
static mp_int_t mp_machine_uart_any(machine_uart_obj_t *self) {
return uart_rx_any(self);
}
// Return `true` if all characters have been sent.
STATIC bool mp_machine_uart_txdone(machine_uart_obj_t *self) {
static bool mp_machine_uart_txdone(machine_uart_obj_t *self) {
return !uart_tx_busy(self);
}
// Send a break condition.
STATIC void mp_machine_uart_sendbreak(machine_uart_obj_t *self) {
static void mp_machine_uart_sendbreak(machine_uart_obj_t *self) {
ra_sci_tx_break((uint32_t)self->uart_id);
}
// Write a single character on the bus. `data` is an integer to write.
STATIC void mp_machine_uart_writechar(machine_uart_obj_t *self, uint16_t data) {
static void mp_machine_uart_writechar(machine_uart_obj_t *self, uint16_t data) {
int errcode;
if (uart_tx_wait(self, self->timeout)) {
uart_tx_data(self, &data, 1, &errcode);
@@ -341,7 +341,7 @@ STATIC void mp_machine_uart_writechar(machine_uart_obj_t *self, uint16_t data) {
// Receive a single character on the bus.
// Return value: The character read, as an integer. Returns -1 on timeout.
STATIC mp_int_t mp_machine_uart_readchar(machine_uart_obj_t *self) {
static mp_int_t mp_machine_uart_readchar(machine_uart_obj_t *self) {
if (uart_rx_wait(self, self->timeout)) {
return uart_rx_char(self);
} else {
@@ -350,7 +350,7 @@ STATIC mp_int_t mp_machine_uart_readchar(machine_uart_obj_t *self) {
}
}
STATIC mp_irq_obj_t *mp_machine_uart_irq(machine_uart_obj_t *self, bool any_args, mp_arg_val_t *args) {
static mp_irq_obj_t *mp_machine_uart_irq(machine_uart_obj_t *self, bool any_args, mp_arg_val_t *args) {
if (self->mp_irq_obj == NULL) {
self->mp_irq_trigger = 0;
self->mp_irq_obj = mp_irq_new(&uart_irq_methods, MP_OBJ_FROM_PTR(self));
@@ -381,7 +381,7 @@ STATIC mp_irq_obj_t *mp_machine_uart_irq(machine_uart_obj_t *self, bool any_args
return self->mp_irq_obj;
}
STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
static mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
byte *buf = buf_in;
@@ -423,7 +423,7 @@ STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
}
}
STATIC mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
static mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
const byte *buf = buf_in;
@@ -452,7 +452,7 @@ STATIC mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_
}
}
STATIC mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
static mp_uint_t mp_machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_uint_t ret;
if (request == MP_STREAM_POLL) {

View File

@@ -77,15 +77,15 @@
#define RA_EARLY_PRINT 1 /* for enabling mp_print in boardctrl. */
#if MICROPY_PY_THREAD
STATIC pyb_thread_t pyb_thread_main;
static pyb_thread_t pyb_thread_main;
#endif
#if defined(MICROPY_HW_UART_REPL)
#ifndef MICROPY_HW_UART_REPL_RXBUF
#define MICROPY_HW_UART_REPL_RXBUF (260)
#endif
STATIC machine_uart_obj_t machine_uart_repl_obj;
STATIC uint8_t machine_uart_repl_rxbuf[MICROPY_HW_UART_REPL_RXBUF];
static machine_uart_obj_t machine_uart_repl_obj;
static uint8_t machine_uart_repl_rxbuf[MICROPY_HW_UART_REPL_RXBUF];
#endif
void NORETURN __fatal_error(const char *msg) {
@@ -126,7 +126,7 @@ void MP_WEAK __assert_func(const char *file, int line, const char *func, const c
}
#endif
STATIC mp_obj_t pyb_main(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t pyb_main(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_opt, MP_ARG_INT, {.u_int = 0} }
};
@@ -147,7 +147,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pyb_main_obj, 1, pyb_main);
#if MICROPY_HW_FLASH_MOUNT_AT_BOOT
// avoid inlining to avoid stack usage within main()
MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
MP_NOINLINE static bool init_flash_fs(uint reset_mode) {
if (reset_mode == BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM) {
// Asked by user to reset filesystem
factory_reset_create_filesystem();

View File

@@ -79,7 +79,7 @@
{ MP_ROM_QSTR(MP_QSTR_DEEPSLEEP_RESET), MP_ROM_INT(PYB_RESET_DEEPSLEEP) }, \
{ MP_ROM_QSTR(MP_QSTR_SOFT_RESET), MP_ROM_INT(PYB_RESET_SOFT) }, \
STATIC uint32_t reset_cause;
static uint32_t reset_cause;
void get_unique_id(uint8_t *id) {
uint32_t *p = (uint32_t *)id;
@@ -100,7 +100,7 @@ void machine_deinit(void) {
// machine.info([dump_alloc_table])
// Print out lots of information about the board.
STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
static mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
// get and print unique id; 128 bits
{
uint8_t id[16];
@@ -177,14 +177,14 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_info_obj, 0, 1, machine_info);
// Returns a string of 16 bytes (128 bits), which is the unique ID for the MCU.
STATIC mp_obj_t mp_machine_unique_id(void) {
static mp_obj_t mp_machine_unique_id(void) {
uint8_t id[16];
get_unique_id((uint8_t *)&id);
return mp_obj_new_bytes(id, 16);
}
// Resets the pyboard in a manner similar to pushing the external RESET button.
NORETURN STATIC void mp_machine_reset(void) {
NORETURN static void mp_machine_reset(void) {
powerctrl_mcu_reset();
}
@@ -209,22 +209,22 @@ NORETURN void mp_machine_bootloader(size_t n_args, const mp_obj_t *args) {
}
// get or set the MCU frequencies
STATIC mp_obj_t mp_machine_get_freq(void) {
static mp_obj_t mp_machine_get_freq(void) {
return mp_obj_new_int(SystemCoreClock);
}
STATIC void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
mp_raise_NotImplementedError(MP_ERROR_TEXT("machine.freq set not supported yet"));
}
// idle()
// This executies a wfi machine instruction which reduces power consumption
// of the MCU until an interrupt occurs, at which point execution continues.
STATIC void mp_machine_idle(void) {
static void mp_machine_idle(void) {
__WFI();
}
STATIC void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
if (n_args != 0) {
mp_obj_t args2[2] = {MP_OBJ_NULL, args[0]};
machine_rtc_wakeup(2, args2);
@@ -232,7 +232,7 @@ STATIC void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
powerctrl_enter_stop_mode();
}
NORETURN STATIC void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
if (n_args != 0) {
mp_obj_t args2[2] = {MP_OBJ_NULL, args[0]};
machine_rtc_wakeup(2, args2);
@@ -240,6 +240,6 @@ NORETURN STATIC void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
powerctrl_enter_standby_mode();
}
STATIC mp_int_t mp_machine_reset_cause(void) {
static mp_int_t mp_machine_reset_cause(void) {
return reset_cause;
}

View File

@@ -46,7 +46,7 @@ void mp_os_dupterm_stream_detached_attached(mp_obj_t stream_detached, mp_obj_t s
}
#if MICROPY_PY_OS_URANDOM
STATIC mp_obj_t mp_os_urandom(mp_obj_t num) {
static mp_obj_t mp_os_urandom(mp_obj_t num) {
mp_int_t n = mp_obj_get_int(num);
vstr_t vstr;
vstr_init_len(&vstr, n);
@@ -55,5 +55,5 @@ STATIC mp_obj_t mp_os_urandom(mp_obj_t num) {
}
return mp_obj_new_bytes_from_vstr(&vstr);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom);
static MP_DEFINE_CONST_FUN_OBJ_1(mp_os_urandom_obj, mp_os_urandom);
#endif

View File

@@ -29,7 +29,7 @@
#include "rtc.h"
// Return the localtime as an 8-tuple.
STATIC mp_obj_t mp_time_localtime_get(void) {
static mp_obj_t mp_time_localtime_get(void) {
// get current date and time
rtc_init_finalise();
ra_rtc_t time;
@@ -48,7 +48,7 @@ STATIC mp_obj_t mp_time_localtime_get(void) {
}
// Returns the number of seconds, as an integer, since the Epoch.
STATIC mp_obj_t mp_time_time_get(void) {
static mp_obj_t mp_time_time_get(void) {
// get date and time
rtc_init_finalise();
ra_rtc_t time;

View File

@@ -42,10 +42,10 @@
uint8_t mp_bluetooth_hci_cmd_buf[4 + 256];
STATIC mp_sched_node_t mp_bluetooth_hci_sched_node;
STATIC soft_timer_entry_t mp_bluetooth_hci_soft_timer;
static mp_sched_node_t mp_bluetooth_hci_sched_node;
static soft_timer_entry_t mp_bluetooth_hci_soft_timer;
STATIC void mp_bluetooth_hci_soft_timer_callback(soft_timer_entry_t *self) {
static void mp_bluetooth_hci_soft_timer_callback(soft_timer_entry_t *self) {
mp_bluetooth_hci_poll_now();
}
@@ -58,7 +58,7 @@ void mp_bluetooth_hci_init(void) {
);
}
STATIC void mp_bluetooth_hci_start_polling(void) {
static void mp_bluetooth_hci_start_polling(void) {
mp_bluetooth_hci_poll_now();
}
@@ -67,7 +67,7 @@ void mp_bluetooth_hci_poll_in_ms(uint32_t ms) {
}
// For synchronous mode, we run all BLE stack code inside a scheduled task.
STATIC void run_events_scheduled_task(mp_sched_node_t *node) {
static void run_events_scheduled_task(mp_sched_node_t *node) {
// This will process all buffered HCI UART data, and run any callouts or events.
mp_bluetooth_hci_poll();
}

View File

@@ -47,7 +47,7 @@ void flash_cache_commit(void);
#define MICROPY_HW_STDIN_BUFFER_LEN 512
#endif
STATIC uint8_t stdin_ringbuf_array[MICROPY_HW_STDIN_BUFFER_LEN];
static uint8_t stdin_ringbuf_array[MICROPY_HW_STDIN_BUFFER_LEN];
ringbuf_t stdin_ringbuf = { stdin_ringbuf_array, sizeof(stdin_ringbuf_array) };
#endif

View File

@@ -34,7 +34,7 @@
#if MICROPY_PY_THREAD
// the mutex controls access to the linked list
STATIC mp_thread_mutex_t thread_mutex;
static mp_thread_mutex_t thread_mutex;
void mp_thread_init(void) {
mp_thread_mutex_init(&thread_mutex);

View File

@@ -88,7 +88,7 @@ void pyb_thread_deinit() {
enable_irq(irq_state);
}
STATIC void pyb_thread_terminate(void) {
static void pyb_thread_terminate(void) {
uint32_t irq_state = disable_irq();
pyb_thread_t *thread = pyb_thread_cur;
// take current thread off the run list

View File

@@ -50,7 +50,7 @@ extern void __fatal_error(const char *);
// More information about decoding the fault registers can be found here:
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0646a/Cihdjcfc.html
STATIC char *fmt_hex(uint32_t val, char *buf) {
static char *fmt_hex(uint32_t val, char *buf) {
const char *hexDig = "0123456789abcdef";
buf[0] = hexDig[(val >> 28) & 0x0f];
@@ -66,7 +66,7 @@ STATIC char *fmt_hex(uint32_t val, char *buf) {
return buf;
}
STATIC void print_reg(const char *label, uint32_t val) {
static void print_reg(const char *label, uint32_t val) {
char hexStr[9];
mp_hal_stdout_tx_str(label);
@@ -74,7 +74,7 @@ STATIC void print_reg(const char *label, uint32_t val) {
mp_hal_stdout_tx_str("\r\n");
}
STATIC void print_hex_hex(const char *label, uint32_t val1, uint32_t val2) {
static void print_hex_hex(const char *label, uint32_t val1, uint32_t val2) {
char hex_str[9];
mp_hal_stdout_tx_str(label);
mp_hal_stdout_tx_str(fmt_hex(val1, hex_str));

View File

@@ -249,7 +249,7 @@ const pyb_flash_obj_t pyb_flash_obj = {
0, // actual size handled in ioctl, MP_BLOCKDEV_IOCTL_BLOCK_COUNT case
};
STATIC void pyb_flash_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void pyb_flash_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_flash_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (self == &pyb_flash_obj) {
mp_printf(print, "Flash()");
@@ -258,7 +258,7 @@ STATIC void pyb_flash_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
}
}
STATIC mp_obj_t pyb_flash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
static mp_obj_t pyb_flash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
// Parse arguments
enum { ARG_start, ARG_len };
static const mp_arg_t allowed_args[] = {
@@ -297,7 +297,7 @@ STATIC mp_obj_t pyb_flash_make_new(const mp_obj_type_t *type, size_t n_args, siz
return MP_OBJ_FROM_PTR(self);
}
STATIC mp_obj_t pyb_flash_readblocks(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_flash_readblocks(size_t n_args, const mp_obj_t *args) {
pyb_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
uint32_t block_num = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo;
@@ -318,9 +318,9 @@ STATIC mp_obj_t pyb_flash_readblocks(size_t n_args, const mp_obj_t *args) {
#endif
return MP_OBJ_NEW_SMALL_INT(ret);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_flash_readblocks_obj, 3, 4, pyb_flash_readblocks);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_flash_readblocks_obj, 3, 4, pyb_flash_readblocks);
STATIC mp_obj_t pyb_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
pyb_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
uint32_t block_num = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo;
@@ -341,9 +341,9 @@ STATIC mp_obj_t pyb_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
#endif
return MP_OBJ_NEW_SMALL_INT(ret);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_flash_writeblocks_obj, 3, 4, pyb_flash_writeblocks);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_flash_writeblocks_obj, 3, 4, pyb_flash_writeblocks);
STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
static mp_obj_t pyb_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
pyb_flash_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t cmd = mp_obj_get_int(cmd_in);
switch (cmd) {
@@ -390,15 +390,15 @@ STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_flash_ioctl_obj, pyb_flash_ioctl);
static MP_DEFINE_CONST_FUN_OBJ_3(pyb_flash_ioctl_obj, pyb_flash_ioctl);
STATIC const mp_rom_map_elem_t pyb_flash_locals_dict_table[] = {
static const mp_rom_map_elem_t pyb_flash_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&pyb_flash_readblocks_obj) },
{ MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&pyb_flash_writeblocks_obj) },
{ MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&pyb_flash_ioctl_obj) },
};
STATIC MP_DEFINE_CONST_DICT(pyb_flash_locals_dict, pyb_flash_locals_dict_table);
static MP_DEFINE_CONST_DICT(pyb_flash_locals_dict, pyb_flash_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
pyb_flash_type,

View File

@@ -37,7 +37,7 @@
#define TIMER_SIZE 2
void timer_irq_handler(void *param);
STATIC mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args);
static mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args);
#if defined(TIMER_CHANNEL)
typedef struct _pyb_timer_channel_obj_t {
@@ -59,10 +59,10 @@ typedef struct _pyb_timer_obj_t {
} pyb_timer_obj_t;
#define PYB_TIMER_OBJ_ALL_NUM MP_ARRAY_SIZE(MP_STATE_PORT(pyb_timer_obj_all))
STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in);
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback);
static mp_obj_t pyb_timer_deinit(mp_obj_t self_in);
static mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback);
#if defined(TIMER_CHANNEL)
STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback);
static mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback);
#endif
static const int ra_agt_timer_ch[TIMER_SIZE] = {1, 2};
@@ -86,7 +86,7 @@ void timer_deinit(void) {
* Timer Class
*/
STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "Timer(%u)", self->tim_id);
}
@@ -106,7 +106,7 @@ STATIC void pyb_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
/// - `callback` - as per Timer.callback()
//////
/// You must either specify freq.
STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
// enum { ARG_freq, ARG_prescaler, ARG_period, ARG_tick_hz, ARG_mode, ARG_div, ARG_callback, ARG_deadtime };
enum { ARG_freq, ARG_callback };
static const mp_arg_t allowed_args[] = {
@@ -145,7 +145,7 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, size_t n_args, cons
/// Construct a new timer object of the given id. If additional
/// arguments are given, then the timer is initialised by `init(...)`.
/// `id` can be 1 to 14, excluding 3.
STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
@@ -174,10 +174,10 @@ STATIC mp_obj_t pyb_timer_make_new(const mp_obj_type_t *type, size_t n_args, siz
return MP_OBJ_FROM_PTR(tim);
}
STATIC mp_obj_t pyb_timer_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
static mp_obj_t pyb_timer_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_timer_init_helper(MP_OBJ_TO_PTR(args[0]), n_args - 1, args + 1, kw_args);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
static MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
/// \method deinit()
/// Deinitialises the timer.
@@ -185,7 +185,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
/// Disables the callback (and the associated irq).
/// Disables any channel callbacks (and the associated irq).
/// Stops the timer, and disables the timer peripheral.
STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
static mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(self_in);
// Disable the base interrupt
@@ -207,7 +207,7 @@ STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in) {
ra_agt_timer_deinit(self->tim_id - 1);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
static MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
#if defined(TIMER_CHANNEL)
/// \method channel(channel, mode, ...)
@@ -221,7 +221,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_timer_deinit_obj, pyb_timer_deinit);
/// input capture. All channels share the same underlying timer, which means
/// that they share the same timer clock.
///
STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_callback, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
{ MP_QSTR_compare, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
@@ -294,14 +294,14 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_ma
// ToDo
return MP_OBJ_FROM_PTR(chan);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_channel_obj, 2, pyb_timer_channel);
static MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_channel_obj, 2, pyb_timer_channel);
#endif
#if TIMER_COUNTER
// Not implemented
/// \method counter([value])
/// Get or set the timer counter.
STATIC mp_obj_t pyb_timer_counter(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_timer_counter(size_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (n_args == 1) {
// get
@@ -312,12 +312,12 @@ STATIC mp_obj_t pyb_timer_counter(size_t n_args, const mp_obj_t *args) {
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_counter_obj, 1, 2, pyb_timer_counter);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_counter_obj, 1, 2, pyb_timer_counter);
#endif
/// \method freq([value])
/// Get or set the frequency for the timer (changes prescaler and period if set).
STATIC mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(args[0]);
int ch = self->tim_id - 1;
if (n_args == 1) {
@@ -349,13 +349,13 @@ STATIC mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args) {
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_freq_obj, 1, 2, pyb_timer_freq);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_freq_obj, 1, 2, pyb_timer_freq);
#if TIMER_PERIOD
// Not implemented
/// \method period([value])
/// Get or set the period of the timer.
STATIC mp_obj_t pyb_timer_period(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_timer_period(size_t n_args, const mp_obj_t *args) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (n_args == 1) {
// get
@@ -367,14 +367,14 @@ STATIC mp_obj_t pyb_timer_period(size_t n_args, const mp_obj_t *args) {
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_period_obj, 1, 2, pyb_timer_period);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_period_obj, 1, 2, pyb_timer_period);
#endif
/// \method callback(fun)
/// Set the function to be called when the timer triggers.
/// `fun` is passed 1 argument, the timer object.
/// If `fun` is `None` then the callback will be disabled.
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback) {
static mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback) {
pyb_timer_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (callback == mp_const_none) {
// stop interrupt (but not timer)
@@ -393,9 +393,9 @@ STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback) {
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_timer_callback_obj, pyb_timer_callback);
static MP_DEFINE_CONST_FUN_OBJ_2(pyb_timer_callback_obj, pyb_timer_callback);
STATIC const mp_rom_map_elem_t pyb_timer_locals_dict_table[] = {
static const mp_rom_map_elem_t pyb_timer_locals_dict_table[] = {
// instance methods
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&pyb_timer_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pyb_timer_deinit_obj) },
@@ -408,7 +408,7 @@ STATIC const mp_rom_map_elem_t pyb_timer_locals_dict_table[] = {
#endif
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&pyb_timer_callback_obj) },
};
STATIC MP_DEFINE_CONST_DICT(pyb_timer_locals_dict, pyb_timer_locals_dict_table);
static MP_DEFINE_CONST_DICT(pyb_timer_locals_dict, pyb_timer_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
pyb_timer_type,
@@ -430,7 +430,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
/// Timer channels are used to generate/capture a signal using a timer.
///
/// TimerChannel objects are created using the Timer.channel() method.
STATIC void pyb_timer_channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
static void pyb_timer_channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_timer_channel_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "TimerChannel(timer=%u, channel=%u",
@@ -455,7 +455,7 @@ STATIC void pyb_timer_channel_print(const mp_print_t *print, mp_obj_t self_in, m
///
/// In edge aligned mode, a pulse_width of `period + 1` corresponds to a duty cycle of 100%
/// In center aligned mode, a pulse width of `period` corresponds to a duty cycle of 100%
STATIC mp_obj_t pyb_timer_channel_capture_compare(size_t n_args, const mp_obj_t *args) {
static mp_obj_t pyb_timer_channel_capture_compare(size_t n_args, const mp_obj_t *args) {
pyb_timer_channel_obj_t *self = MP_OBJ_TO_PTR(args[0]);
if (n_args == 1) {
// get
@@ -466,13 +466,13 @@ STATIC mp_obj_t pyb_timer_channel_capture_compare(size_t n_args, const mp_obj_t
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_channel_capture_compare_obj, 1, 2, pyb_timer_channel_capture_compare);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_timer_channel_capture_compare_obj, 1, 2, pyb_timer_channel_capture_compare);
/// \method callback(fun)
/// Set the function to be called when the timer channel triggers.
/// `fun` is passed 1 argument, the timer object.
/// If `fun` is `None` then the callback will be disabled.
STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback) {
static mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback) {
pyb_timer_channel_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (callback == mp_const_none) {
// stop interrupt (but not timer)
@@ -493,17 +493,17 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_timer_channel_callback_obj, pyb_timer_channel_callback);
static MP_DEFINE_CONST_FUN_OBJ_2(pyb_timer_channel_callback_obj, pyb_timer_channel_callback);
STATIC const mp_rom_map_elem_t pyb_timer_channel_locals_dict_table[] = {
static const mp_rom_map_elem_t pyb_timer_channel_locals_dict_table[] = {
// instance methods
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&pyb_timer_channel_callback_obj) },
{ MP_ROM_QSTR(MP_QSTR_capture), MP_ROM_PTR(&pyb_timer_channel_capture_compare_obj) },
{ MP_ROM_QSTR(MP_QSTR_compare), MP_ROM_PTR(&pyb_timer_channel_capture_compare_obj) },
};
STATIC MP_DEFINE_CONST_DICT(pyb_timer_channel_locals_dict, pyb_timer_channel_locals_dict_table);
static MP_DEFINE_CONST_DICT(pyb_timer_channel_locals_dict, pyb_timer_channel_locals_dict_table);
STATIC MP_DEFINE_CONST_OBJ_TYPE(
static MP_DEFINE_CONST_OBJ_TYPE(
pyb_timer_channel_type,
MP_QSTR_TimerChannel,
MP_TYPE_FLAG_NONE,
@@ -512,7 +512,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
);
#endif
STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_obj_t callback) {
static void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_obj_t callback) {
// execute callback if it's set
if (callback != mp_const_none) {

View File

@@ -506,7 +506,7 @@ void uart_tx_strn(machine_uart_obj_t *uart_obj, const char *str, uint len) {
uart_tx_data(uart_obj, str, len, &errcode);
}
STATIC mp_uint_t uart_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
static mp_uint_t uart_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
uart_irq_config(self, false);
self->mp_irq_trigger = new_trigger;
@@ -514,7 +514,7 @@ STATIC mp_uint_t uart_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
return 0;
}
STATIC mp_uint_t uart_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
static mp_uint_t uart_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (info_type == MP_IRQ_INFO_FLAGS) {
return self->mp_irq_flags;

View File

@@ -69,7 +69,7 @@ typedef struct _pyb_switch_obj_t {
mp_obj_base_t base;
} pyb_switch_obj_t;
STATIC const pyb_switch_obj_t pyb_switch_obj = {{&pyb_switch_type}};
static const pyb_switch_obj_t pyb_switch_obj = {{&pyb_switch_type}};
void pyb_switch_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
mp_print_str(print, "Switch()");
@@ -77,7 +77,7 @@ void pyb_switch_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
/// \classmethod \constructor()
/// Create and return a switch object.
STATIC mp_obj_t pyb_switch_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
static mp_obj_t pyb_switch_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 0, 0, false);
@@ -101,15 +101,15 @@ mp_obj_t pyb_switch_value(mp_obj_t self_in) {
(void)self_in;
return mp_obj_new_bool(switch_get());
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_switch_value_obj, pyb_switch_value);
static MP_DEFINE_CONST_FUN_OBJ_1(pyb_switch_value_obj, pyb_switch_value);
STATIC mp_obj_t switch_callback(mp_obj_t line) {
static mp_obj_t switch_callback(mp_obj_t line) {
if (MP_STATE_PORT(pyb_switch_callback) != mp_const_none) {
mp_call_function_0(MP_STATE_PORT(pyb_switch_callback));
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(switch_callback_obj, switch_callback);
static MP_DEFINE_CONST_FUN_OBJ_1(switch_callback_obj, switch_callback);
/// \method callback(fun)
/// Register the given function to be called when the switch is pressed down.
@@ -126,14 +126,14 @@ mp_obj_t pyb_switch_callback(mp_obj_t self_in, mp_obj_t callback) {
true);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_switch_callback_obj, pyb_switch_callback);
static MP_DEFINE_CONST_FUN_OBJ_2(pyb_switch_callback_obj, pyb_switch_callback);
STATIC const mp_rom_map_elem_t pyb_switch_locals_dict_table[] = {
static const mp_rom_map_elem_t pyb_switch_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&pyb_switch_value_obj) },
{ MP_ROM_QSTR(MP_QSTR_callback), MP_ROM_PTR(&pyb_switch_callback_obj) },
};
STATIC MP_DEFINE_CONST_DICT(pyb_switch_locals_dict, pyb_switch_locals_dict_table);
static MP_DEFINE_CONST_DICT(pyb_switch_locals_dict, pyb_switch_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE(
pyb_switch_type,