Skip to content

Commit a6b792f

Browse files
committed
Added 'machine.PWM' module
updated 'machine.Timer' module
1 parent 1b9a10a commit a6b792f

File tree

18 files changed

+785
-92
lines changed

18 files changed

+785
-92
lines changed

.cproject

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@
231231

232232
<buildCommand>${PWD}/k210-freertos/BUILD.sh</buildCommand>
233233

234+
<buildArguments/>
235+
234236
<stopOnError>true</stopOnError>
235237

236238
<useDefaultCommand>false</useDefaultCommand>
@@ -243,8 +245,6 @@
243245

244246
<buildCommand>${PWD}/k210-freertos/CLEAN.sh</buildCommand>
245247

246-
<buildArguments/>
247-
248248
<stopOnError>true</stopOnError>
249249

250250
<useDefaultCommand>false</useDefaultCommand>
@@ -259,8 +259,6 @@
259259

260260
<buildArguments>-v</buildArguments>
261261

262-
<buildTarget/>
263-
264262
<stopOnError>true</stopOnError>
265263

266264
<useDefaultCommand>false</useDefaultCommand>
@@ -275,8 +273,6 @@
275273

276274
<buildArguments>-j8</buildArguments>
277275

278-
<buildTarget/>
279-
280276
<stopOnError>true</stopOnError>
281277

282278
<useDefaultCommand>false</useDefaultCommand>
@@ -291,6 +287,20 @@
291287

292288
<buildArguments>-v -j8</buildArguments>
293289

290+
<stopOnError>true</stopOnError>
291+
292+
<useDefaultCommand>false</useDefaultCommand>
293+
294+
<runAllBuilders>true</runAllBuilders>
295+
296+
</target>
297+
298+
<target name="BUILD_Fast &amp; Dump" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
299+
300+
<buildCommand>${PWD}/k210-freertos/BUILD.sh</buildCommand>
301+
302+
<buildArguments>-d -j8</buildArguments>
303+
294304
<buildTarget/>
295305

296306
<stopOnError>true</stopOnError>

firmware/MaixPy.bin

8 KB
Binary file not shown.

firmware/MaixPy.kfpkg

3.3 KB
Binary file not shown.

firmware/MaixPy_firmware.zip

11.8 KB
Binary file not shown.

firmware/MaixPy_sqlite.bin

4 KB
Binary file not shown.

firmware/MaixPy_sqlite.kfpkg

2.73 KB
Binary file not shown.

k210-freertos/mpy_support/mpconfigport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
#define MICROPY_HW_BOARD_NAME "Sipeed_board"
4242
#define MICROPY_HW_MCU_NAME "Kendryte-K210"
4343
#define MICROPY_PY_SYS_PLATFORM "K210/FreeRTOS"
44-
#define MICROPY_PY_LOBO_VERSION "1.11.9"
45-
#define MICROPY_PY_LOBO_VERSION_NUM (0x011109)
44+
#define MICROPY_PY_LOBO_VERSION "1.11.10"
45+
#define MICROPY_PY_LOBO_VERSION_NUM (0x011110)
4646

4747
#define MICROPY_PY_USE_LOG_COLORS (1)
4848

k210-freertos/mpy_support/standard_lib/include/modmachine.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#define SYS_RESET_REASON_SOFT 3
5353
#define SYS_RESET_REASON_PWRON 4
5454

55+
#define TIMER_MAX_TIMERS 12
56+
5557
typedef enum _gpio_func_t
5658
{
5759
GPIO_FUNC_NONE,
@@ -95,6 +97,7 @@ typedef enum _gpio_func_as_t
9597
GPIO_USEDAS_DATA3,
9698
} gpio_pin_func_as_t;
9799

100+
98101
typedef struct _mp_fpioa_cfg_item
99102
{
100103
int8_t gpio;
@@ -103,13 +106,15 @@ typedef struct _mp_fpioa_cfg_item
103106
fpioa_function_t function;
104107
} __attribute__((aligned(8))) mp_fpioa_cfg_item_t;
105108

109+
106110
typedef struct _machine_pin_def_t {
107111
int8_t gpio;
108112
gpio_pin_func_t func;
109113
gpio_pin_func_as_t usedas;
110114
fpioa_function_t fpioa_func;
111115
} __attribute__((aligned(8))) machine_pin_def_t;
112116

117+
113118
typedef struct _machine_pin_obj_t {
114119
mp_obj_base_t base;
115120
int8_t pin;
@@ -131,6 +136,43 @@ typedef struct _machine_pin_obj_t {
131136
TaskHandle_t debounce_task;
132137
} __attribute__((aligned(8))) machine_pin_obj_t;
133138

139+
140+
typedef struct _machine_timer_obj_t {
141+
mp_obj_base_t base;
142+
uint8_t id; // timer number (0~11)
143+
uint8_t state; // current timer state
144+
uint8_t type; // timer type
145+
int8_t pin; // timer pin, if not used: -1
146+
int8_t pin_gpio;
147+
int8_t pin_mode;
148+
int8_t pin_pull;
149+
uint8_t reserved;
150+
handle_t handle; // hw timer handle
151+
bool repeat; // true for periodic type
152+
uint64_t period; // timer period in us
153+
int64_t remain; // remaining us until timer event
154+
uint32_t interval; // hw timer interval in nanoseconds
155+
double resolution; // hw timer resolution in nanoseconds
156+
uint64_t event_num; // number of timer events
157+
uint64_t cb_num; // number of scheduled timer callbacks
158+
mp_obj_t callback; // timer callback function
159+
} __attribute__((aligned(8))) machine_timer_obj_t;
160+
161+
162+
typedef struct _machine_pwm_obj_t {
163+
mp_obj_base_t base;
164+
handle_t handle; // hw pwm handle
165+
uint8_t channel;
166+
int8_t pin;
167+
bool active;
168+
bool invert;
169+
uint32_t perc;
170+
uint32_t periods;
171+
double freq;
172+
double dperc;
173+
} __attribute__((aligned(8))) machine_pwm_obj_t;
174+
175+
134176
typedef struct _mpy_flash_config_t {
135177
uint32_t ver;
136178
bool use_two_main_tasks;
@@ -152,6 +194,7 @@ typedef struct _mpy_config_t {
152194
uint32_t crc;
153195
} __attribute__((aligned(8))) mpy_config_t;
154196

197+
155198
enum term_colors_t {
156199
BLACK = 0,
157200
RED,
@@ -172,6 +215,7 @@ extern const char *gpiohs_funcs_in_use[15];
172215
extern const char *reset_reason[8];
173216
extern const char *term_colors[8];
174217
extern mpy_config_t mpy_config;
218+
extern void *mpy_timers_used[TIMER_MAX_TIMERS];
175219

176220
const char *term_color(enum term_colors_t color);
177221
bool mpy_config_crc(bool set);
@@ -197,5 +241,6 @@ extern const mp_obj_type_t machine_uart_type;
197241
extern const mp_obj_type_t machine_hw_i2c_type;
198242
extern const mp_obj_type_t machine_hw_spi_type;
199243
extern const mp_obj_type_t machine_timer_type;
244+
extern const mp_obj_type_t machine_pwm_type;
200245

201246
#endif // MICROPY_MODMACHINE_H

0 commit comments

Comments
 (0)