mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
#include "PikaStdDevice_UART.h"
|
|
#include "BaseObj.h"
|
|
|
|
void PikaStdDevice_UART_enable(PikaObj* self) {
|
|
obj_run(self, "platformEnable()");
|
|
}
|
|
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);
|
|
obj_run(self, "platformRead()");
|
|
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);
|
|
obj_run(self, "platformWrite()");
|
|
}
|
|
|
|
void PikaStdDevice_UART_platformEnable(PikaObj* self) {
|
|
obj_setErrorCode(self, 1);
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
}
|
|
void PikaStdDevice_UART_platformRead(PikaObj* self) {
|
|
obj_setErrorCode(self, 1);
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
}
|
|
void PikaStdDevice_UART_platformWrite(PikaObj* self) {
|
|
obj_setErrorCode(self, 1);
|
|
obj_setSysOut(self, "[error] platform method need to be override.");
|
|
}
|