!231 PikaStdDevice_v2.3.7_1682943025402

Merge pull request !231 from pikabot/PikaStdDevice_v2.3.7_1682943025402
This commit is contained in:
李昂 2023-05-01 12:13:23 +00:00 committed by Gitee
commit f928281a6a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 39 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include "PikaStdDevice_UART.h"
#include "PikaStdDevice_common.h"
#include "pika_hal.h"
void PikaStdDevice_UART_enable(PikaObj* self) {
obj_runNativeMethod(self, "platformEnable", NULL);
@ -39,6 +40,7 @@ void PikaStdDevice_UART_init(PikaObj* self) {
obj_setInt(self, "dataBits", 8);
obj_setInt(self, "parity", PIKA_HAL_UART_PARITY_NONE);
obj_setInt(self, "stopBits", PIKA_HAL_UART_STOP_BITS_1);
obj_setInt(self, "enabled", 0);
}
void PikaStdDevice_UART___init__(PikaObj* self) {
@ -57,24 +59,52 @@ Arg* PikaStdDevice_UART_readBytes(PikaObj* self, int length) {
return arg_copy(obj_getArg(self, "readData"));
}
int _config_update(PikaObj* self, pika_hal_UART_config* cfg){
if (obj_getInt(self, "enabled")) {
pika_debug("UART %s config update.\r\n", obj_getStr(self, "id"));
int err = pika_hal_ioctl(obj_getPtr(self, "pika_dev"),
PIKA_HAL_IOCTL_CONFIG, cfg);
if (err == 0) {
return 0;
}
pika_debug("UART %s config update failed.\r\n", obj_getStr(self, "id"));
}
return -1;
}
void PikaStdDevice_UART_setBaudRate(PikaObj* self, int baudRate) {
obj_setInt(self, "baudRate", baudRate);
pika_hal_UART_config cfg = {0};
cfg.baudrate = baudRate;
_config_update(self, &cfg);
}
void PikaStdDevice_UART_setFlowControl(PikaObj* self, int flowControl) {
obj_setInt(self, "flowControl", flowControl);
pika_hal_UART_config cfg = {0};
cfg.flow_control = flowControl;
_config_update(self, &cfg);
}
void PikaStdDevice_UART_setDataBits(PikaObj* self, int dataBits) {
obj_setInt(self, "dataBits", dataBits);
pika_hal_UART_config cfg = {0};
cfg.data_bits = dataBits;
_config_update(self, &cfg);
}
void PikaStdDevice_UART_setParity(PikaObj* self, int parity) {
obj_setInt(self, "parity", parity);
pika_hal_UART_config cfg = {0};
cfg.parity = parity;
_config_update(self, &cfg);
}
void PikaStdDevice_UART_setStopBits(PikaObj* self, int stopBits) {
obj_setInt(self, "stopBits", stopBits);
pika_hal_UART_config cfg = {0};
cfg.stop_bits = stopBits;
_config_update(self, &cfg);
}
void PikaStdDevice_UART_setId(PikaObj* self, int id) {
@ -161,6 +191,7 @@ void PikaStdDevice_UART_platformEnable(PikaObj* self) {
(int)obj_getInt(self, "id"));
return;
}
obj_setInt(self, "enabled", 1);
}
void PikaStdDevice_UART_platformRead(PikaObj* self) {
@ -186,7 +217,12 @@ void PikaStdDevice_UART_platformDisable(PikaObj* self) {
(int)obj_getInt(self, "id"));
return;
}
pika_hal_ioctl(dev, PIKA_HAL_IOCTL_DISABLE);
if (0!= pika_hal_ioctl(dev, PIKA_HAL_IOCTL_DISABLE)){
__platform_printf("Error: disable UART '%d' failed.\r\n",
(int)obj_getInt(self, "id"));
return;
}
obj_setInt(self, "enabled", 0);
}
void PikaStdDevice_UART_platformReadBytes(PikaObj* self) {

View File

@ -187,7 +187,8 @@ releases = [
"v2.3.3 5282cff66fe8f003c75fd82c54c0144aa7da8277",
"v2.3.4 69cea1d7188b35b84d819ed8cb8f41b3a64d39d1",
"v2.3.5 cd0029b6d1b4340b252532fcee1320667231038c",
"v2.3.6 b9a0109c6125d16270cf02b2a07421a4baf9973c"
"v2.3.6 b9a0109c6125d16270cf02b2a07421a4baf9973c",
"v2.3.7 226cba58e474448a9d8773c5a1a1bd83f148baee"
]
[[packages]]