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:
committed by
Damien George
parent
b3f2f18f92
commit
decf8e6a8b
@@ -42,7 +42,7 @@ static bool channel_list[FSL_FEATURE_DMAMUX_MODULE_CHANNEL] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC bool dma_initialized = false;
|
||||
static bool dma_initialized = false;
|
||||
|
||||
// allocate_channel(): retrieve an available channel. Return the number or -1
|
||||
int allocate_dma_channel(void) {
|
||||
|
||||
@@ -177,7 +177,7 @@ static uint8_t hw_addr_1[6]; // The MAC address field
|
||||
#define TRACE_ETH_RX (0x0004)
|
||||
#define TRACE_ETH_FULL (0x0008)
|
||||
|
||||
STATIC void eth_trace(eth_t *self, size_t len, const void *data, unsigned int flags) {
|
||||
static void eth_trace(eth_t *self, size_t len, const void *data, unsigned int flags) {
|
||||
if (((flags & NETUTILS_TRACE_IS_TX) && (self->trace_flags & TRACE_ETH_TX))
|
||||
|| (!(flags & NETUTILS_TRACE_IS_TX) && (self->trace_flags & TRACE_ETH_RX))) {
|
||||
const uint8_t *buf;
|
||||
@@ -197,7 +197,7 @@ STATIC void eth_trace(eth_t *self, size_t len, const void *data, unsigned int fl
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void eth_process_frame(eth_t *self, uint8_t *buf, size_t length) {
|
||||
static void eth_process_frame(eth_t *self, uint8_t *buf, size_t length) {
|
||||
|
||||
struct netif *netif = &self->netif;
|
||||
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||
@@ -240,7 +240,7 @@ void eth_irq_handler(ENET_Type *base, enet_handle_t *handle,
|
||||
}
|
||||
|
||||
// Configure the ethernet clock
|
||||
STATIC uint32_t eth_clock_init(int eth_id, bool phy_clock) {
|
||||
static uint32_t eth_clock_init(int eth_id, bool phy_clock) {
|
||||
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc);
|
||||
|
||||
@@ -282,7 +282,7 @@ STATIC uint32_t eth_clock_init(int eth_id, bool phy_clock) {
|
||||
}
|
||||
|
||||
// eth_gpio_init: Configure the GPIO pins
|
||||
STATIC void eth_gpio_init(const iomux_table_t iomux_table[], size_t iomux_table_size,
|
||||
static void eth_gpio_init(const iomux_table_t iomux_table[], size_t iomux_table_size,
|
||||
const machine_pin_obj_t *reset_pin, const machine_pin_obj_t *int_pin) {
|
||||
|
||||
gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 1, kGPIO_NoIntmode};
|
||||
@@ -328,7 +328,7 @@ STATIC void eth_gpio_init(const iomux_table_t iomux_table[], size_t iomux_table_
|
||||
}
|
||||
|
||||
// eth_phy_init: Initilaize the PHY interface
|
||||
STATIC void eth_phy_init(phy_handle_t *phyHandle, phy_config_t *phy_config,
|
||||
static void eth_phy_init(phy_handle_t *phyHandle, phy_config_t *phy_config,
|
||||
phy_speed_t *speed, phy_duplex_t *duplex, uint32_t phy_settle_time) {
|
||||
|
||||
bool link = false;
|
||||
@@ -471,12 +471,12 @@ void eth_init_1(eth_t *self, int eth_id, const phy_operations_t *phy_ops, int ph
|
||||
|
||||
#endif
|
||||
// Initialize the phy interface
|
||||
STATIC int eth_mac_init(eth_t *self) {
|
||||
static int eth_mac_init(eth_t *self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Deinit the interface
|
||||
STATIC void eth_mac_deinit(eth_t *self) {
|
||||
static void eth_mac_deinit(eth_t *self) {
|
||||
// Just as a reminder: Calling ENET_Deinit() twice causes the board to stall
|
||||
// with a bus error. Reason unclear. So don't do that for now (or ever).
|
||||
}
|
||||
@@ -488,7 +488,7 @@ void eth_set_trace(eth_t *self, uint32_t value) {
|
||||
/*******************************************************************************/
|
||||
// ETH-LwIP bindings
|
||||
|
||||
STATIC err_t eth_send_frame_blocking(ENET_Type *base, enet_handle_t *handle, uint8_t *buffer, int len) {
|
||||
static err_t eth_send_frame_blocking(ENET_Type *base, enet_handle_t *handle, uint8_t *buffer, int len) {
|
||||
status_t status;
|
||||
int i;
|
||||
#define XMIT_LOOP 10
|
||||
@@ -504,7 +504,7 @@ STATIC err_t eth_send_frame_blocking(ENET_Type *base, enet_handle_t *handle, uin
|
||||
return status;
|
||||
}
|
||||
|
||||
STATIC err_t eth_netif_output(struct netif *netif, struct pbuf *p) {
|
||||
static err_t eth_netif_output(struct netif *netif, struct pbuf *p) {
|
||||
// This function should always be called from a context where PendSV-level IRQs are disabled
|
||||
status_t status;
|
||||
ENET_Type *enet = ENET;
|
||||
@@ -536,7 +536,7 @@ STATIC err_t eth_netif_output(struct netif *netif, struct pbuf *p) {
|
||||
return status == kStatus_Success ? ERR_OK : ERR_BUF;
|
||||
}
|
||||
|
||||
STATIC err_t eth_netif_init(struct netif *netif) {
|
||||
static err_t eth_netif_init(struct netif *netif) {
|
||||
netif->linkoutput = eth_netif_output;
|
||||
netif->output = etharp_output;
|
||||
netif->mtu = 1500;
|
||||
@@ -552,7 +552,7 @@ STATIC err_t eth_netif_init(struct netif *netif) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
STATIC void eth_lwip_init(eth_t *self) {
|
||||
static void eth_lwip_init(eth_t *self) {
|
||||
struct netif *n = &self->netif;
|
||||
ip_addr_t ipconfig[4];
|
||||
|
||||
@@ -588,7 +588,7 @@ STATIC void eth_lwip_init(eth_t *self) {
|
||||
MICROPY_PY_LWIP_EXIT
|
||||
}
|
||||
|
||||
STATIC void eth_lwip_deinit(eth_t *self) {
|
||||
static void eth_lwip_deinit(eth_t *self) {
|
||||
MICROPY_PY_LWIP_ENTER
|
||||
for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
if (netif == &self->netif) {
|
||||
|
||||
@@ -49,9 +49,9 @@ typedef struct _machine_adc_obj_t {
|
||||
uint16_t resolution;
|
||||
} machine_adc_obj_t;
|
||||
|
||||
STATIC ADC_Type *const adc_bases[] = ADC_BASE_PTRS;
|
||||
static ADC_Type *const adc_bases[] = ADC_BASE_PTRS;
|
||||
|
||||
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) {
|
||||
(void)kind;
|
||||
machine_adc_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
@@ -64,7 +64,7 @@ STATIC void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_p
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
// Unpack and check parameter
|
||||
@@ -99,7 +99,7 @@ STATIC mp_obj_t mp_machine_adc_make_new(const mp_obj_type_t *type, size_t n_args
|
||||
|
||||
// read_u16()
|
||||
#if defined(MIMXRT117x_SERIES)
|
||||
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) {
|
||||
lpadc_conv_command_config_t adc_config;
|
||||
lpadc_conv_trigger_config_t trigger_config;
|
||||
|
||||
@@ -133,7 +133,7 @@ void machine_adc_init(void) {
|
||||
|
||||
#else
|
||||
|
||||
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) {
|
||||
// Initiate conversion
|
||||
adc_channel_config_t channel_config = {
|
||||
.channelNumber = self->channel,
|
||||
|
||||
@@ -55,8 +55,8 @@ typedef struct _iomux_table_t {
|
||||
uint32_t configRegister;
|
||||
} iomux_table_t;
|
||||
|
||||
STATIC const uint8_t i2c_index_table[] = MICROPY_HW_I2C_INDEX;
|
||||
STATIC LPI2C_Type *i2c_base_ptr_table[] = LPI2C_BASE_PTRS;
|
||||
static const uint8_t i2c_index_table[] = MICROPY_HW_I2C_INDEX;
|
||||
static LPI2C_Type *i2c_base_ptr_table[] = LPI2C_BASE_PTRS;
|
||||
static const iomux_table_t iomux_table[] = { IOMUX_TABLE_I2C };
|
||||
|
||||
#define MICROPY_HW_I2C_NUM ARRAY_SIZE(i2c_index_table)
|
||||
@@ -80,7 +80,7 @@ bool lpi2c_set_iomux(int8_t hw_i2c, uint8_t drive) {
|
||||
}
|
||||
}
|
||||
|
||||
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)",
|
||||
self->i2c_id, self->master_config->baudRate_Hz);
|
||||
@@ -133,7 +133,7 @@ static void lpi2c_master_callback(LPI2C_Type *base, lpi2c_master_handle_t *handl
|
||||
self->transfer_status = status;
|
||||
}
|
||||
|
||||
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 = (machine_i2c_obj_t *)self_in;
|
||||
status_t ret;
|
||||
lpi2c_master_handle_t g_master_handle;
|
||||
@@ -185,7 +185,7 @@ STATIC int machine_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, si
|
||||
}
|
||||
}
|
||||
|
||||
STATIC const mp_machine_i2c_p_t machine_i2c_p = {
|
||||
static const mp_machine_i2c_p_t machine_i2c_p = {
|
||||
.transfer = mp_machine_i2c_transfer_adaptor,
|
||||
.transfer_single = machine_i2c_transfer_single,
|
||||
};
|
||||
|
||||
@@ -126,12 +126,12 @@ typedef struct _i2s_clock_config_t {
|
||||
uint32_t clock_divider;
|
||||
} i2s_clock_config_t;
|
||||
|
||||
STATIC mp_obj_t machine_i2s_deinit(mp_obj_t self_in);
|
||||
static mp_obj_t machine_i2s_deinit(mp_obj_t self_in);
|
||||
|
||||
// The frame map is used with the readinto() method to transform the audio sample data coming
|
||||
// from DMA memory (32-bit stereo) to the format specified
|
||||
// in the I2S constructor. e.g. 16-bit mono
|
||||
STATIC const int8_t i2s_frame_map[NUM_I2S_USER_FORMATS][I2S_RX_FRAME_SIZE_IN_BYTES] = {
|
||||
static const int8_t i2s_frame_map[NUM_I2S_USER_FORMATS][I2S_RX_FRAME_SIZE_IN_BYTES] = {
|
||||
{-1, -1, 0, 1, -1, -1, -1, -1 }, // Mono, 16-bits
|
||||
{ 0, 1, 2, 3, -1, -1, -1, -1 }, // Mono, 32-bits
|
||||
{-1, -1, 0, 1, -1, -1, 2, 3 }, // Stereo, 16-bits
|
||||
@@ -143,7 +143,7 @@ STATIC const int8_t i2s_frame_map[NUM_I2S_USER_FORMATS][I2S_RX_FRAME_SIZE_IN_BYT
|
||||
|
||||
// Configuration 1: for sampling frequencies [Hz]: 8000, 12000, 16000, 24000, 32000, 48000
|
||||
// Clock frequency = 786,432,000 Hz = 48000 * 64 * 256
|
||||
STATIC const clock_audio_pll_config_t audioPllConfig_8000_48000 = {
|
||||
static const clock_audio_pll_config_t audioPllConfig_8000_48000 = {
|
||||
.loopDivider = 32, // PLL loop divider. Valid range for DIV_SELECT divider value: 27~54
|
||||
.postDivider = 1, // Divider after the PLL, should only be 1, 2, 4, 8, 16
|
||||
.numerator = 76800, // 30 bit numerator of fractional loop divider
|
||||
@@ -155,7 +155,7 @@ STATIC const clock_audio_pll_config_t audioPllConfig_8000_48000 = {
|
||||
|
||||
// Configuration 2: for sampling frequencies [Hz]: 11025, 22050, 44100
|
||||
// Clock frequency = 722,534,400 = 44100 * 64 * 256
|
||||
STATIC const clock_audio_pll_config_t audioPllConfig_11025_44100 = {
|
||||
static const clock_audio_pll_config_t audioPllConfig_11025_44100 = {
|
||||
.loopDivider = 30, // PLL loop divider. Valid range for DIV_SELECT divider value: 27~54
|
||||
.postDivider = 1, // Divider after the PLL, should only be 1, 2, 4, 8, 16
|
||||
.numerator = 10560, // 30 bit numerator of fractional loop divider
|
||||
@@ -170,7 +170,7 @@ STATIC const clock_audio_pll_config_t audioPllConfig_11025_44100 = {
|
||||
// which is 2**n: 0->1, 1->2, 2->4, 3->8, 4->16, 5->32
|
||||
// The divider is 8 bit and must be given as n (not n-1)
|
||||
// So the total division factor is given by (2**p) * d
|
||||
STATIC const i2s_clock_config_t clock_config_map[] = {
|
||||
static const i2s_clock_config_t clock_config_map[] = {
|
||||
{kSAI_SampleRate8KHz, &audioPllConfig_8000_48000, 1, 192}, // 384
|
||||
{kSAI_SampleRate11025Hz, &audioPllConfig_11025_44100, 1, 128}, // 256
|
||||
{kSAI_SampleRate12KHz, &audioPllConfig_8000_48000, 1, 128}, // 256
|
||||
@@ -182,10 +182,10 @@ STATIC const i2s_clock_config_t clock_config_map[] = {
|
||||
{kSAI_SampleRate48KHz, &audioPllConfig_8000_48000, 0, 64} // 64
|
||||
};
|
||||
|
||||
STATIC const clock_root_t i2s_clock_mux[] = I2S_CLOCK_MUX;
|
||||
static const clock_root_t i2s_clock_mux[] = I2S_CLOCK_MUX;
|
||||
#else
|
||||
// for 10xx the total division factor is given by (p + 1) * (d + 1)
|
||||
STATIC const i2s_clock_config_t clock_config_map[] = {
|
||||
static const i2s_clock_config_t clock_config_map[] = {
|
||||
{kSAI_SampleRate8KHz, &audioPllConfig_8000_48000, 5, 63}, // 384
|
||||
{kSAI_SampleRate11025Hz, &audioPllConfig_11025_44100, 3, 63}, // 256
|
||||
{kSAI_SampleRate12KHz, &audioPllConfig_8000_48000, 3, 63}, // 256
|
||||
@@ -197,18 +197,18 @@ STATIC const i2s_clock_config_t clock_config_map[] = {
|
||||
{kSAI_SampleRate48KHz, &audioPllConfig_8000_48000, 0, 63} // 64
|
||||
};
|
||||
|
||||
STATIC const clock_mux_t i2s_clock_mux[] = I2S_CLOCK_MUX;
|
||||
STATIC const clock_div_t i2s_clock_pre_div[] = I2S_CLOCK_PRE_DIV;
|
||||
STATIC const clock_div_t i2s_clock_div[] = I2S_CLOCK_DIV;
|
||||
STATIC const iomuxc_gpr_mode_t i2s_iomuxc_gpr_mode[] = I2S_IOMUXC_GPR_MODE;
|
||||
static const clock_mux_t i2s_clock_mux[] = I2S_CLOCK_MUX;
|
||||
static const clock_div_t i2s_clock_pre_div[] = I2S_CLOCK_PRE_DIV;
|
||||
static const clock_div_t i2s_clock_div[] = I2S_CLOCK_DIV;
|
||||
static const iomuxc_gpr_mode_t i2s_iomuxc_gpr_mode[] = I2S_IOMUXC_GPR_MODE;
|
||||
#endif
|
||||
|
||||
STATIC const I2S_Type *i2s_base_ptr[] = I2S_BASE_PTRS;
|
||||
static const I2S_Type *i2s_base_ptr[] = I2S_BASE_PTRS;
|
||||
|
||||
STATIC const dma_request_source_t i2s_dma_req_src_tx[] = I2S_DMA_REQ_SRC_TX;
|
||||
STATIC const dma_request_source_t i2s_dma_req_src_rx[] = I2S_DMA_REQ_SRC_RX;
|
||||
STATIC const gpio_map_t i2s_gpio_map[] = I2S_GPIO_MAP;
|
||||
AT_NONCACHEABLE_SECTION_ALIGN(STATIC edma_tcd_t edmaTcd[MICROPY_HW_I2S_NUM], 32);
|
||||
static const dma_request_source_t i2s_dma_req_src_tx[] = I2S_DMA_REQ_SRC_TX;
|
||||
static const dma_request_source_t i2s_dma_req_src_rx[] = I2S_DMA_REQ_SRC_RX;
|
||||
static const gpio_map_t i2s_gpio_map[] = I2S_GPIO_MAP;
|
||||
AT_NONCACHEABLE_SECTION_ALIGN(edma_tcd_t edmaTcd[MICROPY_HW_I2S_NUM], 32);
|
||||
|
||||
// called on processor reset
|
||||
void machine_i2s_init0() {
|
||||
@@ -228,7 +228,7 @@ void machine_i2s_deinit_all(void) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC int8_t get_frame_mapping_index(int8_t bits, format_t format) {
|
||||
static int8_t get_frame_mapping_index(int8_t bits, format_t format) {
|
||||
if (format == MONO) {
|
||||
if (bits == 16) {
|
||||
return 0;
|
||||
@@ -244,7 +244,7 @@ STATIC int8_t get_frame_mapping_index(int8_t bits, format_t format) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC int8_t get_dma_bits(uint16_t mode, int8_t bits) {
|
||||
static int8_t get_dma_bits(uint16_t mode, int8_t bits) {
|
||||
if (mode == TX) {
|
||||
if (bits == 16) {
|
||||
return 16;
|
||||
@@ -258,7 +258,7 @@ STATIC int8_t get_dma_bits(uint16_t mode, int8_t bits) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC bool lookup_gpio(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uint8_t hw_id, uint16_t *index) {
|
||||
static bool lookup_gpio(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uint8_t hw_id, uint16_t *index) {
|
||||
for (uint16_t i = 0; i < ARRAY_SIZE(i2s_gpio_map); i++) {
|
||||
if ((pin->name == i2s_gpio_map[i].name) &&
|
||||
(i2s_gpio_map[i].fn == fn) &&
|
||||
@@ -270,7 +270,7 @@ STATIC bool lookup_gpio(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uin
|
||||
return false;
|
||||
}
|
||||
|
||||
STATIC bool set_iomux(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uint8_t hw_id) {
|
||||
static bool set_iomux(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uint8_t hw_id) {
|
||||
uint16_t mapping_index;
|
||||
if (lookup_gpio(pin, fn, hw_id, &mapping_index)) {
|
||||
iomux_table_t iom = i2s_gpio_map[mapping_index].iomux;
|
||||
@@ -283,7 +283,7 @@ STATIC bool set_iomux(const machine_pin_obj_t *pin, i2s_pin_function_t fn, uint8
|
||||
}
|
||||
}
|
||||
|
||||
STATIC bool is_rate_supported(int32_t rate) {
|
||||
static bool is_rate_supported(int32_t rate) {
|
||||
for (uint16_t i = 0; i < ARRAY_SIZE(clock_config_map); i++) {
|
||||
if (clock_config_map[i].rate == rate) {
|
||||
return true;
|
||||
@@ -292,7 +292,7 @@ STATIC bool is_rate_supported(int32_t rate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
STATIC const clock_audio_pll_config_t *get_pll_config(int32_t rate) {
|
||||
static const clock_audio_pll_config_t *get_pll_config(int32_t rate) {
|
||||
for (uint16_t i = 0; i < ARRAY_SIZE(clock_config_map); i++) {
|
||||
if (clock_config_map[i].rate == rate) {
|
||||
return clock_config_map[i].pll_config;
|
||||
@@ -301,7 +301,7 @@ STATIC const clock_audio_pll_config_t *get_pll_config(int32_t rate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC const uint32_t get_clock_pre_divider(int32_t rate) {
|
||||
static const uint32_t get_clock_pre_divider(int32_t rate) {
|
||||
for (uint16_t i = 0; i < ARRAY_SIZE(clock_config_map); i++) {
|
||||
if (clock_config_map[i].rate == rate) {
|
||||
return clock_config_map[i].clock_pre_divider;
|
||||
@@ -310,7 +310,7 @@ STATIC const uint32_t get_clock_pre_divider(int32_t rate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC const uint32_t get_clock_divider(int32_t rate) {
|
||||
static const uint32_t get_clock_divider(int32_t rate) {
|
||||
for (uint16_t i = 0; i < ARRAY_SIZE(clock_config_map); i++) {
|
||||
if (clock_config_map[i].rate == rate) {
|
||||
return clock_config_map[i].clock_divider;
|
||||
@@ -320,7 +320,7 @@ STATIC const uint32_t get_clock_divider(int32_t rate) {
|
||||
}
|
||||
|
||||
// function is used in IRQ context
|
||||
STATIC void empty_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
static void empty_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
uint16_t dma_buffer_offset = 0;
|
||||
|
||||
if (dma_ping_pong == TOP_HALF) {
|
||||
@@ -343,7 +343,7 @@ STATIC void empty_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
}
|
||||
|
||||
// function is used in IRQ context
|
||||
STATIC void feed_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
static void feed_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
uint16_t dma_buffer_offset = 0;
|
||||
|
||||
if (dma_ping_pong == TOP_HALF) {
|
||||
@@ -387,7 +387,7 @@ STATIC void feed_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) {
|
||||
MP_HAL_CLEAN_DCACHE(dma_buffer_p, SIZEOF_HALF_DMA_BUFFER_IN_BYTES);
|
||||
}
|
||||
|
||||
STATIC void edma_i2s_callback(edma_handle_t *handle, void *userData, bool transferDone, uint32_t tcds) {
|
||||
static void edma_i2s_callback(edma_handle_t *handle, void *userData, bool transferDone, uint32_t tcds) {
|
||||
machine_i2s_obj_t *self = userData;
|
||||
|
||||
if (self->mode == TX) {
|
||||
@@ -423,7 +423,7 @@ STATIC void edma_i2s_callback(edma_handle_t *handle, void *userData, bool transf
|
||||
}
|
||||
}
|
||||
|
||||
STATIC bool i2s_init(machine_i2s_obj_t *self) {
|
||||
static bool i2s_init(machine_i2s_obj_t *self) {
|
||||
|
||||
#if defined(MIMXRT117x_SERIES)
|
||||
clock_audio_pll_config_t pll_config = *get_pll_config(self->rate);
|
||||
@@ -570,7 +570,7 @@ STATIC bool i2s_init(machine_i2s_obj_t *self) {
|
||||
return true;
|
||||
}
|
||||
|
||||
STATIC void mp_machine_i2s_init_helper(machine_i2s_obj_t *self, mp_arg_val_t *args) {
|
||||
static void mp_machine_i2s_init_helper(machine_i2s_obj_t *self, mp_arg_val_t *args) {
|
||||
// is Mode valid?
|
||||
uint16_t i2s_mode = args[ARG_mode].u_int;
|
||||
if ((i2s_mode != (RX)) &&
|
||||
@@ -667,7 +667,7 @@ STATIC void mp_machine_i2s_init_helper(machine_i2s_obj_t *self, mp_arg_val_t *ar
|
||||
}
|
||||
}
|
||||
|
||||
STATIC machine_i2s_obj_t *mp_machine_i2s_make_new_instance(mp_int_t i2s_id) {
|
||||
static machine_i2s_obj_t *mp_machine_i2s_make_new_instance(mp_int_t i2s_id) {
|
||||
if (i2s_id < 1 || i2s_id > MICROPY_HW_I2S_NUM) {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("I2S(%d) does not exist"), i2s_id);
|
||||
}
|
||||
@@ -694,7 +694,7 @@ STATIC machine_i2s_obj_t *mp_machine_i2s_make_new_instance(mp_int_t i2s_id) {
|
||||
return self;
|
||||
}
|
||||
|
||||
STATIC void mp_machine_i2s_deinit(machine_i2s_obj_t *self) {
|
||||
static void mp_machine_i2s_deinit(machine_i2s_obj_t *self) {
|
||||
// use self->i2s_inst as in indication that I2S object has already been de-initialized
|
||||
if (self->i2s_inst != NULL) {
|
||||
EDMA_AbortTransfer(&self->edmaHandle);
|
||||
@@ -718,7 +718,7 @@ STATIC void mp_machine_i2s_deinit(machine_i2s_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void mp_machine_i2s_irq_update(machine_i2s_obj_t *self) {
|
||||
static void mp_machine_i2s_irq_update(machine_i2s_obj_t *self) {
|
||||
(void)self;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
|
||||
#if defined(MICROPY_HW_LED1_PIN)
|
||||
|
||||
STATIC void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
static void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
machine_led_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_printf(print, "LED(%u)", self->led_id);
|
||||
}
|
||||
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
// Extract arguments
|
||||
@@ -51,34 +51,34 @@ STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
||||
return MP_OBJ_FROM_PTR(&machine_led_obj[led_id - 1]);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t led_obj_on(mp_obj_t self_in) {
|
||||
static mp_obj_t led_obj_on(mp_obj_t self_in) {
|
||||
machine_led_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
MICROPY_HW_LED_ON(self->led_pin);
|
||||
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_on_obj, led_obj_on);
|
||||
|
||||
STATIC mp_obj_t led_obj_off(mp_obj_t self_in) {
|
||||
static mp_obj_t led_obj_off(mp_obj_t self_in) {
|
||||
machine_led_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
MICROPY_HW_LED_OFF(self->led_pin);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off);
|
||||
|
||||
STATIC mp_obj_t led_obj_toggle(mp_obj_t self_in) {
|
||||
static mp_obj_t led_obj_toggle(mp_obj_t self_in) {
|
||||
machine_led_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_hal_pin_toggle(self->led_pin);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(led_obj_toggle_obj, led_obj_toggle);
|
||||
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(
|
||||
machine_led_type,
|
||||
|
||||
@@ -39,18 +39,18 @@
|
||||
#endif
|
||||
|
||||
// Local functions
|
||||
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);
|
||||
|
||||
// Class Methods
|
||||
STATIC void machine_pin_obj_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind);
|
||||
STATIC mp_obj_t machine_pin_obj_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
|
||||
static void machine_pin_obj_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind);
|
||||
static mp_obj_t machine_pin_obj_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
|
||||
mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
|
||||
// Instance Methods
|
||||
STATIC mp_obj_t machine_pin_off(mp_obj_t self_in);
|
||||
STATIC mp_obj_t machine_pin_on(mp_obj_t self_in);
|
||||
STATIC mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args);
|
||||
STATIC mp_obj_t machine_pin_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
||||
static mp_obj_t machine_pin_off(mp_obj_t self_in);
|
||||
static mp_obj_t machine_pin_on(mp_obj_t self_in);
|
||||
static mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args);
|
||||
static mp_obj_t machine_pin_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
|
||||
|
||||
// Local data
|
||||
enum {
|
||||
@@ -75,12 +75,12 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
locals_dict, &machine_pin_board_pins_locals_dict
|
||||
);
|
||||
|
||||
STATIC const mp_irq_methods_t machine_pin_irq_methods;
|
||||
static const mp_irq_methods_t machine_pin_irq_methods;
|
||||
|
||||
static GPIO_Type *gpiobases[] = GPIO_BASE_PTRS;
|
||||
STATIC const uint16_t GPIO_combined_low_irqs[] = GPIO_COMBINED_LOW_IRQS;
|
||||
STATIC const uint16_t GPIO_combined_high_irqs[] = GPIO_COMBINED_HIGH_IRQS;
|
||||
STATIC const uint16_t IRQ_mapping[] = {kGPIO_NoIntmode, kGPIO_IntRisingEdge, kGPIO_IntFallingEdge, kGPIO_IntRisingOrFallingEdge};
|
||||
static const uint16_t GPIO_combined_low_irqs[] = GPIO_COMBINED_LOW_IRQS;
|
||||
static const uint16_t GPIO_combined_high_irqs[] = GPIO_COMBINED_HIGH_IRQS;
|
||||
static const uint16_t IRQ_mapping[] = {kGPIO_NoIntmode, kGPIO_IntRisingEdge, kGPIO_IntFallingEdge, kGPIO_IntRisingOrFallingEdge};
|
||||
#define GET_PIN_IRQ_INDEX(gpio_nr, pin) ((gpio_nr - 1) * 32 + pin)
|
||||
|
||||
int GPIO_get_instance(GPIO_Type *gpio) {
|
||||
@@ -254,7 +254,7 @@ void machine_pin_config(const machine_pin_obj_t *self, uint8_t mode,
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_pin_obj_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
static mp_obj_t machine_pin_obj_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
machine_pin_obj_t *self = self_in;
|
||||
|
||||
@@ -266,7 +266,7 @@ STATIC mp_obj_t machine_pin_obj_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
[PIN_INIT_ARG_MODE] { MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
[PIN_INIT_ARG_PULL] { MP_QSTR_pull, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE}},
|
||||
@@ -326,7 +326,7 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
STATIC void machine_pin_obj_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||
static void machine_pin_obj_print(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
const machine_pin_obj_t *self = MP_OBJ_TO_PTR(o);
|
||||
mp_printf(print, "Pin(%s)", qstr_str(self->name));
|
||||
@@ -349,43 +349,43 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
|
||||
}
|
||||
|
||||
// pin.off()
|
||||
STATIC mp_obj_t machine_pin_off(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_pin_off(mp_obj_t self_in) {
|
||||
machine_pin_obj_t *self = self_in;
|
||||
mp_hal_pin_low(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_off_obj, machine_pin_off);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_off_obj, machine_pin_off);
|
||||
|
||||
// pin.on()
|
||||
STATIC mp_obj_t machine_pin_on(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_pin_on(mp_obj_t self_in) {
|
||||
machine_pin_obj_t *self = self_in;
|
||||
mp_hal_pin_high(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_on_obj, machine_pin_on);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_on_obj, machine_pin_on);
|
||||
|
||||
// pin.toggle()
|
||||
STATIC mp_obj_t machine_pin_toggle(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_pin_toggle(mp_obj_t self_in) {
|
||||
machine_pin_obj_t *self = self_in;
|
||||
mp_hal_pin_toggle(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_toggle_obj, machine_pin_toggle);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_pin_toggle_obj, machine_pin_toggle);
|
||||
|
||||
// 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_obj_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.init(mode, pull, [kwargs])
|
||||
STATIC mp_obj_t machine_pin_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static mp_obj_t machine_pin_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_init);
|
||||
|
||||
// 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} },
|
||||
@@ -452,9 +452,9 @@ STATIC mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
|
||||
return MP_OBJ_FROM_PTR(irq);
|
||||
}
|
||||
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_off), MP_ROM_PTR(&machine_pin_off_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&machine_pin_on_obj) },
|
||||
@@ -491,9 +491,9 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_IRQ_FALLING), MP_ROM_INT(2) },
|
||||
|
||||
};
|
||||
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 = self_in;
|
||||
|
||||
@@ -509,7 +509,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_obj_protocol = {
|
||||
static const mp_pin_p_t machine_pin_obj_protocol = {
|
||||
.ioctl = machine_pin_ioctl,
|
||||
};
|
||||
|
||||
@@ -534,7 +534,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
locals_dict, &machine_pin_locals_dict
|
||||
);
|
||||
|
||||
STATIC mp_uint_t machine_pin_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
|
||||
static mp_uint_t machine_pin_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
|
||||
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
uint32_t gpio_nr = GPIO_get_instance(self->gpio);
|
||||
machine_pin_irq_obj_t *irq = MP_STATE_PORT(machine_pin_irq_objects[GET_PIN_IRQ_INDEX(gpio_nr, self->pin)]);
|
||||
@@ -551,7 +551,7 @@ STATIC mp_uint_t machine_pin_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC mp_uint_t machine_pin_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
|
||||
static mp_uint_t machine_pin_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
|
||||
machine_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
uint32_t gpio_nr = GPIO_get_instance(self->gpio);
|
||||
machine_pin_irq_obj_t *irq = MP_STATE_PORT(machine_pin_irq_objects[GET_PIN_IRQ_INDEX(gpio_nr, self->pin)]);
|
||||
@@ -563,7 +563,7 @@ STATIC mp_uint_t machine_pin_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC const mp_irq_methods_t machine_pin_irq_methods = {
|
||||
static const mp_irq_methods_t machine_pin_irq_methods = {
|
||||
.trigger = machine_pin_irq_trigger,
|
||||
.info = machine_pin_irq_info,
|
||||
};
|
||||
|
||||
@@ -70,9 +70,9 @@ static char *ERRMSG_FREQ = "PWM frequency too low";
|
||||
static char *ERRMSG_INIT = "PWM set-up failed";
|
||||
static char *ERRMSG_VALUE = "value larger than period";
|
||||
|
||||
STATIC void mp_machine_pwm_start(machine_pwm_obj_t *self);
|
||||
static void mp_machine_pwm_start(machine_pwm_obj_t *self);
|
||||
|
||||
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);
|
||||
if (self->is_flexpwm) {
|
||||
mp_printf(print, "<FLEXPWM module=%u submodule=%u ", self->module, self->submodule);
|
||||
@@ -103,7 +103,7 @@ STATIC void mp_machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_p
|
||||
|
||||
// Utility functions for decoding and converting
|
||||
//
|
||||
STATIC uint32_t duty_ns_to_duty_u16(uint32_t freq, uint32_t duty_ns) {
|
||||
static uint32_t duty_ns_to_duty_u16(uint32_t freq, uint32_t duty_ns) {
|
||||
uint64_t duty = (uint64_t)duty_ns * freq * PWM_FULL_SCALE / 1000000000ULL;
|
||||
if (duty > PWM_FULL_SCALE) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT(ERRMSG_VALUE));
|
||||
@@ -111,7 +111,7 @@ STATIC uint32_t duty_ns_to_duty_u16(uint32_t freq, uint32_t duty_ns) {
|
||||
return (uint32_t)duty;
|
||||
}
|
||||
|
||||
STATIC uint8_t module_decode(char channel) {
|
||||
static uint8_t module_decode(char channel) {
|
||||
switch (channel) {
|
||||
case '0':
|
||||
return kPWM_Module_0;
|
||||
@@ -126,7 +126,7 @@ STATIC uint8_t module_decode(char channel) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC uint8_t channel_decode(char channel) {
|
||||
static uint8_t channel_decode(char channel) {
|
||||
switch (channel) {
|
||||
case 'A':
|
||||
return kPWM_PwmA;
|
||||
@@ -140,7 +140,7 @@ STATIC uint8_t channel_decode(char channel) {
|
||||
}
|
||||
|
||||
// decode the AF objects module and Port number. Returns NULL if it is not a FLEXPWM object
|
||||
STATIC const machine_pin_af_obj_t *af_name_decode_flexpwm(const machine_pin_af_obj_t *af_obj,
|
||||
static const machine_pin_af_obj_t *af_name_decode_flexpwm(const machine_pin_af_obj_t *af_obj,
|
||||
uint8_t *module, uint8_t *submodule, uint8_t *channel) {
|
||||
const char *str;
|
||||
size_t len;
|
||||
@@ -158,7 +158,7 @@ STATIC const machine_pin_af_obj_t *af_name_decode_flexpwm(const machine_pin_af_o
|
||||
}
|
||||
|
||||
#ifdef FSL_FEATURE_SOC_TMR_COUNT
|
||||
STATIC uint8_t qtmr_decode(char channel) {
|
||||
static uint8_t qtmr_decode(char channel) {
|
||||
switch (channel) {
|
||||
case '0':
|
||||
return kQTMR_Channel_0;
|
||||
@@ -174,7 +174,7 @@ STATIC uint8_t qtmr_decode(char channel) {
|
||||
}
|
||||
|
||||
// decode the AF objects module and Port number. Returns NULL if it is not a QTMR object
|
||||
STATIC const machine_pin_af_obj_t *af_name_decode_qtmr(const machine_pin_af_obj_t *af_obj, uint8_t *module, uint8_t *channel) {
|
||||
static const machine_pin_af_obj_t *af_name_decode_qtmr(const machine_pin_af_obj_t *af_obj, uint8_t *module, uint8_t *channel) {
|
||||
const char *str;
|
||||
size_t len;
|
||||
str = (char *)qstr_data(af_obj->name, &len);
|
||||
@@ -190,7 +190,7 @@ STATIC const machine_pin_af_obj_t *af_name_decode_qtmr(const machine_pin_af_obj_
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC bool is_board_pin(const machine_pin_obj_t *pin) {
|
||||
static bool is_board_pin(const machine_pin_obj_t *pin) {
|
||||
const mp_map_t *board_map = &machine_pin_board_pins_locals_dict.map;
|
||||
for (uint i = 0; i < board_map->alloc; i++) {
|
||||
if (pin == MP_OBJ_TO_PTR(board_map->table[i].value)) {
|
||||
@@ -202,7 +202,7 @@ STATIC bool is_board_pin(const machine_pin_obj_t *pin) {
|
||||
|
||||
// Functions for configuring the PWM Device
|
||||
//
|
||||
STATIC int calc_prescaler(uint32_t clock, uint32_t freq) {
|
||||
static int calc_prescaler(uint32_t clock, uint32_t freq) {
|
||||
float temp = (float)clock / (float)PWM_FULL_SCALE / (float)freq;
|
||||
for (int prescale = 0; prescale < 8; prescale++, temp /= 2) {
|
||||
if (temp <= 1) {
|
||||
@@ -213,7 +213,7 @@ STATIC int calc_prescaler(uint32_t clock, uint32_t freq) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
STATIC void configure_flexpwm(machine_pwm_obj_t *self) {
|
||||
static void configure_flexpwm(machine_pwm_obj_t *self) {
|
||||
pwm_signal_param_u16_t pwmSignal;
|
||||
|
||||
// Initialize PWM module.
|
||||
@@ -300,7 +300,7 @@ STATIC void configure_flexpwm(machine_pwm_obj_t *self) {
|
||||
}
|
||||
|
||||
#ifdef FSL_FEATURE_SOC_TMR_COUNT
|
||||
STATIC void configure_qtmr(machine_pwm_obj_t *self) {
|
||||
static void configure_qtmr(machine_pwm_obj_t *self) {
|
||||
qtmr_config_t qtmrConfig;
|
||||
int prescale;
|
||||
#if defined(MIMXRT117x_SERIES)
|
||||
@@ -331,7 +331,7 @@ STATIC void configure_qtmr(machine_pwm_obj_t *self) {
|
||||
}
|
||||
#endif // FSL_FEATURE_SOC_TMR_COUNT
|
||||
|
||||
STATIC void configure_pwm(machine_pwm_obj_t *self) {
|
||||
static void configure_pwm(machine_pwm_obj_t *self) {
|
||||
// Set the clock frequencies
|
||||
// Freq range is 15Hz to ~ 3 MHz.
|
||||
static bool set_frequency = true;
|
||||
@@ -360,7 +360,7 @@ STATIC void configure_pwm(machine_pwm_obj_t *self) {
|
||||
|
||||
// Micropython API functions
|
||||
//
|
||||
STATIC void mp_machine_pwm_init_helper(machine_pwm_obj_t *self,
|
||||
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) {
|
||||
enum { ARG_freq, ARG_duty_u16, ARG_duty_ns, ARG_center, ARG_align,
|
||||
ARG_invert, ARG_sync, ARG_xor, ARG_deadtime };
|
||||
@@ -444,7 +444,7 @@ STATIC void mp_machine_pwm_init_helper(machine_pwm_obj_t *self,
|
||||
}
|
||||
|
||||
// PWM(pin | pin-tuple, freq, [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) {
|
||||
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) {
|
||||
// Check number of arguments
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
@@ -580,7 +580,7 @@ void machine_pwm_deinit_all(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC void mp_machine_pwm_start(machine_pwm_obj_t *self) {
|
||||
static void mp_machine_pwm_start(machine_pwm_obj_t *self) {
|
||||
if (self->is_flexpwm) {
|
||||
PWM_StartTimer(self->instance, 1 << self->submodule);
|
||||
#ifdef FSL_FEATURE_SOC_TMR_COUNT
|
||||
@@ -590,7 +590,7 @@ STATIC void mp_machine_pwm_start(machine_pwm_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void mp_machine_pwm_deinit(machine_pwm_obj_t *self) {
|
||||
static void mp_machine_pwm_deinit(machine_pwm_obj_t *self) {
|
||||
if (self->is_flexpwm) {
|
||||
PWM_StopTimer(self->instance, 1 << self->submodule);
|
||||
#ifdef FSL_FEATURE_SOC_TMR_COUNT
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "fsl_snvs_lp.h"
|
||||
#include "fsl_snvs_hp.h"
|
||||
|
||||
STATIC mp_int_t timeout = 0;
|
||||
static mp_int_t timeout = 0;
|
||||
|
||||
void machine_rtc_alarm_clear_en(void) {
|
||||
SNVS_LP_SRTC_DisableInterrupts(SNVS, SNVS_LPCR_LPTA_EN_MASK);
|
||||
@@ -103,7 +103,7 @@ typedef struct _machine_rtc_irq_obj_t {
|
||||
mp_irq_obj_t base;
|
||||
} machine_rtc_irq_obj_t;
|
||||
|
||||
STATIC mp_uint_t machine_rtc_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
|
||||
static mp_uint_t machine_rtc_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger) {
|
||||
new_trigger /= 1000;
|
||||
if (!new_trigger) {
|
||||
machine_rtc_alarm_off(true);
|
||||
@@ -113,11 +113,11 @@ STATIC mp_uint_t machine_rtc_irq_trigger(mp_obj_t self_in, mp_uint_t new_trigger
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC mp_uint_t machine_rtc_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
|
||||
static mp_uint_t machine_rtc_irq_info(mp_obj_t self_in, mp_uint_t info_type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC const mp_irq_methods_t machine_rtc_irq_methods = {
|
||||
static const mp_irq_methods_t machine_rtc_irq_methods = {
|
||||
.trigger = machine_rtc_irq_trigger,
|
||||
.info = machine_rtc_irq_info,
|
||||
};
|
||||
@@ -148,7 +148,7 @@ typedef struct _machine_rtc_obj_t {
|
||||
} machine_rtc_obj_t;
|
||||
|
||||
// Singleton RTC object.
|
||||
STATIC const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
|
||||
static const machine_rtc_obj_t machine_rtc_obj = {{&machine_rtc_type}};
|
||||
|
||||
// Start the RTC Timer.
|
||||
void machine_rtc_start(void) {
|
||||
@@ -177,7 +177,7 @@ void machine_rtc_start(void) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -185,7 +185,7 @@ STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, s
|
||||
return (mp_obj_t)&machine_rtc_obj;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_rtc_datetime_helper(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t machine_rtc_datetime_helper(size_t n_args, const mp_obj_t *args) {
|
||||
if (n_args == 1) {
|
||||
// Get date and time.
|
||||
snvs_lp_srtc_datetime_t srtc_date;
|
||||
@@ -225,12 +225,12 @@ STATIC mp_obj_t machine_rtc_datetime_helper(size_t n_args, const mp_obj_t *args)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t machine_rtc_datetime(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return machine_rtc_datetime_helper(n_args, args);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_datetime_obj, 1, 2, machine_rtc_datetime);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_datetime_obj, 1, 2, machine_rtc_datetime);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_now(mp_obj_t self_in) {
|
||||
static mp_obj_t machine_rtc_now(mp_obj_t self_in) {
|
||||
// Get date and time in CPython order.
|
||||
snvs_lp_srtc_datetime_t srtc_date;
|
||||
SNVS_LP_SRTC_GetDatetime(SNVS, &srtc_date);
|
||||
@@ -247,18 +247,18 @@ STATIC mp_obj_t machine_rtc_now(mp_obj_t self_in) {
|
||||
};
|
||||
return mp_obj_new_tuple(8, tuple);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_rtc_now_obj, machine_rtc_now);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_rtc_now_obj, machine_rtc_now);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_init(mp_obj_t self_in, mp_obj_t date) {
|
||||
static mp_obj_t machine_rtc_init(mp_obj_t self_in, mp_obj_t date) {
|
||||
mp_obj_t args[2] = {self_in, date};
|
||||
machine_rtc_datetime_helper(2, args);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_rtc_init_obj, machine_rtc_init);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_2(machine_rtc_init_obj, machine_rtc_init);
|
||||
|
||||
// calibration(cal)
|
||||
// When the argument is a number in the range [-16 to 15], set the calibration value.
|
||||
STATIC mp_obj_t machine_rtc_calibration(mp_obj_t self_in, mp_obj_t cal_in) {
|
||||
static mp_obj_t machine_rtc_calibration(mp_obj_t self_in, mp_obj_t cal_in) {
|
||||
mp_int_t cal = 0;
|
||||
snvs_lp_srtc_config_t snvsSrtcConfig;
|
||||
cal = mp_obj_get_int(cal_in);
|
||||
@@ -271,10 +271,10 @@ STATIC mp_obj_t machine_rtc_calibration(mp_obj_t self_in, mp_obj_t cal_in) {
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(machine_rtc_calibration_obj, machine_rtc_calibration);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_2(machine_rtc_calibration_obj, machine_rtc_calibration);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_alarm(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
STATIC const mp_arg_t allowed_args[] = {
|
||||
static mp_obj_t machine_rtc_alarm(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_id, MP_ARG_INT, {.u_int = 0} },
|
||||
{ MP_QSTR_time, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_repeat, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
|
||||
@@ -321,9 +321,9 @@ STATIC mp_obj_t machine_rtc_alarm(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_rtc_alarm_obj, 1, machine_rtc_alarm);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_rtc_alarm_obj, 1, machine_rtc_alarm);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_alarm_left(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t machine_rtc_alarm_left(size_t n_args, const mp_obj_t *args) {
|
||||
// only alarm id 0 is available
|
||||
if (n_args > 1 && mp_obj_get_int(args[1]) != 0) {
|
||||
mp_raise_OSError(MP_ENODEV);
|
||||
@@ -332,9 +332,9 @@ STATIC mp_obj_t machine_rtc_alarm_left(size_t n_args, const mp_obj_t *args) {
|
||||
uint32_t alarmSeconds = SNVS->LPTAR;
|
||||
return mp_obj_new_int((alarmSeconds >= seconds) ? ((alarmSeconds - seconds) * 1000) : 0);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_alarm_left_obj, 1, 2, machine_rtc_alarm_left);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_alarm_left_obj, 1, 2, machine_rtc_alarm_left);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_alarm_cancel(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t machine_rtc_alarm_cancel(size_t n_args, const mp_obj_t *args) {
|
||||
// only alarm id 0 is available
|
||||
if (n_args > 1 && mp_obj_get_int(args[1]) != 0) {
|
||||
mp_raise_OSError(MP_ENODEV);
|
||||
@@ -342,9 +342,9 @@ STATIC mp_obj_t machine_rtc_alarm_cancel(size_t n_args, const mp_obj_t *args) {
|
||||
machine_rtc_alarm_off(true);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_alarm_cancel_obj, 1, 2, machine_rtc_alarm_cancel);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_rtc_alarm_cancel_obj, 1, 2, machine_rtc_alarm_cancel);
|
||||
|
||||
STATIC mp_obj_t machine_rtc_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static mp_obj_t machine_rtc_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_trigger, ARG_handler, ARG_wake, ARG_hard };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_trigger, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
@@ -384,9 +384,9 @@ STATIC mp_obj_t machine_rtc_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
|
||||
return MP_OBJ_FROM_PTR(irq);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_rtc_irq_obj, 1, machine_rtc_irq);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(machine_rtc_irq_obj, 1, machine_rtc_irq);
|
||||
|
||||
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_datetime), MP_ROM_PTR(&machine_rtc_datetime_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_now), MP_ROM_PTR(&machine_rtc_now_obj) },
|
||||
@@ -398,7 +398,7 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&machine_rtc_irq_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ALARM0), MP_ROM_INT(0) },
|
||||
};
|
||||
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,
|
||||
|
||||
@@ -44,19 +44,19 @@
|
||||
enum { SDCARD_INIT_ARG_ID };
|
||||
|
||||
|
||||
STATIC const mp_arg_t sdcard_init_allowed_args[] = {
|
||||
static const mp_arg_t sdcard_init_allowed_args[] = {
|
||||
[SDCARD_INIT_ARG_ID] = { MP_QSTR_id, MP_ARG_INT, {.u_int = 1} },
|
||||
};
|
||||
|
||||
|
||||
STATIC void machine_sdcard_init_helper(mimxrt_sdcard_obj_t *self) {
|
||||
static void machine_sdcard_init_helper(mimxrt_sdcard_obj_t *self) {
|
||||
sdcard_init(self, 198000000UL); // Initialize SDCard Host with 198MHz base clock
|
||||
sdcard_init_pins(self);
|
||||
|
||||
ticks_delay_us64(2ULL * 1000ULL); // Wait 2ms to allow USDHC signals to settle/debounce
|
||||
}
|
||||
|
||||
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_map_init_fixed_table(&kw_args, n_kw, all_args + n_args);
|
||||
|
||||
@@ -81,7 +81,7 @@ STATIC mp_obj_t sdcard_obj_make_new(const mp_obj_type_t *type, size_t n_args, si
|
||||
}
|
||||
|
||||
// init()
|
||||
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) {
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
|
||||
if (!sdcard_state_initialized(self)) {
|
||||
@@ -89,18 +89,18 @@ STATIC mp_obj_t machine_sdcard_init(size_t n_args, const mp_obj_t *pos_args, mp_
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
sdcard_deinit(self);
|
||||
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);
|
||||
|
||||
// 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;
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE);
|
||||
@@ -111,16 +111,16 @@ 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);
|
||||
|
||||
// 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) {
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return mp_obj_new_bool(sdcard_detect(self));
|
||||
}
|
||||
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) {
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
if (sdcard_detect(self) && sdcard_state_initialized(self)) {
|
||||
@@ -136,10 +136,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);
|
||||
|
||||
// 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;
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE);
|
||||
@@ -150,10 +150,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) {
|
||||
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_int_t cmd = mp_obj_get_int(cmd_in);
|
||||
|
||||
@@ -200,9 +200,9 @@ STATIC mp_obj_t machine_sdcard_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t
|
||||
}
|
||||
}
|
||||
}
|
||||
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) },
|
||||
@@ -212,7 +212,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,
|
||||
|
||||
@@ -78,8 +78,8 @@ typedef struct _iomux_table_t {
|
||||
uint32_t configRegister;
|
||||
} iomux_table_t;
|
||||
|
||||
STATIC const uint8_t spi_index_table[] = MICROPY_HW_SPI_INDEX;
|
||||
STATIC LPSPI_Type *spi_base_ptr_table[] = LPSPI_BASE_PTRS;
|
||||
static const uint8_t spi_index_table[] = MICROPY_HW_SPI_INDEX;
|
||||
static LPSPI_Type *spi_base_ptr_table[] = LPSPI_BASE_PTRS;
|
||||
static const iomux_table_t iomux_table[] = {
|
||||
IOMUX_TABLE_SPI
|
||||
};
|
||||
@@ -118,7 +118,7 @@ bool lpspi_set_iomux(int8_t spi, uint8_t drive, int8_t cs) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void machine_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
static void machine_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
static const char *firstbit_str[] = {"MSB", "LSB"};
|
||||
machine_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_printf(print, "SPI(%u, baudrate=%u, polarity=%u, phase=%u, bits=%u, firstbit=%s, gap_ns=%d)",
|
||||
@@ -193,7 +193,7 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
STATIC void machine_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_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_gap_ns };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
|
||||
@@ -236,7 +236,7 @@ STATIC void machine_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj
|
||||
LPSPI_MasterInit(self->spi_inst, self->master_config, BOARD_BOOTCLOCKRUN_LPSPI_CLK_ROOT);
|
||||
}
|
||||
|
||||
STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
|
||||
static void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
|
||||
machine_spi_obj_t *self = (machine_spi_obj_t *)self_in;
|
||||
|
||||
if (len > 0) {
|
||||
@@ -255,7 +255,7 @@ STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8
|
||||
}
|
||||
}
|
||||
|
||||
STATIC const mp_machine_spi_p_t machine_spi_p = {
|
||||
static const mp_machine_spi_p_t machine_spi_p = {
|
||||
.init = machine_spi_init,
|
||||
.transfer = machine_spi_transfer,
|
||||
};
|
||||
|
||||
@@ -73,8 +73,8 @@ typedef struct _iomux_table_t {
|
||||
uint32_t configRegister;
|
||||
} iomux_table_t;
|
||||
|
||||
STATIC const uint8_t uart_index_table[] = MICROPY_HW_UART_INDEX;
|
||||
STATIC LPUART_Type *uart_base_ptr_table[] = LPUART_BASE_PTRS;
|
||||
static const uint8_t uart_index_table[] = MICROPY_HW_UART_INDEX;
|
||||
static LPUART_Type *uart_base_ptr_table[] = LPUART_BASE_PTRS;
|
||||
static const iomux_table_t iomux_table_uart[] = {
|
||||
IOMUX_TABLE_UART
|
||||
};
|
||||
@@ -82,9 +82,9 @@ static const iomux_table_t iomux_table_uart_cts_rts[] = {
|
||||
IOMUX_TABLE_UART_CTS_RTS
|
||||
};
|
||||
|
||||
STATIC const char *_parity_name[] = {"None", "", "0", "1"}; // Is defined as 0, 2, 3
|
||||
STATIC const char *_invert_name[] = {"None", "INV_TX", "INV_RX", "INV_TX|INV_RX"};
|
||||
STATIC const char *_flow_name[] = {"None", "RTS", "CTS", "RTS|CTS"};
|
||||
static const char *_parity_name[] = {"None", "", "0", "1"}; // Is defined as 0, 2, 3
|
||||
static const char *_invert_name[] = {"None", "INV_TX", "INV_RX", "INV_TX|INV_RX"};
|
||||
static const char *_flow_name[] = {"None", "RTS", "CTS", "RTS|CTS"};
|
||||
|
||||
#define RX (iomux_table_uart[index + 1])
|
||||
#define TX (iomux_table_uart[index])
|
||||
@@ -171,7 +171,7 @@ void machine_uart_set_baudrate(mp_obj_t uart_in, uint32_t baudrate) {
|
||||
{ MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_INT(UART_HWCONTROL_CTS) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_INT(UART_HWCONTROL_RTS) }, \
|
||||
|
||||
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);
|
||||
mp_printf(print, "UART(%u, baudrate=%u, bits=%u, parity=%s, stop=%u, flow=%s, "
|
||||
"rxbuf=%d, txbuf=%d, timeout=%u, timeout_char=%u, invert=%s)",
|
||||
@@ -182,7 +182,7 @@ STATIC void mp_machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_
|
||||
_invert_name[self->invert]);
|
||||
}
|
||||
|
||||
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) {
|
||||
enum { ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_flow,
|
||||
ARG_timeout, ARG_timeout_char, ARG_invert, ARG_rxbuf, ARG_txbuf};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
@@ -338,7 +338,7 @@ STATIC void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_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) {
|
||||
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) {
|
||||
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
||||
// Get UART bus.
|
||||
@@ -372,21 +372,21 @@ STATIC mp_obj_t mp_machine_uart_make_new(const mp_obj_type_t *type, size_t n_arg
|
||||
}
|
||||
|
||||
// uart.deinit()
|
||||
STATIC void mp_machine_uart_deinit(machine_uart_obj_t *self) {
|
||||
static void mp_machine_uart_deinit(machine_uart_obj_t *self) {
|
||||
LPUART_SoftwareReset(self->lpuart);
|
||||
}
|
||||
|
||||
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) {
|
||||
machine_uart_ensure_active(self);
|
||||
size_t count = LPUART_TransferGetRxRingBufferLength(self->lpuart, &self->handle);
|
||||
return count;
|
||||
}
|
||||
|
||||
STATIC bool mp_machine_uart_txdone(machine_uart_obj_t *self) {
|
||||
static bool mp_machine_uart_txdone(machine_uart_obj_t *self) {
|
||||
return self->tx_status == kStatus_LPUART_TxIdle;
|
||||
}
|
||||
|
||||
STATIC void mp_machine_uart_sendbreak(machine_uart_obj_t *self) {
|
||||
static void mp_machine_uart_sendbreak(machine_uart_obj_t *self) {
|
||||
machine_uart_ensure_active(self);
|
||||
self->lpuart->CTRL |= 1 << LPUART_CTRL_SBK_SHIFT; // Set SBK bit
|
||||
self->lpuart->CTRL &= ~LPUART_CTRL_SBK_MASK; // Clear SBK bit
|
||||
@@ -401,7 +401,7 @@ void machine_uart_deinit_all(void) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
uint64_t t = ticks_us64() + (uint64_t)self->timeout * 1000;
|
||||
uint64_t timeout_char_us = (uint64_t)self->timeout_char * 1000;
|
||||
@@ -436,7 +436,7 @@ STATIC mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
|
||||
return size;
|
||||
}
|
||||
|
||||
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);
|
||||
lpuart_transfer_t xfer;
|
||||
uint64_t t;
|
||||
@@ -496,7 +496,7 @@ STATIC mp_uint_t mp_machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_
|
||||
return size;
|
||||
}
|
||||
|
||||
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 = self_in;
|
||||
mp_uint_t ret;
|
||||
if (request == MP_STREAM_POLL) {
|
||||
|
||||
@@ -36,9 +36,9 @@ typedef struct _machine_wdt_obj_t {
|
||||
mp_obj_base_t base;
|
||||
} machine_wdt_obj_t;
|
||||
|
||||
STATIC const machine_wdt_obj_t machine_wdt = {{&machine_wdt_type}};
|
||||
static const machine_wdt_obj_t machine_wdt = {{&machine_wdt_type}};
|
||||
|
||||
STATIC machine_wdt_obj_t *mp_machine_wdt_make_new_instance(mp_int_t id, mp_int_t timeout_ms) {
|
||||
static machine_wdt_obj_t *mp_machine_wdt_make_new_instance(mp_int_t id, mp_int_t timeout_ms) {
|
||||
// Verify the WDT id.
|
||||
if (id != 0) {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("WDT(%d) doesn't exist"), id);
|
||||
@@ -59,12 +59,12 @@ STATIC machine_wdt_obj_t *mp_machine_wdt_make_new_instance(mp_int_t id, mp_int_t
|
||||
return (machine_wdt_obj_t *)&machine_wdt;
|
||||
}
|
||||
|
||||
STATIC void mp_machine_wdt_feed(machine_wdt_obj_t *self) {
|
||||
static void mp_machine_wdt_feed(machine_wdt_obj_t *self) {
|
||||
(void)self;
|
||||
WDOG_Refresh(WDOG1);
|
||||
}
|
||||
|
||||
STATIC void mp_machine_wdt_timeout_ms_set(machine_wdt_obj_t *self, mp_int_t timeout_ms) {
|
||||
static void mp_machine_wdt_timeout_ms_set(machine_wdt_obj_t *self, mp_int_t timeout_ms) {
|
||||
(void)self;
|
||||
|
||||
// confine to the valid range
|
||||
|
||||
@@ -42,11 +42,11 @@ typedef struct _mimxrt_flash_obj_t {
|
||||
uint32_t flash_size;
|
||||
} mimxrt_flash_obj_t;
|
||||
|
||||
STATIC mimxrt_flash_obj_t mimxrt_flash_obj = {
|
||||
static mimxrt_flash_obj_t mimxrt_flash_obj = {
|
||||
.base = { &mimxrt_flash_type }
|
||||
};
|
||||
|
||||
STATIC mp_obj_t mimxrt_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 mimxrt_flash_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
// Check args.
|
||||
mp_arg_check_num(n_args, n_kw, 0, 0, false);
|
||||
|
||||
@@ -62,7 +62,7 @@ STATIC mp_obj_t mimxrt_flash_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
|
||||
// readblocks(block_num, buf, [offset])
|
||||
// read size of buffer number of bytes from block (with offset) into buffer
|
||||
STATIC mp_obj_t mimxrt_flash_readblocks(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t mimxrt_flash_readblocks(size_t n_args, const mp_obj_t *args) {
|
||||
mimxrt_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
|
||||
@@ -76,13 +76,13 @@ STATIC mp_obj_t mimxrt_flash_readblocks(size_t n_args, const mp_obj_t *args) {
|
||||
flash_read_block((self->flash_base + offset), (uint8_t *)bufinfo.buf, (uint32_t)bufinfo.len);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mimxrt_flash_readblocks_obj, 3, 4, mimxrt_flash_readblocks);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mimxrt_flash_readblocks_obj, 3, 4, mimxrt_flash_readblocks);
|
||||
|
||||
// writeblocks(block_num, buf, [offset])
|
||||
// Erase block based on block_num and write buffer size number of bytes from buffer into block. If additional offset
|
||||
// parameter is provided only write operation at block start + offset will be performed.
|
||||
// This requires a prior erase operation of the block!
|
||||
STATIC mp_obj_t mimxrt_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t mimxrt_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
|
||||
status_t status;
|
||||
mimxrt_flash_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
mp_buffer_info_t bufinfo;
|
||||
@@ -110,10 +110,10 @@ STATIC mp_obj_t mimxrt_flash_writeblocks(size_t n_args, const mp_obj_t *args) {
|
||||
|
||||
return MP_OBJ_NEW_SMALL_INT(status != kStatus_Success);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mimxrt_flash_writeblocks_obj, 3, 4, mimxrt_flash_writeblocks);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mimxrt_flash_writeblocks_obj, 3, 4, mimxrt_flash_writeblocks);
|
||||
|
||||
// ioctl(op, arg)
|
||||
STATIC mp_obj_t mimxrt_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
|
||||
static mp_obj_t mimxrt_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t arg_in) {
|
||||
mimxrt_flash_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_int_t cmd = mp_obj_get_int(cmd_in);
|
||||
status_t status;
|
||||
@@ -137,14 +137,14 @@ STATIC mp_obj_t mimxrt_flash_ioctl(mp_obj_t self_in, mp_obj_t cmd_in, mp_obj_t a
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mimxrt_flash_ioctl_obj, mimxrt_flash_ioctl);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_3(mimxrt_flash_ioctl_obj, mimxrt_flash_ioctl);
|
||||
|
||||
STATIC const mp_rom_map_elem_t mimxrt_flash_locals_dict_table[] = {
|
||||
static const mp_rom_map_elem_t mimxrt_flash_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&mimxrt_flash_readblocks_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&mimxrt_flash_writeblocks_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ioctl), MP_ROM_PTR(&mimxrt_flash_ioctl_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mimxrt_flash_locals_dict, mimxrt_flash_locals_dict_table);
|
||||
static MP_DEFINE_CONST_DICT(mimxrt_flash_locals_dict, mimxrt_flash_locals_dict_table);
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mimxrt_flash_type,
|
||||
|
||||
@@ -76,20 +76,20 @@ typedef enum {
|
||||
MP_SOFT_RESET
|
||||
} reset_reason_t;
|
||||
|
||||
STATIC mp_obj_t mp_machine_unique_id(void) {
|
||||
static mp_obj_t mp_machine_unique_id(void) {
|
||||
unsigned char id[8];
|
||||
mp_hal_get_unique_id(id);
|
||||
return mp_obj_new_bytes(id, sizeof(id));
|
||||
}
|
||||
|
||||
NORETURN STATIC void mp_machine_reset(void) {
|
||||
NORETURN static void mp_machine_reset(void) {
|
||||
WDOG_TriggerSystemSoftwareReset(WDOG1);
|
||||
while (true) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_int_t mp_machine_reset_cause(void) {
|
||||
static mp_int_t mp_machine_reset_cause(void) {
|
||||
#ifdef MIMXRT117x_SERIES
|
||||
uint32_t user_reset_flag = kSRC_M7CoreIppUserResetFlag;
|
||||
#else
|
||||
@@ -110,23 +110,23 @@ STATIC mp_int_t mp_machine_reset_cause(void) {
|
||||
return reset_cause;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_machine_get_freq(void) {
|
||||
static mp_obj_t mp_machine_get_freq(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_hal_get_cpu_freq());
|
||||
}
|
||||
|
||||
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(NULL);
|
||||
}
|
||||
|
||||
STATIC void mp_machine_idle(void) {
|
||||
static void mp_machine_idle(void) {
|
||||
MICROPY_EVENT_POLL_HOOK;
|
||||
}
|
||||
|
||||
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) {
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
}
|
||||
|
||||
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_int_t seconds = mp_obj_get_int(args[0]) / 1000;
|
||||
if (seconds > 0) {
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
#include "py/runtime.h"
|
||||
#include "modmimxrt.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t mimxrt_module_globals_table[] = {
|
||||
static const mp_rom_map_elem_t mimxrt_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_mimxrt) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&mimxrt_flash_type) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mimxrt_module_globals, mimxrt_module_globals_table);
|
||||
static MP_DEFINE_CONST_DICT(mimxrt_module_globals, mimxrt_module_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_mimxrt = {
|
||||
.base = { &mp_type_module },
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
static bool initialized = false;
|
||||
|
||||
#if defined(MIMXRT117x_SERIES)
|
||||
STATIC caam_handle_t caam_handle;
|
||||
STATIC caam_rng_state_handle_t caam_state_handle = kCAAM_RngStateHandle0;
|
||||
static caam_handle_t caam_handle;
|
||||
static caam_rng_state_handle_t caam_state_handle = kCAAM_RngStateHandle0;
|
||||
|
||||
#if defined(FSL_FEATURE_HAS_L1CACHE) || defined(__DCACHE_PRESENT)
|
||||
AT_NONCACHEABLE_SECTION(static caam_job_ring_interface_t s_jrif0);
|
||||
@@ -52,7 +52,7 @@ AT_NONCACHEABLE_SECTION(static caam_job_ring_interface_t s_jrif0);
|
||||
static caam_job_ring_interface_t s_jrif0;
|
||||
#endif
|
||||
|
||||
STATIC void trng_start(void) {
|
||||
static void trng_start(void) {
|
||||
caam_config_t config;
|
||||
|
||||
if (!initialized) {
|
||||
@@ -71,7 +71,7 @@ void trng_random_data(unsigned char *output, size_t len) {
|
||||
|
||||
#else
|
||||
|
||||
STATIC void trng_start(void) {
|
||||
static void trng_start(void) {
|
||||
trng_config_t trngConfig;
|
||||
|
||||
if (!initialized) {
|
||||
@@ -99,7 +99,7 @@ uint32_t trng_random_u32(void) {
|
||||
}
|
||||
|
||||
#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);
|
||||
@@ -109,5 +109,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
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "fsl_snvs_lp.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.
|
||||
snvs_lp_srtc_datetime_t t;
|
||||
SNVS_LP_SRTC_GetDatetime(SNVS, &t);
|
||||
@@ -48,7 +48,7 @@ STATIC mp_obj_t mp_time_localtime_get(void) {
|
||||
}
|
||||
|
||||
// Return the number of seconds since the Epoch.
|
||||
STATIC mp_obj_t mp_time_time_get(void) {
|
||||
static mp_obj_t mp_time_time_get(void) {
|
||||
snvs_lp_srtc_datetime_t t;
|
||||
SNVS_LP_SRTC_GetDatetime(SNVS, &t);
|
||||
// EPOCH is 1970 for this port, which leads to the following trouble:
|
||||
|
||||
@@ -46,10 +46,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();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,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();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,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();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include CPU_HEADER_H
|
||||
|
||||
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), 0, 0};
|
||||
|
||||
uint8_t cdc_itf_pending; // keep track of cdc interfaces which need attention to poll
|
||||
|
||||
@@ -55,7 +55,7 @@ u32_t sys_now(void) {
|
||||
return mp_hal_ticks_ms();
|
||||
}
|
||||
|
||||
STATIC void pyb_lwip_poll(void) {
|
||||
static void pyb_lwip_poll(void) {
|
||||
// Run the lwIP internal updates
|
||||
sys_check_timeouts();
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@ typedef struct _network_lan_obj_t {
|
||||
} network_lan_obj_t;
|
||||
|
||||
|
||||
STATIC const network_lan_obj_t network_lan_eth0 = { { &network_lan_type }, ð_instance0 };
|
||||
static const network_lan_obj_t network_lan_eth0 = { { &network_lan_type }, ð_instance0 };
|
||||
#if defined(ENET_DUAL_PORT)
|
||||
STATIC const network_lan_obj_t network_lan_eth1 = { { &network_lan_type }, ð_instance1 };
|
||||
static const network_lan_obj_t network_lan_eth1 = { { &network_lan_type }, ð_instance1 };
|
||||
#endif
|
||||
|
||||
STATIC void network_lan_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
static void network_lan_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
struct netif *netif = eth_netif(self->eth);
|
||||
int status = eth_link_status(self->eth);
|
||||
@@ -74,7 +74,7 @@ STATIC void network_lan_print(const mp_print_t *print, mp_obj_t self_in, mp_prin
|
||||
);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t network_lan_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 network_lan_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
enum { ARG_id, ARG_phy_type, ARG_phy_addr, ARG_ref_clk_mode};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_id, MP_ARG_INT, {.u_int = 0} },
|
||||
@@ -148,7 +148,7 @@ STATIC mp_obj_t network_lan_make_new(const mp_obj_type_t *type, size_t n_args, s
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t network_lan_active(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_lan_active(size_t n_args, const mp_obj_t *args) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
if (n_args == 1) {
|
||||
return mp_obj_new_bool(eth_link_status(self->eth));
|
||||
@@ -165,21 +165,21 @@ STATIC mp_obj_t network_lan_active(size_t n_args, const mp_obj_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_lan_active_obj, 1, 2, network_lan_active);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_lan_active_obj, 1, 2, network_lan_active);
|
||||
|
||||
STATIC mp_obj_t network_lan_isconnected(mp_obj_t self_in) {
|
||||
static mp_obj_t network_lan_isconnected(mp_obj_t self_in) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return mp_obj_new_bool(eth_link_status(self->eth) == 3);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(network_lan_isconnected_obj, network_lan_isconnected);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(network_lan_isconnected_obj, network_lan_isconnected);
|
||||
|
||||
STATIC mp_obj_t network_lan_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_lan_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
return mod_network_nic_ifconfig(eth_netif(self->eth), n_args - 1, args + 1);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_lan_ifconfig_obj, 1, 2, network_lan_ifconfig);
|
||||
|
||||
STATIC mp_obj_t network_lan_status(size_t n_args, const mp_obj_t *args) {
|
||||
static mp_obj_t network_lan_status(size_t n_args, const mp_obj_t *args) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
(void)self;
|
||||
|
||||
@@ -190,9 +190,9 @@ STATIC mp_obj_t network_lan_status(size_t n_args, const mp_obj_t *args) {
|
||||
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("unknown status param"));
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_lan_status_obj, 1, 2, network_lan_status);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_lan_status_obj, 1, 2, network_lan_status);
|
||||
|
||||
STATIC mp_obj_t network_lan_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
static mp_obj_t network_lan_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||
network_lan_obj_t *self = MP_OBJ_TO_PTR(args[0]);
|
||||
|
||||
if (kwargs->used == 0) {
|
||||
@@ -235,9 +235,9 @@ STATIC mp_obj_t network_lan_config(size_t n_args, const mp_obj_t *args, mp_map_t
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(network_lan_config_obj, 1, network_lan_config);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_KW(network_lan_config_obj, 1, network_lan_config);
|
||||
|
||||
STATIC const mp_rom_map_elem_t network_lan_locals_dict_table[] = {
|
||||
static const mp_rom_map_elem_t network_lan_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_active), MP_ROM_PTR(&network_lan_active_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_isconnected), MP_ROM_PTR(&network_lan_isconnected_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ifconfig), MP_ROM_PTR(&network_lan_ifconfig_obj) },
|
||||
@@ -252,7 +252,7 @@ STATIC const mp_rom_map_elem_t network_lan_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_IN), MP_ROM_INT(PHY_TX_CLK_IN) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OUT), MP_ROM_INT(PHY_TX_CLK_OUT) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(network_lan_locals_dict, network_lan_locals_dict_table);
|
||||
static MP_DEFINE_CONST_DICT(network_lan_locals_dict, network_lan_locals_dict_table);
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
network_lan_type,
|
||||
|
||||
Reference in New Issue
Block a user