30 lines
795 B
C
Raw Normal View History

2021-09-09 08:40:13 +08:00
#include "PikaStdDevice_ADC.h"
2021-09-10 17:51:53 +08:00
#include "BaseObj.h"
2021-09-09 08:40:13 +08:00
2021-09-10 17:51:53 +08:00
void PikaStdDevice_ADC_enable(PikaObj* self) {
obj_run(self, "platformEnable(pin)");
2021-09-09 08:40:13 +08:00
}
2021-09-10 17:51:53 +08:00
void PikaStdDevice_ADC_init(PikaObj* self) {
obj_setStr(self, "pin", "PA0");
2021-09-09 08:40:13 +08:00
}
2021-09-10 17:51:53 +08:00
float PikaStdDevice_ADC_read(PikaObj* self) {
obj_run(self, "val = platformRead(pin)");
return obj_getFloat(self, "val");
2021-09-09 08:40:13 +08:00
}
2021-09-10 17:51:53 +08:00
void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) {
obj_setStr(self, "pin", pin);
2021-09-09 08:40:13 +08:00
}
2021-09-10 17:51:53 +08:00
void PikaStdDevice_ADC_platformEnable(PikaObj* self, char* pin) {
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
2021-09-09 08:40:13 +08:00
}
2021-09-10 17:51:53 +08:00
float PikaStdDevice_ADC_platformRead(PikaObj* self, char* pin) {
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
return -1;
2021-09-09 08:40:13 +08:00
}