Merge pull request #1889 from openmv/refactor_common_header

misc: Rename common header.
This commit is contained in:
Ibrahim Abdelkader 2023-07-04 13:57:39 +03:00 committed by GitHub
commit d85935e787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 97 additions and 105 deletions

View File

@ -16,7 +16,7 @@
#include <string.h>
#include <stdbool.h>
#include "common.h"
#include "omv_common.h"
#include "omv_gpio.h"
#include "omv_spi.h"

View File

@ -14,7 +14,7 @@
#include <stdint.h>
#include <errno.h>
#include "winc.h"
#include "common.h"
#include "omv_common.h"
// WINC's includes
#include "driver/include/nmasic.h"

View File

@ -18,7 +18,7 @@
#include "py/mphal.h"
#include "dma_alloc.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
typedef union block block_t;
union block {

View File

@ -14,7 +14,7 @@
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
#include "common.h"
#include "omv_common.h"
#include "fb_alloc.h"
#include "ff_wrapper.h"
#define FF_MIN(x, y) (((x) < (y))?(x):(y))

View File

@ -16,7 +16,7 @@
#include "vospi.h"
#include "crc16.h"
#include "common.h"
#include "omv_common.h"
#include "omv_spi.h"
#define VOSPI_LINE_PIXELS (80)

View File

@ -11,7 +11,7 @@
#include <arm_math.h>
#include "fb_alloc.h"
#include "ff_wrapper.h"
#include "common.h"
#include "omv_common.h"
#include "fft.h"
// http://processors.wiki.ti.com/index.php/Efficient_FFT_Computation_of_Real_Input

View File

@ -9,7 +9,7 @@
* Fast approximate math functions.
*/
#include "fmath.h"
#include "common.h"
#include "omv_common.h"
#define M_PI 3.14159265f
#define M_PI_2 1.57079632f

View File

@ -13,7 +13,7 @@
#include <stdint.h>
#include "imlib.h"
#include "mutex.h"
#include "common.h"
#include "omv_common.h"
// DMA Buffers need to be aligned by cache lines or 16 bytes.
#ifndef __DCACHE_PRESENT

View File

@ -16,7 +16,7 @@
#include "array.h"
#include "ff_wrapper.h"
#include "imlib.h"
#include "common.h"
#include "omv_common.h"
#include "omv_boardconfig.h"
void imlib_init_all() {

View File

@ -20,7 +20,7 @@
#include "mimxrt_hal.h"
#include "omv_boardconfig.h"
#include "omv_gpio.h"
#include "common.h"
#include "omv_common.h"
#define IOMUXC_SET_REG(base, reg, val) *((volatile uint32_t *) ((((uint32_t) base) << 16) | reg)) = (val)

View File

@ -20,7 +20,7 @@
#include CLOCK_CONFIG_H
#include "mimxrt_hal.h"
#include "common.h"
#include "omv_common.h"
#include "omv_spi.h"
typedef struct dma_descr {

View File

@ -21,7 +21,7 @@
#include "py_helper.h"
#include "fb_alloc.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
#include "nrfx_pdm.h"
#include "hal/nrf_gpio.h"
@ -45,13 +45,13 @@ static int16_t PDM_BUFFERS[2][PDM_BUFFER_SIZE];
static mp_sched_node_t audio_task_sched_node;
static void audio_task_callback(mp_sched_node_t *node);
static void nrfx_pdm_event_handler(nrfx_pdm_evt_t const *evt)
{
static void nrfx_pdm_event_handler(nrfx_pdm_evt_t const *evt) {
if (evt->error == NRFX_PDM_NO_ERROR) {
if (evt->buffer_requested) {
if (evt->buffer_released == PDM_BUFFERS[0]) {
nrfx_pdm_buffer_set(PDM_BUFFERS[1], PDM_BUFFER_SIZE);
} else { // NULL (first buffer request) or second buffer is full.
} else {
// NULL (first buffer request) or second buffer is full.
nrfx_pdm_buffer_set(PDM_BUFFERS[0], PDM_BUFFER_SIZE);
}
}
@ -64,8 +64,7 @@ static void nrfx_pdm_event_handler(nrfx_pdm_evt_t const *evt)
}
}
static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
{
static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// Read Args.
g_channels = py_helper_keyword_int(n_args, args, 0, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_channels), 2);
uint32_t frequency = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_frequency), 16000);
@ -125,8 +124,7 @@ static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
return mp_const_none;
}
void py_audio_deinit()
{
void py_audio_deinit() {
// Disable PDM and IRQ
nrfx_pdm_uninit();
@ -141,15 +139,13 @@ void py_audio_deinit()
g_audio_callback = mp_const_none;
}
static void audio_task_callback(mp_sched_node_t *node)
{
static void audio_task_callback(mp_sched_node_t *node) {
memcpy(g_pcmbuf->items, PDM_BUFFERS[g_buf_index], PDM_BUFFER_SIZE * sizeof(int16_t));
// Call user callback
mp_call_function_1(g_audio_callback, MP_OBJ_FROM_PTR(g_pcmbuf));
}
static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj)
{
static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj) {
g_audio_callback = callback_obj;
if (!mp_obj_is_callable(g_audio_callback)) {
@ -166,8 +162,7 @@ static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj)
return mp_const_none;
}
static mp_obj_t py_audio_stop_streaming()
{
static mp_obj_t py_audio_stop_streaming() {
// Stop PDM.
nrfx_pdm_stop();
g_audio_callback = mp_const_none;

View File

@ -14,7 +14,7 @@
#include "omv_boardconfig.h"
#include "omv_i2c.h"
#include "common.h"
#include "omv_common.h"
#define I2C_TIMEOUT (1000)
#define I2C_SCAN_TIMEOUT (100)

View File

@ -71,8 +71,7 @@ static mp_sched_node_t audio_task_sched_node;
static volatile bool audio_task_scheduled = false;
static bool irq_handler_installed = false;
static void audio_task_callback(mp_sched_node_t *node)
{
static void audio_task_callback(mp_sched_node_t *node) {
if (audio_data->streaming == false) {
audio_task_scheduled = false;
return;
@ -100,8 +99,7 @@ static void audio_task_callback(mp_sched_node_t *node)
}
}
static void dma_irq_handler()
{
static void dma_irq_handler() {
if (dma_irqn_get_channel_status(PDM_DMA, audio_data->dma_channel)) {
// Clear the interrupt request.
dma_irqn_acknowledge_channel(PDM_DMA, audio_data->dma_channel);
@ -147,9 +145,10 @@ static void dma_irq_handler()
}
}
static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
{
enum { ARG_channels, ARG_frequency, ARG_gain_db, ARG_buffers, ARG_overflow, ARG_clkdiv };
static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum {
ARG_channels, ARG_frequency, ARG_gain_db, ARG_buffers, ARG_overflow, ARG_clkdiv
};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_channels, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
{ MP_QSTR_frequency, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = PDM_DEFAULT_FREQ} },
@ -287,20 +286,17 @@ static mp_obj_t py_audio_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *k
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_audio_init_obj, 0, py_audio_init);
static mp_obj_t py_audio_samples()
{
static mp_obj_t py_audio_samples() {
return mp_obj_new_int(audio_data->t_samples);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_audio_samples_obj, py_audio_samples);
static mp_obj_t py_audio_overflow()
{
static mp_obj_t py_audio_overflow() {
return mp_obj_new_bool(audio_data->overflow);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_audio_overflow_obj, py_audio_overflow);
static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj)
{
static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj) {
audio_data->head = 0;
audio_data->tail = 0;
#if PDM_TIME_CONV
@ -327,8 +323,7 @@ static mp_obj_t py_audio_start_streaming(mp_obj_t callback_obj)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_audio_start_streaming_obj, py_audio_start_streaming);
static mp_obj_t py_audio_stop_streaming()
{
static mp_obj_t py_audio_stop_streaming() {
if (audio_data->streaming) {
// Disable PDM and IRQ
dma_channel_abort(audio_data->dma_channel);
@ -347,7 +342,9 @@ static mp_obj_t py_audio_stop_streaming()
audio_data->streaming = false;
for (mp_uint_t start = mp_hal_ticks_ms();
audio_task_scheduled && (mp_hal_ticks_ms() - start) < 1500;
mp_hal_delay_ms(10));
mp_hal_delay_ms(10)) {
;
}
#if PDM_TIME_CONV
mp_printf(&mp_plat_print, "Average conversion time:%ld us\n",
@ -359,9 +356,10 @@ static mp_obj_t py_audio_stop_streaming()
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_audio_stop_streaming_obj, py_audio_stop_streaming);
static mp_obj_t py_audio_get_buffer(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
{
enum { ARG_timeout };
static mp_obj_t py_audio_get_buffer(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum {
ARG_timeout
};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
};
@ -399,8 +397,7 @@ static mp_obj_t py_audio_get_buffer(uint n_args, const mp_obj_t *pos_args, mp_ma
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_audio_get_buffer_obj, 0, py_audio_get_buffer);
void py_audio_deinit()
{
void py_audio_deinit() {
if (audio_initialized) {
py_audio_stop_streaming();
audio_data->head = 0;

View File

@ -12,7 +12,7 @@
#include "py/mphal.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
#include "dma_utils.h"
// Defined in micropython/ports/stm32/dma.c

View File

@ -23,7 +23,7 @@
#include "pdm2pcm_glo.h"
#include "fb_alloc.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
#include "dma_utils.h"
#if MICROPY_PY_AUDIO

View File

@ -22,7 +22,7 @@
#include "omv_boardconfig.h"
#include "libtf.h"
#include "py_tf.h"
#include "common.h"
#include "omv_common.h"
#if MICROPY_PY_MICRO_SPEECH
#define kMaxAudioSampleSize (512)

View File

@ -22,7 +22,7 @@
#include "extmod/modnetwork.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "common.h"
#include "omv_common.h"
#include "py_helper.h"
#include "ff_wrapper.h"

View File

@ -14,7 +14,7 @@
#include "py/mphal.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
#include "omv_gpio.h"
#include "omv_i2c.h"

View File

@ -16,7 +16,7 @@
#include "omv_boardconfig.h"
#include "irq.h"
#include "common.h"
#include "omv_common.h"
#include "dma_utils.h"
#include "omv_spi.h"

View File

@ -13,7 +13,7 @@
#include "imlib.h"
#include "irq.h"
#include "omv_boardconfig.h"
#include "common.h"
#include "omv_common.h"
// Define pin objects in this file.
#define OMV_GPIO_DEFINE_PINS (1)
#include "omv_gpio.h"

View File

@ -15,7 +15,7 @@
#include "sensor.h"
#include "vospi.h"
#include "py/mphal.h"
#include "common.h"
#include "omv_common.h"
#include "omv_gpio.h"
#include "omv_i2c.h"
#include "framebuffer.h"