add disable api for adc iic pwm and uart in std device

This commit is contained in:
lyon 2022-03-07 14:58:21 +08:00
parent 51117e29ce
commit 1878ea884f
5 changed files with 65 additions and 1 deletions

View File

@ -92,6 +92,9 @@ class ADC(TinyObj):
def enable(): def enable():
pass pass
def disable():
pass
def read() -> float: def read() -> float:
pass pass
@ -103,6 +106,10 @@ class ADC(TinyObj):
def platformRead(): def platformRead():
pass pass
# need override
def platformDisable():
pass
class UART(TinyObj): class UART(TinyObj):
def __init__(): def __init__():
@ -120,6 +127,9 @@ class UART(TinyObj):
def enable(): def enable():
pass pass
def disable():
pass
def write(data: str): def write(data: str):
pass pass
@ -138,6 +148,9 @@ class UART(TinyObj):
def platformRead(): def platformRead():
pass pass
# need override
def platformDisable():
pass
class IIC(TinyObj): class IIC(TinyObj):
def __init__(): def __init__():
@ -158,6 +171,9 @@ class IIC(TinyObj):
def enable(): def enable():
pass pass
def disable():
pass
def write(addr: int, data: str): def write(addr: int, data: str):
pass pass
@ -176,6 +192,9 @@ class IIC(TinyObj):
def platformRead(): def platformRead():
pass pass
# need override
def platformDisable():
pass
class PWM(TinyObj): class PWM(TinyObj):
def __init__(): def __init__():
@ -211,6 +230,9 @@ class PWM(TinyObj):
def enable(): def enable():
pass pass
def disable():
pass
def getFrequency() -> int: def getFrequency() -> int:
pass pass
@ -228,3 +250,7 @@ class PWM(TinyObj):
# need override # need override
def platformSetDuty(): def platformSetDuty():
pass pass
# need override
def platformDisable():
pass

View File

@ -5,6 +5,10 @@ void PikaStdDevice_ADC_enable(PikaObj* self) {
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
void PikaStdDevice_ADC_disable(PikaObj *self){
obj_run(self, "platformDisable()");
}
void PikaStdDevice_ADC_init(PikaObj* self) { void PikaStdDevice_ADC_init(PikaObj* self) {
obj_setStr(self, "pin", "PA0"); 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."); 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) { void PikaStdDevice_ADC_platformRead(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");

View File

@ -15,6 +15,10 @@ void PikaStdDevice_IIC_enable(PikaObj *self){
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
void PikaStdDevice_IIC_disable(PikaObj *self){
obj_run(self, "platformDisable()");
}
void PikaStdDevice_IIC_setDeviceAddr(PikaObj *self, int addr){ void PikaStdDevice_IIC_setDeviceAddr(PikaObj *self, int addr){
obj_setInt(self, "deviceAddr", 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."); 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){ void PikaStdDevice_IIC_platformRead(PikaObj *self){
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");

View File

@ -31,6 +31,10 @@ void PikaStdDevice_PWM_enable(PikaObj* self) {
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
void PikaStdDevice_PWM_disable(PikaObj *self){
obj_run(self, "platformDisable()");
}
float PikaStdDevice_PWM_getDuty(PikaObj* self) { float PikaStdDevice_PWM_getDuty(PikaObj* self) {
return obj_getFloat(self, "duty"); 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."); 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) { char* PikaStdDevice_PWM_getName(PikaObj* self) {
return obj_getStr(self, "name"); return obj_getStr(self, "name");
} }
@ -70,4 +79,4 @@ int PikaStdDevice_PWM_getChannel(PikaObj* self) {
void PikaStdDevice_PWM_setFreq(PikaObj* self, int freq) { void PikaStdDevice_PWM_setFreq(PikaObj* self, int freq) {
PikaStdDevice_PWM_setFrequency(self, freq); PikaStdDevice_PWM_setFrequency(self, freq);
} }

View File

@ -4,6 +4,11 @@
void PikaStdDevice_UART_enable(PikaObj* self) { void PikaStdDevice_UART_enable(PikaObj* self) {
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
void PikaStdDevice_UART_disable(PikaObj *self){
obj_run(self, "platformDisable()");
}
void PikaStdDevice_UART_init(PikaObj* self) { void PikaStdDevice_UART_init(PikaObj* self) {
obj_setInt(self, "baudRate", 115200); obj_setInt(self, "baudRate", 115200);
obj_setInt(self, "id", 1); obj_setInt(self, "id", 1);
@ -42,3 +47,9 @@ void PikaStdDevice_UART_platformWrite(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); 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.");
}