mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
update use old stm32 to stm32f1
This commit is contained in:
parent
9aa06359c2
commit
bce5c1fb98
@ -314,7 +314,7 @@
|
|||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
<Optim>5</Optim>
|
<Optim>2</Optim>
|
||||||
<oTime>0</oTime>
|
<oTime>0</oTime>
|
||||||
<SplitLS>0</SplitLS>
|
<SplitLS>0</SplitLS>
|
||||||
<OneElfS>1</OneElfS>
|
<OneElfS>1</OneElfS>
|
||||||
@ -333,7 +333,7 @@
|
|||||||
<v6LangP>3</v6LangP>
|
<v6LangP>3</v6LangP>
|
||||||
<vShortEn>1</vShortEn>
|
<vShortEn>1</vShortEn>
|
||||||
<vShortWch>1</vShortWch>
|
<vShortWch>1</vShortWch>
|
||||||
<v6Lto>1</v6Lto>
|
<v6Lto>0</v6Lto>
|
||||||
<v6WtE>0</v6WtE>
|
<v6WtE>0</v6WtE>
|
||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
@ -669,6 +669,26 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\pikascript\pikascript-api\STM32F1-api.c</FilePath>
|
<FilePath>..\pikascript\pikascript-api\STM32F1-api.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_ADC-api.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-api\STM32F1_ADC-api.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_IIC-api.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-api\STM32F1_IIC-api.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_PWM-api.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-api\STM32F1_PWM-api.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_UART-api.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-api\STM32F1_UART-api.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@ -684,6 +704,26 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_GPIO.c</FilePath>
|
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_GPIO.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_IIC.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_IIC.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_PWM.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_PWM.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_UART.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_UART.c</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>STM32F1_ADC.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\pikascript\pikascript-lib\STM32F1\STM32F1_ADC.c</FilePath>
|
||||||
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>STM32F1_Time.c</FileName>
|
<FileName>STM32F1_Time.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
@ -741,8 +781,8 @@
|
|||||||
<RTE>
|
<RTE>
|
||||||
<apis/>
|
<apis/>
|
||||||
<components>
|
<components>
|
||||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.3.0" condition="ARMv6_7_8-M Device">
|
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
|
||||||
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.6.0"/>
|
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="stm32f103c8"/>
|
<targetInfo name="stm32f103c8"/>
|
||||||
</targetInfos>
|
</targetInfos>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pikascript-core==v1.2.6
|
pikascript-core==v1.2.6
|
||||||
PikaStdLib==v1.2.1
|
PikaStdLib==v1.2.1
|
||||||
PikaStdDevice==v1.4.3
|
PikaStdDevice==v1.4.3
|
||||||
STM32F1==v1.0.1
|
STM32F1==latest
|
||||||
STM32F103C8Booter==v1.0.0
|
STM32F103C8Booter==v1.0.0
|
@ -38,62 +38,61 @@ class Time(PikaStdDevice.Time):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# class ADC(PikaStdDevice.ADC):
|
class ADC(PikaStdDevice.ADC):
|
||||||
# # override
|
# override
|
||||||
# def platformEnable():
|
def platformEnable():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformRead():
|
def platformRead():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# class UART(PikaStdDevice.UART):
|
class UART(PikaStdDevice.UART):
|
||||||
# # override
|
# override
|
||||||
# def platformEnable():
|
def platformEnable():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformWrite():
|
def platformWrite():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformRead():
|
def platformRead():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# class PWM(PikaStdDevice.PWM):
|
class PWM(PikaStdDevice.PWM):
|
||||||
# # override
|
# override
|
||||||
# def platformEnable():
|
def platformEnable():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformSetFrequency():
|
def platformSetFrequency():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformSetDuty():
|
def platformSetDuty():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# class IIC(PikaStdDevice.IIC):
|
class IIC(PikaStdDevice.IIC):
|
||||||
# SCL = GPIO()
|
SCL = GPIO()
|
||||||
# SDA = GPIO()
|
SDA = GPIO()
|
||||||
# # override
|
# override
|
||||||
|
|
||||||
# def platformEnable():
|
def platformEnable():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformWrite():
|
def platformWrite():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# # override
|
# override
|
||||||
# def platformRead():
|
def platformRead():
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class lowLevel(TinyObj):
|
class lowLevel(TinyObj):
|
||||||
def readPin(pin: str) -> int:
|
def readPin(pin: str) -> int:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -2,47 +2,47 @@
|
|||||||
#include "BaseObj.h"
|
#include "BaseObj.h"
|
||||||
#include "STM32F1_common.h"
|
#include "STM32F1_common.h"
|
||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
#include "stm32f1xx_ll_gpio.h"
|
|
||||||
|
|
||||||
void STM32F1_GPIO_platformDisable(PikaObj* self) {
|
void STM32F1_GPIO_platformDisable(PikaObj* self) {
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
char* mode = obj_getStr(self, "mode");
|
char* mode = obj_getStr(self, "mode");
|
||||||
|
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
|
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
|
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio pin.");
|
obj_setSysOut(self, "[error] not match gpio pin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_GPIO_DeInit(gpioPort,gpioPin);
|
HAL_GPIO_DeInit(gpioPort, gpioPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STM32F1_GPIO_platformEnable(PikaObj* self) {
|
void STM32F1_GPIO_platformEnable(PikaObj* self) {
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
char* mode = obj_getStr(self, "mode");
|
char* mode = obj_getStr(self, "mode");
|
||||||
|
|
||||||
if (0 != GPIO_enable_clock(pin)) {
|
if (0 != enableClk(pin)) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
|
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
|
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
@ -50,18 +50,18 @@ void STM32F1_GPIO_platformEnable(PikaObj* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
LL_GPIO_ResetOutputPin(gpioPort, gpioPin);
|
HAL_GPIO_WritePin(gpioPort, gpioPin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
uint32_t pinMode = getPinMode(mode);
|
uint32_t pinMode = getPinMode(mode);
|
||||||
|
|
||||||
uint32_t gpioPull = GPIO_NOPULL;
|
uint32_t gpioPull = GPIO_NOPULL;
|
||||||
char* pull = obj_getStr(self, "pull");
|
char *pull = obj_getStr(self, "pull");
|
||||||
if (strEqu(pull, "up")) {
|
if(strEqu(pull, "up")){
|
||||||
gpioPull = GPIO_PULLUP;
|
gpioPull = GPIO_PULLUP;
|
||||||
} else if (strEqu(pull, "down")) {
|
}else if(strEqu(pull, "down")){
|
||||||
gpioPull = GPIO_PULLDOWN;
|
gpioPull = GPIO_PULLDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
/*Configure GPIO*/
|
/*Configure GPIO*/
|
||||||
GPIO_InitStruct.Pin = gpioPin;
|
GPIO_InitStruct.Pin = gpioPin;
|
||||||
@ -72,61 +72,55 @@ void STM32F1_GPIO_platformEnable(PikaObj* self) {
|
|||||||
}
|
}
|
||||||
void STM32F1_GPIO_platformLow(PikaObj* self) {
|
void STM32F1_GPIO_platformLow(PikaObj* self) {
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
|
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
|
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio pin.");
|
obj_setSysOut(self, "[error] not match gpio pin.");
|
||||||
}
|
}
|
||||||
|
HAL_GPIO_WritePin(gpioPort, gpioPin, GPIO_PIN_RESET);
|
||||||
WRITE_REG(gpioPort->BSRR, (uint32_t)gpioPin << 16U);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void STM32F1_GPIO_platformHigh(PikaObj* self) {
|
void STM32F1_GPIO_platformHigh(PikaObj* self) {
|
||||||
|
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
|
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
|
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio pin.");
|
obj_setSysOut(self, "[error] not match gpio pin.");
|
||||||
}
|
}
|
||||||
|
HAL_GPIO_WritePin(gpioPort, gpioPin, GPIO_PIN_SET);
|
||||||
WRITE_REG(gpioPort->BSRR, gpioPin);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STM32F1_GPIO_platformSetMode(PikaObj* self) {
|
void STM32F1_GPIO_platformSetMode(PikaObj* self) {
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
char* mode = obj_getStr(self, "mode");
|
char *mode = obj_getStr(self, "mode");
|
||||||
if (0 != GPIO_enable_clock(pin)) {
|
if (0 != enableClk(pin)) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
|
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
|
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
@ -134,7 +128,7 @@ void STM32F1_GPIO_platformSetMode(PikaObj* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
LL_GPIO_ResetOutputPin(gpioPort, gpioPin);
|
HAL_GPIO_WritePin(gpioPort, gpioPin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
uint32_t pinMode = getPinMode(mode);
|
uint32_t pinMode = getPinMode(mode);
|
||||||
|
|
||||||
@ -147,31 +141,31 @@ void STM32F1_GPIO_platformSetMode(PikaObj* self) {
|
|||||||
HAL_GPIO_Init(gpioPort, &GPIO_InitStruct);
|
HAL_GPIO_Init(gpioPort, &GPIO_InitStruct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STM32F1_GPIO_platformRead(PikaObj* self) {
|
void STM32F1_GPIO_platformRead(PikaObj *self){
|
||||||
char* pin = obj_getStr(self, "pin");
|
char* pin = obj_getStr(self, "pin");
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio pin.");
|
obj_setSysOut(self, "[error] not match gpio pin.");
|
||||||
}
|
}
|
||||||
obj_setInt(self, "readBuff", LL_GPIO_IsInputPinSet(gpioPort, gpioPin));
|
obj_setInt(self, "readBuff", HAL_GPIO_ReadPin(gpioPort,gpioPin));
|
||||||
}
|
}
|
||||||
|
|
||||||
int STM32F1_lowLevel_readPin(PikaObj* self, char* pin) {
|
int STM32F1_lowLevel_readPin(PikaObj *self, char * pin){
|
||||||
GPIO_TypeDef* gpioPort = GPIO_get_Group(pin);
|
GPIO_TypeDef* gpioPort = getGpioPort(pin);
|
||||||
if (NULL == gpioPort) {
|
if (NULL == gpioPort) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio port.");
|
obj_setSysOut(self, "[error] not match gpio port.");
|
||||||
}
|
}
|
||||||
uint16_t gpioPin = GPIO_get_pin(pin);
|
uint16_t gpioPin = getGpioPin(pin);
|
||||||
if (0 == gpioPin) {
|
if (0 == gpioPin) {
|
||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
obj_setSysOut(self, "[error] not match gpio pin.");
|
obj_setSysOut(self, "[error] not match gpio pin.");
|
||||||
}
|
}
|
||||||
return LL_GPIO_IsInputPinSet(gpioPort, gpioPin);
|
return HAL_GPIO_ReadPin(gpioPort,gpioPin);
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "BaseObj.h"
|
#include "BaseObj.h"
|
||||||
#include "STM32F1_common.h"
|
|
||||||
|
|
||||||
|
#include "STM32F1_common.h"
|
||||||
|
|
||||||
void STM32F1_Time_sleep_ms(PikaObj* self, int ms) {
|
void STM32F1_Time_sleep_ms(PikaObj* self, int ms) {
|
||||||
HAL_Delay(ms);
|
HAL_Delay(ms);
|
||||||
@ -10,4 +10,4 @@ void STM32F1_Time_sleep_s(PikaObj* self, int s) {
|
|||||||
for (int i = 0; i < s; i++) {
|
for (int i = 0; i < s; i++) {
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,52 @@
|
|||||||
#include "STM32F1_common.h"
|
#include "STM32F1_common.h"
|
||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
|
|
||||||
GPIO_TypeDef* GPIO_get_Group(char* pin) {
|
void __platformDisableIrqHandle(){
|
||||||
|
__disable_irq();
|
||||||
|
}
|
||||||
|
void __platformEnableIrqHandle(){
|
||||||
|
__enable_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
void delay_unit(uint32_t delays) {
|
||||||
|
/* one unit is 1/64 us */
|
||||||
|
uint32_t startval, tickn, wait;
|
||||||
|
|
||||||
|
startval = SysTick->VAL;
|
||||||
|
tickn = HAL_GetTick();
|
||||||
|
if (delays > startval) {
|
||||||
|
while (HAL_GetTick() == tickn) {
|
||||||
|
}
|
||||||
|
wait = 64000 + startval - delays;
|
||||||
|
while (wait < SysTick->VAL) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wait = startval - delays;
|
||||||
|
while (wait < SysTick->VAL && HAL_GetTick() == tickn) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void delay_us(uint32_t udelay) {
|
||||||
|
uint32_t startval, tickn, delays, wait;
|
||||||
|
|
||||||
|
startval = SysTick->VAL;
|
||||||
|
tickn = HAL_GetTick();
|
||||||
|
delays = udelay * 64; // delay 1us when delays = 64
|
||||||
|
if (delays > startval) {
|
||||||
|
while (HAL_GetTick() == tickn) {
|
||||||
|
}
|
||||||
|
wait = 64000 + startval - delays;
|
||||||
|
while (wait < SysTick->VAL) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wait = startval - delays;
|
||||||
|
while (wait < SysTick->VAL && HAL_GetTick() == tickn) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GPIO_TypeDef* getGpioPort(char* pin) {
|
||||||
if (strIsStartWith(pin, "PA")) {
|
if (strIsStartWith(pin, "PA")) {
|
||||||
return GPIOA;
|
return GPIOA;
|
||||||
}
|
}
|
||||||
@ -17,7 +62,7 @@ GPIO_TypeDef* GPIO_get_Group(char* pin) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t GPIO_get_pin(char* pin) {
|
uint16_t getGpioPin(char* pin) {
|
||||||
Args* buffs = New_strBuff();
|
Args* buffs = New_strBuff();
|
||||||
uint16_t gpioPin = 0;
|
uint16_t gpioPin = 0;
|
||||||
|
|
||||||
@ -102,7 +147,7 @@ uint32_t getPinMode(char* mode) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GPIO_enable_clock(char* pin) {
|
uint8_t enableClk(char* pin) {
|
||||||
if (strIsStartWith(pin, "PA")) {
|
if (strIsStartWith(pin, "PA")) {
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
return 0;
|
return 0;
|
||||||
@ -120,4 +165,4 @@ uint8_t GPIO_enable_clock(char* pin) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
@ -1,19 +1,13 @@
|
|||||||
#ifndef __STM32F1__COMMON__H
|
#ifndef __STM32__COMMON__H
|
||||||
#define __STM32F1__COMMON__H
|
#define __STM32__COMMON__H
|
||||||
#include "PikaObj.h"
|
#include "PikaObj.h"
|
||||||
#include "main.h"
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "stm32f1xx_hal.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* support std lib for stm32 */
|
/* support std lib for stm32 */
|
||||||
|
#define delay_ms HAL_Delay
|
||||||
#undef u16
|
typedef uint16_t u16;
|
||||||
#undef u8
|
typedef uint8_t u8;
|
||||||
#undef u32
|
typedef uint32_t u32;
|
||||||
#define u16 uint16_t
|
|
||||||
#define u8 uint8_t
|
|
||||||
#define u32 uint32_t
|
|
||||||
|
|
||||||
#define GPIO_Pin_0 GPIO_PIN_0
|
#define GPIO_Pin_0 GPIO_PIN_0
|
||||||
#define GPIO_Pin_1 GPIO_PIN_1
|
#define GPIO_Pin_1 GPIO_PIN_1
|
||||||
@ -32,7 +26,8 @@
|
|||||||
#define GPIO_Pin_14 GPIO_PIN_14
|
#define GPIO_Pin_14 GPIO_PIN_14
|
||||||
#define GPIO_Pin_15 GPIO_PIN_15
|
#define GPIO_Pin_15 GPIO_PIN_15
|
||||||
|
|
||||||
|
#ifdef STM32F103xB
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
#define UART1_EXIST
|
#define UART1_EXIST
|
||||||
#define UART2_EXIST
|
#define UART2_EXIST
|
||||||
#define UART3_EXIST
|
#define UART3_EXIST
|
||||||
@ -41,24 +36,46 @@
|
|||||||
#define TIM2_EXIST
|
#define TIM2_EXIST
|
||||||
#define TIM3_EXIST
|
#define TIM3_EXIST
|
||||||
#define TIM4_EXIST
|
#define TIM4_EXIST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct pika_IIC_info_t {
|
|
||||||
GPIO_TypeDef* SCL_GPIO;
|
|
||||||
GPIO_TypeDef* SDA_GPIO;
|
|
||||||
|
|
||||||
uint32_t SCL_GPIO_Pin;
|
|
||||||
uint32_t SDA_GPIO_Pin;
|
|
||||||
uint8_t deviceAddr;
|
|
||||||
|
|
||||||
uint8_t readBuff[32];
|
|
||||||
} pika_IIC_info;
|
|
||||||
|
|
||||||
GPIO_TypeDef* GPIO_get_Group(char* pin);
|
|
||||||
uint16_t GPIO_get_pin(char* pin);
|
|
||||||
uint32_t getPinMode(char* mode);
|
|
||||||
uint8_t GPIO_enable_clock(char* pin);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define RX_BUFF_LENGTH 64
|
||||||
|
|
||||||
|
#define FLASH_SCRIPT_START_ADDR (FLASH_BASE + ((FLASH_PAGE_NB - 2) * FLASH_PAGE_SIZE))
|
||||||
|
#define FLASH_SCRIPT_END_ADDR (FLASH_BASE + FLASH_SIZE - 1)
|
||||||
|
|
||||||
|
#define FLASH_PIKA_ASM_START_ADDR FLASH_SCRIPT_START_ADDR
|
||||||
|
#define FLASH_PIKA_ASM_END_ADDR FLASH_SCRIPT_END_ADDR
|
||||||
|
|
||||||
|
uint32_t GetPage(uint32_t Addr);
|
||||||
|
#define DATA_64 ((uint64_t)0x1234567812345678)
|
||||||
|
#define DATA_32 ((uint32_t)0x12345678)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UART_HandleTypeDef huart;
|
||||||
|
uint8_t id;
|
||||||
|
char rxBuff[RX_BUFF_LENGTH];
|
||||||
|
uint16_t rxBuffOffset;
|
||||||
|
PikaObj* obj;
|
||||||
|
} pika_uart_t;
|
||||||
|
|
||||||
|
typedef struct _CodeHeap{
|
||||||
|
char *content;
|
||||||
|
uint32_t size;
|
||||||
|
uint8_t ena;
|
||||||
|
uint32_t reciveTime;
|
||||||
|
|
||||||
|
uint32_t oldSize;
|
||||||
|
}CodeHeap;
|
||||||
|
|
||||||
|
GPIO_TypeDef* getGpioPort(char* pin);
|
||||||
|
uint16_t getGpioPin(char* pin);
|
||||||
|
uint32_t getPinMode(char* mode);
|
||||||
|
uint8_t enableClk(char* pin);
|
||||||
|
void delay_us(uint32_t delay);
|
||||||
|
void delay_unit(uint32_t delay);
|
||||||
|
void STM32_UART_clearRxBuff(pika_uart_t* pika_uart);
|
||||||
|
uint8_t STM32_Code_reciveHandler(char *data, uint32_t rxSize);
|
||||||
|
void STM32_Code_Init();
|
||||||
|
void STM32_Code_flashHandler();
|
||||||
|
void HARDWARE_PRINTF_Init();
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user