pikapython/package/PikaStdDevice/PikaStdDevice_UART.c

40 lines
1.3 KiB
C
Raw Normal View History

2021-10-01 20:00:15 +08:00
#include "PikaStdDevice_UART.h"
#include "BaseObj.h"
void PikaStdDevice_UART_enable(PikaObj* self) {
2021-11-14 19:40:06 +08:00
obj_run(self, "platformEnable()");
2021-10-01 20:00:15 +08:00
}
void PikaStdDevice_UART_init(PikaObj* self) {
obj_setInt(self, "baudRate", 115200);
obj_setInt(self, "id", 1);
obj_setStr(self, "readBuff", "");
}
char* PikaStdDevice_UART_read(PikaObj* self, int length) {
obj_setInt(self, "length", length);
2021-11-14 19:40:06 +08:00
obj_run(self, "platformRead()");
2021-10-01 20:00:15 +08:00
return obj_getStr(self, "readData");
}
void PikaStdDevice_UART_setBaudRate(PikaObj* self, int baudRate) {
obj_setInt(self, "baudRate", baudRate);
}
void PikaStdDevice_UART_setId(PikaObj* self, int id) {
obj_setInt(self, "id", id);
}
void PikaStdDevice_UART_write(PikaObj* self, char* data) {
obj_setStr(self, "writeData", data);
2021-11-14 19:40:06 +08:00
obj_run(self, "platformWrite()");
2021-10-01 20:00:15 +08:00
}
2021-11-14 19:40:06 +08:00
void PikaStdDevice_UART_platformEnable(PikaObj* self) {
2021-10-01 20:00:15 +08:00
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
}
2021-11-14 19:40:06 +08:00
void PikaStdDevice_UART_platformRead(PikaObj* self) {
2021-10-01 20:00:15 +08:00
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
}
2021-11-14 19:40:06 +08:00
void PikaStdDevice_UART_platformWrite(PikaObj* self) {
2021-10-01 20:00:15 +08:00
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override.");
2021-11-14 19:44:15 +08:00
}