mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add disable api for adc iic pwm and uart in std device
This commit is contained in:
parent
51117e29ce
commit
1878ea884f
@ -92,6 +92,9 @@ class ADC(TinyObj):
|
||||
def enable():
|
||||
pass
|
||||
|
||||
def disable():
|
||||
pass
|
||||
|
||||
def read() -> float:
|
||||
pass
|
||||
|
||||
@ -103,6 +106,10 @@ class ADC(TinyObj):
|
||||
def platformRead():
|
||||
pass
|
||||
|
||||
# need override
|
||||
def platformDisable():
|
||||
pass
|
||||
|
||||
|
||||
class UART(TinyObj):
|
||||
def __init__():
|
||||
@ -120,6 +127,9 @@ class UART(TinyObj):
|
||||
def enable():
|
||||
pass
|
||||
|
||||
def disable():
|
||||
pass
|
||||
|
||||
def write(data: str):
|
||||
pass
|
||||
|
||||
@ -138,6 +148,9 @@ class UART(TinyObj):
|
||||
def platformRead():
|
||||
pass
|
||||
|
||||
# need override
|
||||
def platformDisable():
|
||||
pass
|
||||
|
||||
class IIC(TinyObj):
|
||||
def __init__():
|
||||
@ -158,6 +171,9 @@ class IIC(TinyObj):
|
||||
def enable():
|
||||
pass
|
||||
|
||||
def disable():
|
||||
pass
|
||||
|
||||
def write(addr: int, data: str):
|
||||
pass
|
||||
|
||||
@ -176,6 +192,9 @@ class IIC(TinyObj):
|
||||
def platformRead():
|
||||
pass
|
||||
|
||||
# need override
|
||||
def platformDisable():
|
||||
pass
|
||||
|
||||
class PWM(TinyObj):
|
||||
def __init__():
|
||||
@ -211,6 +230,9 @@ class PWM(TinyObj):
|
||||
def enable():
|
||||
pass
|
||||
|
||||
def disable():
|
||||
pass
|
||||
|
||||
def getFrequency() -> int:
|
||||
pass
|
||||
|
||||
@ -228,3 +250,7 @@ class PWM(TinyObj):
|
||||
# need override
|
||||
def platformSetDuty():
|
||||
pass
|
||||
|
||||
# need override
|
||||
def platformDisable():
|
||||
pass
|
||||
|
@ -5,6 +5,10 @@ void PikaStdDevice_ADC_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_disable(PikaObj *self){
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_init(PikaObj* self) {
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
}
|
||||
@ -27,6 +31,11 @@ void PikaStdDevice_ADC_platformEnable(PikaObj* self) {
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_platformDisable(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_platformRead(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
|
@ -15,6 +15,10 @@ void PikaStdDevice_IIC_enable(PikaObj *self){
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC_disable(PikaObj *self){
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC_setDeviceAddr(PikaObj *self, int addr){
|
||||
obj_setInt(self, "deviceAddr", addr);
|
||||
}
|
||||
@ -50,6 +54,11 @@ void PikaStdDevice_IIC_platformEnable(PikaObj *self){
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC_platformDisable(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_IIC_platformRead(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
|
@ -31,6 +31,10 @@ void PikaStdDevice_PWM_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM_disable(PikaObj *self){
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
float PikaStdDevice_PWM_getDuty(PikaObj* self) {
|
||||
return obj_getFloat(self, "duty");
|
||||
}
|
||||
@ -52,6 +56,11 @@ void PikaStdDevice_PWM_platformSetFrequency(PikaObj* self) {
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM_platformDisable(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
char* PikaStdDevice_PWM_getName(PikaObj* self) {
|
||||
return obj_getStr(self, "name");
|
||||
}
|
||||
@ -70,4 +79,4 @@ int PikaStdDevice_PWM_getChannel(PikaObj* self) {
|
||||
|
||||
void PikaStdDevice_PWM_setFreq(PikaObj* self, int freq) {
|
||||
PikaStdDevice_PWM_setFrequency(self, freq);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,11 @@
|
||||
void PikaStdDevice_UART_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_UART_disable(PikaObj *self){
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_UART_init(PikaObj* self) {
|
||||
obj_setInt(self, "baudRate", 115200);
|
||||
obj_setInt(self, "id", 1);
|
||||
@ -42,3 +47,9 @@ void PikaStdDevice_UART_platformWrite(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_UART_platformDisable(PikaObj *self){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user