2021-09-08 21:25:52 +08:00
|
|
|
#include "BaseObj.h"
|
|
|
|
#include "PikaStdDevice_GPIO.h"
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_init(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setInt(self, "isEnable", 0);
|
|
|
|
obj_setStr(self, "pin", "PA0");
|
|
|
|
obj_setStr(self, "mode", "out");
|
|
|
|
obj_setInt(self, "isOn", 0);
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_disable(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setInt(self, "isEnable", 0);
|
|
|
|
obj_run(self, "platformDisable()");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_enable(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setInt(self, "isEnable", 1);
|
|
|
|
obj_run(self, "platformEnable()");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
char *PikaStdDevice_GPIO_getMode(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
return obj_getStr(self, "mode");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
char *PikaStdDevice_GPIO_getPin(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
return obj_getStr(self, "pin");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PikaStdDevice_GPIO_low(PikaObj *self)
|
|
|
|
{
|
|
|
|
obj_setInt(self, "isOn", 0);
|
|
|
|
obj_run(self, "platformLow()");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_high(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setInt(self, "isOn", 1);
|
|
|
|
obj_run(self, "platformHigh()");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_setMode(PikaObj *self, char *mode){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setStr(self, "mode", mode);
|
|
|
|
obj_run(self, "platformSetMode(mode)");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_setPin(PikaObj *self, char *pinName){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setStr(self, "pin", pinName);
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformDisable(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformEnable(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformLow(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformHigh(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformSetMode(PikaObj *self, char *mode){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformOff(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|
|
|
|
|
2021-09-09 08:40:13 +08:00
|
|
|
void PikaStdDevice_GPIO_platformOn(PikaObj *self){
|
2021-09-08 21:25:52 +08:00
|
|
|
obj_setErrorCode(self, 1);
|
|
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
|
|
}
|