mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
update package for bsp/f103
This commit is contained in:
parent
58c906e2e1
commit
80725a1551
@ -645,6 +645,11 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\pikascript\pikascript-core\TinyObj.c</FilePath>
|
<FilePath>..\pikascript\pikascript-core\TinyObj.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>pikaPlatform.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-core\pikaPlatform.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
Binary file not shown.
@ -723,10 +723,10 @@ void obj_run(PikaObj* self, char* cmd) {
|
|||||||
obj_setSysOut(self, sysOut);
|
obj_setSysOut(self, sysOut);
|
||||||
obj_setErrorCode(self, errcode);
|
obj_setErrorCode(self, errcode);
|
||||||
if (!strEqu("", sysOut)) {
|
if (!strEqu("", sysOut)) {
|
||||||
printf("%s\r\n", sysOut);
|
__platformPrintf("%s\r\n", sysOut);
|
||||||
}
|
}
|
||||||
if (0 != errcode) {
|
if (0 != errcode) {
|
||||||
printf("[info] input commond: %s\r\n", cmd);
|
__platformPrintf("[info] input commond: %s\r\n", cmd);
|
||||||
while (1)
|
while (1)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
PikaMemInfo pikaMemInfo = {0};
|
PikaMemInfo pikaMemInfo = {0};
|
||||||
|
|
||||||
__attribute__((weak)) void __pikaDisableIrqHandle(){
|
|
||||||
/* disable irq to support thread */
|
|
||||||
}
|
|
||||||
__attribute__((weak)) void __pikaEnableIrqHandle(){
|
|
||||||
/* disable irq to support thread */
|
|
||||||
}
|
|
||||||
void* pikaMalloc(uint32_t size) {
|
void* pikaMalloc(uint32_t size) {
|
||||||
pikaMemInfo.heapUsed += size;
|
pikaMemInfo.heapUsed += size;
|
||||||
if (pikaMemInfo.heapUsedMax < pikaMemInfo.heapUsed) {
|
if (pikaMemInfo.heapUsedMax < pikaMemInfo.heapUsed) {
|
||||||
pikaMemInfo.heapUsedMax = pikaMemInfo.heapUsed;
|
pikaMemInfo.heapUsedMax = pikaMemInfo.heapUsed;
|
||||||
}
|
}
|
||||||
__pikaDisableIrqHandle();
|
__platformDisableIrqHandle();
|
||||||
void* mem = malloc(size);
|
void* mem = __platformMalloc(size);
|
||||||
__pikaEnableIrqHandle();
|
__platformEnableIrqHandle();
|
||||||
if (NULL == mem) {
|
if (NULL == mem) {
|
||||||
printf("[error]: No heap space! Please reset the device.\r\n");
|
__platformPrintf("[error]: No heap space! Please reset the device.\r\n");
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,9 +25,9 @@ void* pikaMalloc(uint32_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pikaFree(void* mem, uint32_t size) {
|
void pikaFree(void* mem, uint32_t size) {
|
||||||
__pikaDisableIrqHandle();
|
__platformDisableIrqHandle();
|
||||||
free(mem);
|
__platformFree(mem);
|
||||||
__pikaEnableIrqHandle();
|
__platformEnableIrqHandle();
|
||||||
pikaMemInfo.heapUsed -= size;
|
pikaMemInfo.heapUsed -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "pikaPlatform.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t heapUsed;
|
uint32_t heapUsed;
|
||||||
|
29
bsp/stm32f103c8/pikascript/pikascript-core/pikaPlatform.c
Normal file
29
bsp/stm32f103c8/pikascript/pikascript-core/pikaPlatform.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "pikaPlatform.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
PIKA_WEAK void __platformDisableIrqHandle() {
|
||||||
|
/* disable irq to support thread */
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK void __platformEnableIrqHandle() {
|
||||||
|
/* disable irq to support thread */
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK void* __platformMalloc(size_t size) {
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK void __platformFree(void* ptr) {
|
||||||
|
return free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK void __platformPrintf(char* fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
char sysOut[128] = {0};
|
||||||
|
vprintf(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
19
bsp/stm32f103c8/pikascript/pikascript-core/pikaPlatform.h
Normal file
19
bsp/stm32f103c8/pikascript/pikascript-core/pikaPlatform.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __PIKA_PALTFORM__H
|
||||||
|
#define __PIKA_PALTFORM__H
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
|
||||||
|
#define PIKA_WEAK __attribute__((weak))
|
||||||
|
#elif defined(__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
|
||||||
|
#define PIKA_WEAK __weak
|
||||||
|
#elif defined(__GNUC__) /* GNU GCC Compiler */
|
||||||
|
#define PIKA_WEAK __attribute__((weak))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void __platformPrintf(char* fmt, ...);
|
||||||
|
void* __platformMalloc(size_t size);
|
||||||
|
void __platformFree(void* ptr);
|
||||||
|
void __platformEnableIrqHandle();
|
||||||
|
void __platformDisableIrqHandle();
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,13 @@
|
|||||||
#include "STM32_common.h"
|
#include "STM32_common.h"
|
||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
|
|
||||||
|
void __platformDisableIrqHandle(){
|
||||||
|
__disable_irq();
|
||||||
|
}
|
||||||
|
void __platformEnableIrqHandle(){
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
|
||||||
void delay_unit(uint32_t delays) {
|
void delay_unit(uint32_t delays) {
|
||||||
/* one unit is 1/64 us */
|
/* one unit is 1/64 us */
|
||||||
uint32_t startval, tickn, wait;
|
uint32_t startval, tickn, wait;
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
#define UART2_EXIST
|
#define UART2_EXIST
|
||||||
#define UART3_EXIST
|
#define UART3_EXIST
|
||||||
#define UART4_EXIST
|
#define UART4_EXIST
|
||||||
|
|
||||||
|
#define TIM1_EXIST
|
||||||
|
#define TIM3_EXIST
|
||||||
|
#define TIM14_EXIST
|
||||||
|
#define TIM16_EXIST
|
||||||
|
#define TIM17_EXIST
|
||||||
|
#define Code_ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STM32F103xB
|
#ifdef STM32F103xB
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pikascript-core==latest
|
pikascript-core==v0.8.3
|
||||||
PikaStdLib==v1.0.1
|
PikaStdLib==latest
|
||||||
PikaStdDevice==v1.3.0
|
PikaStdDevice==v1.3.0
|
||||||
STM32==v1.0.1
|
STM32==v1.0.2
|
Loading…
x
Reference in New Issue
Block a user