中移4G模块-ML302-OpenCpu开发-串口开发

B站:https://space.bilibili.com/309103931

中移4G模块-ML302专栏:https://blog.csdn.net/qq_33259323/category_10453372.html

中移4G模块-ML302文集:https://www.bilibili.com/read/readlist/rl328642

1.中移4G模块-ML302-OpenCpu开发-(固件编译和烧录)

https://blog.csdn.net/qq_33259323/article/details/108586847

https://www.bilibili.com/read/cv7876504

2.中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云)

https://blog.csdn.net/qq_33259323/article/details/108638945

https://www.bilibili.com/read/cv7876527

2.1中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-订阅主题)

https://blog.csdn.net/qq_33259323/article/details/108960540

https://www.bilibili.com/read/cv7879954

2.2中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-接收和发送数据)

https://blog.csdn.net/qq_33259323/article/details/108964810

https://www.bilibili.com/read/cv7886836

2.3中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-RRPC通讯)

https://blog.csdn.net/qq_33259323/article/details/108965071

https://www.bilibili.com/read/cv7888259

3.中移4G模块-ML302-OpenCpu开发-串口开发

https://blog.csdn.net/qq_33259323/article/details/108974888

https://www.bilibili.com/read/cv7888865

4.中移4G模块-ML302-OpenCpu开发-51单片机串口转I2C

https://blog.csdn.net/qq_33259323/article/details/109020642

https://www.bilibili.com/read/cv7922942

5.中移4G模块-ML302-OpenCpu开发-MCP23017输入/输出

https://blog.csdn.net/qq_33259323/article/details/109109136

https://www.bilibili.com/read/cv7969395

7.中移4G模块-ML302-OpenCpu开发-PCF8591测量电压

https://blog.csdn.net/qq_33259323/article/details/109109266

https://www.bilibili.com/read/cv7969365

8.中移4G模块-ML302-OpenCpu开发-GPIO

https://blog.csdn.net/qq_33259323/article/details/108960947

https://www.bilibili.com/read/cv7877192

9.中移4G模块-ML302-OpenCpu开发-ADC

https://blog.csdn.net/qq_33259323/article/details/109020864

https://www.bilibili.com/read/cv7922958

10.中移4G模块-ML302-OpenCpu开发-CJSON

https://blog.csdn.net/qq_33259323/article/details/109020898

https://www.bilibili.com/read/cv7923020

11.中移4G模块-ML302-OpenCpu开发-HTTP

https://blog.csdn.net/qq_33259323/article/details/109020904

https://www.bilibili.com/read/cv7923054

中移4G模块-ML302-OpenCpu开发-串口开发

ML302 OpenCPU 可使用 3 路串口:串口 0、串口 1、串口 2,另外提供 1 路调试串口。

1.串口初始化

初始化串口2,波特率为115200

#define MM_UART CM_UART_2

void uart_init(){
    cm_uart_cfg_t mm_uart_cfg;

    mm_uart_cfg.id = MM_UART;                        //串口ID
    mm_uart_cfg.baud = CM_UART_BAUD_115200;          //波特率
    mm_uart_cfg.databit = CM_UART_DATA_BITS_8;       //数据位
    mm_uart_cfg.stopbit = CM_UART_STOP_BITS_1;       //停止位
    mm_uart_cfg.parity = CM_UART_NO_PARITY;          //校验
    mm_uart_cfg.cb = mm_test_oc_uart_cb;             //串口接收中断
    mm_uart_cfg.param = "test param mm";
    mm_uart_cfg.event = CM_UART_EVENT_RX_ARRIVED;

    cm_uart_init(&mm_uart_cfg);
}

2.串口接收中断

unsigned char mm_I2C_UART_BUFFER[50] = {0};    // 串口接收存放数组
static void mm_test_oc_uart_cb(void *param,unsigned int evt){
    cm_uart_receive(MM_UART,mm_I2C_UART_BUFFER,1024);
    cm_printf("%s\r\n",mm_I2C_UART_BUFFER);
    if(strstr(mm_I2C_UART_BUFFER,"ok") != NULL){
        return;
    }
    memset(mm_I2C_UART_BUFFER,0,50);
}

3.串口发送数据

// 串口ID,数据,数据长度
cm_uart_send_cache(MM_UART,"hhhh",4);

猜你喜欢

转载自blog.csdn.net/qq_33259323/article/details/108974888
今日推荐