ML305A_ML307A_OpenCPU_API: 模块

ML305A_ML307A_OpenCPU_API V1.4.3
模块
这里列出了所有模块:
[详情级别 12]
adc
asocket
async_dns
Audio_common
Audio_player
Audio_recorder
Camera
CPUINFO
eloop
fota
Fs
FTP
Gnss
gpio
▼ http
Define
Enum
Struct
i2c
Iomux
keypad
Lbs
LCD
tts
mem
modem
mqtt
ntp
os
pm
pwm
QR
rtc
SDCARD
sim
spi
SSL
sys
uart
USB
virt_at
Wifiscan
制作者 CMCC CMCC-IOT


ML305A_ML307A_OpenCPU_API: adc

枚举 | 函数
adc

枚举

enum cm_adc_dev_e { CM_ADC_0 = 1 , CM_ADC_1 , CM_ADC_2 , CM_ADC_3 }
ADC 通道 更多...

函数

int32_t cm_adc_read (cm_adc_dev_e dev, int32_t *voltage)
读取ADC电压 更多...

详细描述

枚举类型说明

◆ cm_adc_dev_e

enum cm_adc_dev_e

ADC 通道

枚举值
CM_ADC_0 | ADC0
CM_ADC_1 | ADC1(ML307A系列不支持)
CM_ADC_2 | ADC2(ML307A系列 && ML305A系列不支持)
CM_ADC_3 | ADC3(ML307A系列 && ML305A系列不支持)

函数说明

◆ cm_adc_read()

int32_t cm_adc_read | ( | cm_adc_dev_e | dev,
 |  | int32_t * | voltage
 | ) |  |

读取ADC电压

参数
[in] | dev | ADC设备ID
[out] | voltage | 电压值, 单位: mv
返回

= 0 - 成功. < 0 - 失败, 返回值为错误码.

通过ADC设备读取测量电压值


ML305A_ML307A_OpenCPU_API: asocket

宏定义 | 类型定义 | 枚举 | 函数
asocket

宏定义

#define | cm_asocket_bind bind
其他接口全部使用标准socket接口 更多...
#define | cm_asocket_shutdown shutdown
#define | cm_asocket_getpeername getpeername
#define | cm_asocket_getsockname getsockname
#define | cm_asocket_setsockopt setsockopt
#define | cm_asocket_getsockopt getsockopt
#define | cm_asocket_recv recv
#define | cm_asocket_recvmsg recvmsg
#define | cm_asocket_recvfrom recvfrom
#define | cm_asocket_send send
#define | cm_asocket_sendmsg sendmsg
#define | cm_asocket_sendto sendto
#define | cm_asocket_ioctl ioctlsocket

类型定义

typedef void(* cm_asocket_event_cb) (int sock, cm_asocket_event_e event, void *cb_param)

枚举

enum cm_asocket_event_e {
CM_ASOCKET_EV_NONE = 0 , CM_ASOCKET_EV_CONNECT_OK , CM_ASOCKET_EV_CONNECT_FAIL , CM_ASOCKET_EV_RECV_IND ,
CM_ASOCKET_EV_SEND_IND , CM_ASOCKET_EV_ACCEPT_IND , CM_ASOCKET_EV_ERROR_IND , CM_ASOCKET_EV_SEQ_IND
}

函数

cm_eloop_handle_t | cm_asocket_eloop (void)
获取异步socket模块运行的Event Loop 更多...
int | cm_asocket_open (int domain, int type, int protocol, cm_asocket_event_cb event_cb, void *cb_param)
开启异步socket 更多...
int | cm_asocket_connect (int sock, const struct sockaddr *addr, socklen_t addr_len)
异步socket connect操作 更多...
int | cm_asocket_close (int sock)
关闭异步socket 更多...

详细描述

宏定义说明

◆ cm_asocket_bind

#define cm_asocket_bind bind

其他接口全部使用标准socket接口

◆ cm_asocket_shutdown

#define cm_asocket_shutdown shutdown

◆ cm_asocket_getpeername

#define cm_asocket_getpeername getpeername

◆ cm_asocket_getsockname

#define cm_asocket_getsockname getsockname

◆ cm_asocket_setsockopt

#define cm_asocket_setsockopt setsockopt

◆ cm_asocket_getsockopt

#define cm_asocket_getsockopt getsockopt

◆ cm_asocket_recv

#define cm_asocket_recv recv

◆ cm_asocket_recvmsg

#define cm_asocket_recvmsg recvmsg

◆ cm_asocket_recvfrom

#define cm_asocket_recvfrom recvfrom

◆ cm_asocket_send

#define cm_asocket_send send

◆ cm_asocket_sendmsg

#define cm_asocket_sendmsg sendmsg

◆ cm_asocket_sendto

#define cm_asocket_sendto sendto

◆ cm_asocket_ioctl

#define cm_asocket_ioctl ioctlsocket

类型定义说明

◆ cm_asocket_event_cb

typedef void(* cm_asocket_event_cb) (int sock, cm_asocket_event_e event, void *cb_param)

异步socket事件回调函数类型

参数
sock | [in] 发生事件的socket描述符
event | [in] 事件类型
cb_param | [in] 用户参数(创建socket时指定)

枚举类型说明

◆ cm_asocket_event_e

enum cm_asocket_event_e

异步socket事件类型

枚举值
CM_ASOCKET_EV_NONE |
CM_ASOCKET_EV_CONNECT_OK | connect response ok
CM_ASOCKET_EV_CONNECT_FAIL | connect response fail
CM_ASOCKET_EV_RECV_IND | data receve indication(通过ioctlsocket(FIONREAD)获取接收缓存中可读的数据长度)
CM_ASOCKET_EV_SEND_IND | send buffer available indication(表示发送缓冲区剩余空间超过水位线)
CM_ASOCKET_EV_ACCEPT_IND | accept indication
CM_ASOCKET_EV_ERROR_IND | error indication(通过getsockopt(SOL_SOCKET, SO_ERROR)获取socket错误码)
CM_ASOCKET_EV_SEQ_IND | 空口回传

函数说明

◆ cm_asocket_eloop()

cm_eloop_handle_t cm_asocket_eloop ( void )

获取异步socket模块运行的Event Loop

返回

本模块运行的Event Loop

获取本模块运行的Event Loop(初始化传入或者系统默认Event Loop)

◆ cm_asocket_open()

int cm_asocket_open | ( | int | domain,
 |  | int | type,
 |  | int | protocol,
 |  | cm_asocket_event_cb | event_cb,
 |  | void * | cb_param
 | ) |  |

开启异步socket

参数
[in] | domain | socket协议族
[in] | type | socket类型
[in] | protocol | 协议类型
[in] | event_cb | 异步事件回调函数
[in] | cb_param | 用户参数(将作为参数传入event_cb)
返回

>= 0 - 异步socket描述符
= -1 - 失败(可通过errno获取具体错误类型)

创建异步socket(分配资源, 返回socket描述符)

◆ cm_asocket_connect()

int cm_asocket_connect | ( | int | sock,
 |  | const struct sockaddr * | addr,
 |  | socklen_t | addr_len
 | ) |  |

异步socket connect操作

参数
[in] | sock | 异步socket描述符
[in] | addr | 远端地址信息
[in] | addr_len | size of addr
返回

= 0 - 成功
= -1 - 失败(可通过errno获取具体错误类型,注意EINPROGRESS的处理)

请求建立连接

◆ cm_asocket_close()

int cm_asocket_close ( int sock )

关闭异步socket

参数
[in] sock 要关闭的异步socket描述符
返回

= 0 - 成功
< 0 - 失败(可通过errno获取具体错误类型)

关闭异步socket(释放资源)


ML305A_ML307A_OpenCPU_API: async_dns

结构体 | 类型定义 | 枚举 | 函数
async_dns

结构体

struct cm_async_dns_ip_addr

类型定义

typedef struct cm_async_dns_ip_addr | cm_async_dns_ip_addr_t
typedef void(* | cm_async_dns_event_cb) (int req_id, cm_async_dns_event_e event, void *cb_param, const char *host_name, const cm_async_dns_ip_addr_t *ip_addr)

枚举

enum | cm_async_dns_addrtype_e { CM_ASYNC_DNS_ADDRTYPE_IPV4 = 0 , CM_ASYNC_DNS_ADDRTYPE_IPV6 , CM_ASYNC_DNS_ADDRTYPE_IPV4_IPV6 , CM_ASYNC_DNS_ADDRTYPE_IPV6_IPV4 }
enum | cm_async_dns_event_e { CM_ASYNC_DNS_EV_NONE = 0 , CM_ASYNC_DNS_RESOLVE_OK , CM_ASYNC_DNS_RESOLVE_FAIL }

函数

cm_eloop_handle_t | cm_async_dns_eloop (void)
获取异步dns模块运行的Event Loop 更多...
int32_t | cm_async_dns_set_priority (uint8_t priority)
设置DNS解析全局优先级 更多...
int | cm_async_dns_request (const char *host_name, cm_async_dns_addrtype_e addr_type, cm_async_dns_ip_addr_t *ip_addr, cm_async_dns_event_cb event_cb, void *cb_param)
请求执行异步DNS解析 更多...

详细描述

类型定义说明

◆ cm_async_dns_ip_addr_t

typedef struct cm_async_dns_ip_addr cm_async_dns_ip_addr_t

IP地址(异步DNS解析结果)类型

◆ cm_async_dns_event_cb

typedef void(* cm_async_dns_event_cb) (int req_id, cm_async_dns_event_e event, void *cb_param, const char *host_name, const cm_async_dns_ip_addr_t *ip_addr)

异步DNS解析事件回调函数类型

参数
req_id | [in] 请求ID
event | [in] 事件类型
cb_param | [in] 用户参数(创建socket时指定)
host_name | [in] 域名
ip_addr | [in] IP地址(DNS解析结果)

枚举类型说明

◆ cm_async_dns_addrtype_e

enum cm_async_dns_addrtype_e

DNS resolve types

枚举值
CM_ASYNC_DNS_ADDRTYPE_IPV4 | resolve IPv4 address
CM_ASYNC_DNS_ADDRTYPE_IPV6 | resolve IPv6 address
CM_ASYNC_DNS_ADDRTYPE_IPV4_IPV6 | try to resolve IPv4 first, try IPv6 if IPv4 fails only
CM_ASYNC_DNS_ADDRTYPE_IPV6_IPV4 | try to resolve IPv6 first, try IPv4 if IPv6 fails only

◆ cm_async_dns_event_e

enum cm_async_dns_event_e

异步DNS解析事件类型

枚举值
CM_ASYNC_DNS_EV_NONE |
CM_ASYNC_DNS_RESOLVE_OK | 域名解析成功
CM_ASYNC_DNS_RESOLVE_FAIL | 域名解析失败

函数说明

◆ cm_async_dns_eloop()

cm_eloop_handle_t cm_async_dns_eloop ( void )

获取异步dns模块运行的Event Loop

返回

本模块运行的Event Loop

获取本模块运行的Event Loop(初始化传入或者系统默认Event Loop)

◆ cm_async_dns_set_priority()

int32_t cm_async_dns_set_priority ( uint8_t priority )

设置DNS解析全局优先级

参数
[in] priority DNS解析优先级，0：v4优先，1：v6优先，默认v6优先
返回
= 0 - 成功
< 0 - 失败

开机默认v6优先，若使用业务(MQTT/HTTP/NTP)时单独配置了通道优先级，则全局优先级对该业务通道将不生效

◆ cm_async_dns_request()

int cm_async_dns_request | ( | const char * | host_name,
 |  | cm_async_dns_addrtype_e | addr_type,
 |  | cm_async_dns_ip_addr_t * | ip_addr,
 |  | cm_async_dns_event_cb | event_cb,
 |  | void * | cb_param
 | ) |  |

请求执行异步DNS解析

参数
[in] | host_name | 域名
[in] | addr_type | 地址类型(IPV4或IPV6)
[out] | ip_addr | IP地址(DNS解析结果)
[in] | event_cb | 异步事件回调函数
[in] | cb_param | 用户参数(将作为参数传入event_cb)
返回

0 - DNS请求成功,返回异步DNS请求ID(等待回调函数传回执行结果)

= 0 - DNS请求已完成(result输出解析结果)
= -1 - 请求失败

请求执行异步DNS解析


ML305A_ML307A_OpenCPU_API: cm_async_dns_ip_addr结构体 参考

成员变量
cm_async_dns_ip_addr结构体 参考
async_dns

#include <cm_async_dns.h>

成员变量

cm_async_dns_addrtype_e type
union {
struct in_addr sin_addr
struct in6_addr sin6_addr
} u_addr

详细描述

IP地址(异步DNS解析结果)类型

结构体成员变量说明

◆ type

cm_async_dns_addrtype_e type

地址类型(IPv4或IPv6)

◆ sin_addr

struct in_addr sin_addr

IPv4 address

◆ sin6_addr

struct in6_addr sin6_addr

IPv6 address

◆

union { ... } u_addr
该结构体的文档由以下文件生成:
  • cm_async_dns.h


ML305A_ML307A_OpenCPU_API: Audio_common

结构体 | 枚举
Audio_common

结构体

struct cm_audio_sample_param_t

枚举

enum | cm_audio_play_format_e { CM_AUDIO_PLAY_FORMAT_PCM = 1 , CM_AUDIO_PLAY_FORMAT_WAV , CM_AUDIO_PLAY_FORMAT_MP3 = 3 , CM_AUDIO_PLAY_FORMAT_AMRNB }
enum cm_audio_record_format_e {
CM_AUDIO_RECORD_FORMAT_PCM = 1 , CM_AUDIO_RECORD_FORMAT_AMRNB_475 = 4 , CM_AUDIO_RECORD_FORMAT_AMRNB_515 , CM_AUDIO_RECORD_FORMAT_AMRNB_590 ,
CM_AUDIO_RECORD_FORMAT_AMRNB_670 , CM_AUDIO_RECORD_FORMAT_AMRNB_740 , CM_AUDIO_RECORD_FORMAT_AMRNB_795 , CM_AUDIO_RECORD_FORMAT_AMRNB_1020 ,
CM_AUDIO_RECORD_FORMAT_AMRNB_1220
}
enum | cm_audio_sample_format_e { CM_AUDIO_SAMPLE_FORMAT_8BIT = 1 , CM_AUDIO_SAMPLE_FORMAT_16BIT , CM_AUDIO_SAMPLE_FORMAT_24BIT , CM_AUDIO_SAMPLE_FORMAT_32BIT }
enum cm_audio_sample_rate_e {
CM_AUDIO_SAMPLE_RATE_8000HZ = 8000 , CM_AUDIO_SAMPLE_RATE_11025HZ = 11025 , CM_AUDIO_SAMPLE_RATE_12000HZ = 12000 , CM_AUDIO_SAMPLE_RATE_16000HZ = 16000 ,
CM_AUDIO_SAMPLE_RATE_22050HZ = 22050 , CM_AUDIO_SAMPLE_RATE_24000HZ = 24000 , CM_AUDIO_SAMPLE_RATE_32000HZ = 32000 , CM_AUDIO_SAMPLE_RATE_44100HZ = 44100 ,
CM_AUDIO_SAMPLE_RATE_48000HZ = 48000 , CM_AUDIO_SAMPLE_RATE_96000HZ = 96000
}
enum | cm_audio_sound_channel_e { CM_AUDIO_SOUND_MONO = 1 , CM_AUDIO_SOUND_STEREO = 2 }

详细描述

枚举类型说明

◆ cm_audio_play_format_e

enum cm_audio_play_format_e

音频播放格式支持

枚举值
CM_AUDIO_PLAY_FORMAT_PCM | PCM格式
CM_AUDIO_PLAY_FORMAT_WAV | WAV格式
CM_AUDIO_PLAY_FORMAT_MP3 | MP3格式
CM_AUDIO_PLAY_FORMAT_AMRNB | AMR-NB格式

◆ cm_audio_record_format_e

enum cm_audio_record_format_e

音频录音格式支持

枚举值
CM_AUDIO_RECORD_FORMAT_PCM | PCM格式
CM_AUDIO_RECORD_FORMAT_AMRNB_475 | 4.75 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_515 | 5.15 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_590 | 5.90 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_670 | 6.70 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_740 | 7.40 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_795 | 7.95 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_1020 | 10.20 kbps AMR格式
CM_AUDIO_RECORD_FORMAT_AMRNB_1220 | 12.20 kbps AMR格式

◆ cm_audio_sample_format_e

enum cm_audio_sample_format_e

PCM音频采样格式

枚举值
CM_AUDIO_SAMPLE_FORMAT_8BIT | 8位，暂不开放，请使用CM_AUDIO_SAMPLE_FORMAT_16BIT
CM_AUDIO_SAMPLE_FORMAT_16BIT | 16位, 小端
CM_AUDIO_SAMPLE_FORMAT_24BIT | 24位, 本平台不支持
CM_AUDIO_SAMPLE_FORMAT_32BIT | 32位, 暂不开放，请使用CM_AUDIO_SAMPLE_FORMAT_16BIT

◆ cm_audio_sample_rate_e

enum cm_audio_sample_rate_e

音频播放支持的采样率（录音支持的采样率单独标注）

枚举值
CM_AUDIO_SAMPLE_RATE_8000HZ | （默认）录音时默认且只能使用8000Hz
CM_AUDIO_SAMPLE_RATE_11025HZ |
CM_AUDIO_SAMPLE_RATE_12000HZ |
CM_AUDIO_SAMPLE_RATE_16000HZ |
CM_AUDIO_SAMPLE_RATE_22050HZ |
CM_AUDIO_SAMPLE_RATE_24000HZ |
CM_AUDIO_SAMPLE_RATE_32000HZ |
CM_AUDIO_SAMPLE_RATE_44100HZ |
CM_AUDIO_SAMPLE_RATE_48000HZ |
CM_AUDIO_SAMPLE_RATE_96000HZ |

◆ cm_audio_sound_channel_e

enum cm_audio_sound_channel_e

PCM音频采样通道

枚举值
CM_AUDIO_SOUND_MONO | （默认）单通道，录音时默认且只能使用CM_AUDIO_SOUND_MONO
CM_AUDIO_SOUND_STEREO | 双通道（立体声）


ML305A_ML307A_OpenCPU_API: cm_audio_sample_param_t结构体 参考

成员变量
cm_audio_sample_param_t结构体 参考
Audio_common

#include <cm_audio_common.h>

成员变量

cm_audio_sample_format_e sample_format
cm_audio_sample_rate_e rate
cm_audio_sound_channel_e num_channels

详细描述

音频采样参数结构体

结构体成员变量说明

◆ sample_format

cm_audio_sample_format_e sample_format

采样格式（PCM）

◆ rate

cm_audio_sample_rate_e rate

采样率（PCM）

◆ num_channels

cm_audio_sound_channel_e num_channels

采样声道（PCM）

该结构体的文档由以下文件生成:
  • cm_audio_common.h


ML305A_ML307A_OpenCPU_API: Audio_player

类型定义 | 枚举 | 函数
Audio_player

类型定义

typedef void(* cm_audio_play_callback_t) (cm_audio_play_event_e event, void *param)
播放回调函数 更多...

枚举

enum | cm_audio_play_channel_e { CM_AUDIO_PLAY_CHANNEL_RECEIVER = 1 , CM_AUDIO_PLAY_CHANNEL_HEADSET , CM_AUDIO_PLAY_CHANNEL_SPEAKER }
enum | cm_audio_play_event_e { CM_AUDIO_PLAY_EVENT_FINISHED = 1 }
enum | cm_audio_play_cfg_type_e { CM_AUDIO_PLAY_CFG_CHANNEL = 1 , CM_AUDIO_PLAY_CFG_VOLUME }

函数

int32_t | cm_audio_play_set_cfg (cm_audio_play_cfg_type_e type, void *value)
设置播放参数 更多...
int32_t | cm_audio_play_get_cfg (cm_audio_play_cfg_type_e type, void *value)
读取播放参数 更多...
int32_t | cm_audio_play_file (const char *path, cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_play_callback_t cb, void *cb_param)
从文件系统播放音频文件 更多...
int32_t | cm_audio_player_pause (void)
暂停播放 更多...
int32_t | cm_audio_player_resume (void)
继续播放 更多...
int32_t | cm_audio_player_stop (void)
停止播放 更多...
int32_t | cm_audio_player_stream_open (cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param)
从管道/消息队列中播放音频（开启） 更多...
int32_t | cm_audio_player_stream_push (uint8_t *data, uint32_t size)
往管道/消息队列中发送要播放的音频数据 更多...
void | cm_audio_player_stream_close (void)
从管道/消息队列中播放音频（关闭） 更多...

详细描述

类型定义说明

◆ cm_audio_play_callback_t

typedef void(* cm_audio_play_callback_t) (cm_audio_play_event_e event, void *param)

播放回调函数

参数
[in] | event | 事件类型
[in] | param | 事件参数

须在播放API中传入
通知事件为中断触发，不可阻塞，不可做耗时较长的操作，例如不可使用UART打印log

枚举类型说明

◆ cm_audio_play_channel_e

enum cm_audio_play_channel_e

音频播放通道支持

枚举值
CM_AUDIO_PLAY_CHANNEL_RECEIVER | 听筒通道，不支持设置
CM_AUDIO_PLAY_CHANNEL_HEADSET | 耳机通道，不支持设置
CM_AUDIO_PLAY_CHANNEL_SPEAKER | 扬声器通道，不支持设置

◆ cm_audio_play_event_e

enum cm_audio_play_event_e

音频播放回调的事件类型

枚举值
CM_AUDIO_PLAY_EVENT_FINISHED

播放结束

◆ cm_audio_play_cfg_type_e

enum cm_audio_play_cfg_type_e

音频播放设置类型

枚举值
CM_AUDIO_PLAY_CFG_CHANNEL | 播放通道，支持范围参见cm_audio_play_channel_e枚举量，不支持设置
CM_AUDIO_PLAY_CFG_VOLUME | 播放音量，支持范围参见0~100

函数说明

◆ cm_audio_play_set_cfg()

int32_t cm_audio_play_set_cfg | ( | cm_audio_play_cfg_type_e | type,
 |  | void * | value
 | ) |  |

设置播放参数

参数
[in] | type | 设置参数类型
[in] | value | 设置参数数值
返回
= 0 - 成功
= -1 - 失败

不支持设置播放通道（模组仅一个播放通道，默认使用该通道，该通道外接扬声器/耳机/听筒由用户决定）
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_play_get_cfg()

int32_t cm_audio_play_get_cfg | ( | cm_audio_play_cfg_type_e | type,
 |  | void * | value
 | ) |  |

读取播放参数

参数
[in] | type | 读取参数类型
[out] | value | 读取参数数值
返回
= 0 - 成功
= -1 - 失败

不支持获取播放通道（模组仅一个播放通道，默认使用该通道，该通道外接扬声器/耳机/听筒由用户决定）
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_play_file()

int32_t cm_audio_play_file | ( | const char * | path,
 |  | cm_audio_play_format_e | format,
 |  | cm_audio_sample_param_t * | sample_param,
 |  | cm_audio_play_callback_t | cb,
 |  | void * | cb_param
 | ) |  |

从文件系统播放音频文件

参数
[in] | path | 文件路径/名称
[in] | format | 播放格式
[in] | sample_param | 播放音频PCM采样参数（format参数为CM_AUDIO_PLAY_FORMAT_PCM使用，其余情况传入NULL）
[in] | cb | 音频播放回调函数（回调函数在音频处理线程中被执行）
[in] | cb_param | 用户参数（与cm_audio_play_callback回调函数中param参数相对应，长度最大为8）
返回
= 0 - 成功
= -1 - 失败

支持mp3、amr格式
通知事件为中断触发，不可阻塞，不可做耗时较长的操作，例如不可使用UART打印log
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_pause()

int32_t cm_audio_player_pause ( void )

暂停播放

返回
= 0 - 成功
= -1 - 失败

支持MP3、AMR格式;调用该接口到暂停播放存在一定延时
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_resume()

int32_t cm_audio_player_resume ( void )

继续播放

返回
= 0 - 成功
= -1 - 失败
   仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_stop()

int32_t cm_audio_player_stop ( void )

停止播放

返回
= 0 - 成功
= -1 - 失败

支持MP3、AMR格式;调用该接口到停止播放存在一定延时
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_stream_open()

int32_t cm_audio_player_stream_open | ( | cm_audio_play_format_e | format,
 |  | cm_audio_sample_param_t * | sample_param
 | ) |  |

从管道/消息队列中播放音频（开启）

参数
[in] | format | 播放格式（暂只支持PCM）
[in] | sample_param | 播放音频PCM采样参数（format参数为CM_AUDIO_PLAY_FORMAT_PCM使用，其余情况传入NULL）
返回
= 0 - 成功
= -1 - 失败

支持PCM、MP3、AMR格式
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_stream_push()

int32_t cm_audio_player_stream_push | ( | uint8_t * | data,
 |  | uint32_t | size
 | ) |  |

往管道/消息队列中发送要播放的音频数据

参数
[in] | data | 播放的数据
[in] | size | 播放数据的长度
返回
>= 0 - 实际写入的数据长度
= -1 - 失败

支持PCM、MP3、AMR格式
对于PCM格式，传输数据须是帧长度的整数倍（例如，8k 16bit的PCM数据，每帧为320字节，传输的数据应是320的整数倍）
对于AMR格式，传输数据若包含不完整帧数据可能出现爆破音
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_player_stream_close()

void cm_audio_player_stream_close ( void )

从管道/消息队列中播放音频（关闭）

仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能


ML305A_ML307A_OpenCPU_API: Audio_recorder

结构体 | 类型定义 | 枚举 | 函数
Audio_recorder

结构体

struct cm_audio_record_data_t

类型定义

typedef void(* cm_audio_record_callback_t) (cm_audio_record_event_e event, void *param)
录音回调函数 更多...

枚举

enum | cm_audio_record_channel_e { CM_AUDIO_RECORD_CHANNEL_MAIN = 1 , CM_AUDIO_RECORD_CHANNEL_HP }
enum | cm_audio_record_event_e { CM_AUDIO_RECORD_EVENT_DATA = 1 }
enum | cm_audio_record_cfg_type_e { CM_AUDIO_RECORD_CFG_CHANNEL = 1 , CM_AUDIO_RECORD_CFG_GAIN }

函数

int32_t | cm_audio_record_set_cfg (cm_audio_record_cfg_type_e type, void *value)
设置录音参数 更多...
int32_t | cm_audio_record_get_cfg (cm_audio_record_cfg_type_e type, void *value)
读取录音参数 更多...
int32_t | cm_audio_recorder_start (cm_audio_record_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_record_callback_t cb, void *cb_param)
开始录音 更多...
void | cm_audio_recorder_stop (void)
结束录音 更多...

详细描述

类型定义说明

◆ cm_audio_record_callback_t

typedef void(* cm_audio_record_callback_t) (cm_audio_record_event_e event, void *param)

录音回调函数

参数
[in] | event | 事件类型
[in] | param | 事件参数（事件类型为CM_AUDIO_RECORD_DATA时，需要将param强转为cm_audio_record_data_t型。其余情况该参数为用户传入参数）

须在录音API中传入
通知事件为中断触发，不可阻塞，不可做耗时较长的操作，例如不可使用UART打印log

枚举类型说明

◆ cm_audio_record_channel_e

enum cm_audio_record_channel_e

录音通道支持

枚举值
CM_AUDIO_RECORD_CHANNEL_MAIN | 主MIC通道，不支持设置
CM_AUDIO_RECORD_CHANNEL_HP | 耳机MIC通道，不支持设置

◆ cm_audio_record_event_e

enum cm_audio_record_event_e

录音回调的事件类型

枚举值
CM_AUDIO_RECORD_EVENT_DATA

录音数据上报

◆ cm_audio_record_cfg_type_e

enum cm_audio_record_cfg_type_e

录音设置类型

枚举值
CM_AUDIO_RECORD_CFG_CHANNEL | 录音通道，支持范围参见cm_audio_record_channel_e枚举量，不支持设置
CM_AUDIO_RECORD_CFG_GAIN | 录音增益，不支持设置

函数说明

◆ cm_audio_record_set_cfg()

int32_t cm_audio_record_set_cfg | ( | cm_audio_record_cfg_type_e | type,
 |  | void * | value
 | ) |  |

设置录音参数

参数
[in] | type | 设置参数类型
[in] | value | 设置参数数值
返回
= 0 - 成功
= -1 - 失败

增益调节范围为（0~48），呈线性关系；非录音状态下该参数设置后保持至本地缓存中不会立即生效，应用调用cm_audio_recorder_start()后方才生效，暂不支持
0 -36dB
12 -24dB
24 -12dB
36 0dB
48 12dB
不支持设置录音通道（模组仅一个录音通道，默认使用该通道，该通道外接mic/耳机mic由用户决定）
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_record_get_cfg()

int32_t cm_audio_record_get_cfg | ( | cm_audio_record_cfg_type_e | type,
 |  | void * | value
 | ) |  |

读取录音参数

参数
[in] | type | 读取参数类型
[out] | value | 读取参数数值
返回
= 0 - 成功
= -1 - 失败

增益调节范围为（0~48），呈线性关系；录音状态下读取实际值，非录音状态下读取本地缓存中的值，暂不支持
0 -36dB
12 -24dB
24 -12dB
36 0dB
48 12dB
不支持获取录音通道（模组仅一个播放通道，默认使用该通道，该通道外接mic/耳机mic由用户决定）
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_recorder_start()

int32_t cm_audio_recorder_start | ( | cm_audio_record_format_e | format,
 |  | cm_audio_sample_param_t * | sample_param,
 |  | cm_audio_record_callback_t | cb,
 |  | void * | cb_param
 | ) |  |

开始录音

参数
[in] | format | 录制音频格式
[in] | sample_param | 录制音频PCM采样参数
[in] | cb | 录音回调函数（回调函数不能阻塞）
[in] | cb_param | 用户参数（参见cm_audio_record_callback回调函数中param参数描述，长度最大为8）
返回
= 0 - 成功
= -1 - 失败

回调函数不能阻塞，支持PCM和AMR格式
通知事件为中断触发，不可阻塞，不可做耗时较长的操作，例如不可使用UART打印log
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能

◆ cm_audio_recorder_stop()

void cm_audio_recorder_stop ( void )

结束录音

仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS）支持audio功能


ML305A_ML307A_OpenCPU_API: cm_audio_record_data_t结构体 参考

成员变量
cm_audio_record_data_t结构体 参考
Audio_recorder

#include <cm_audio_recorder.h>

成员变量

uint8_t * | data
uint32_t | len
void * | user

结构体成员变量说明

◆ data

uint8_t* data

录音数据

◆ len

uint32_t len

录音数据长度

◆ user

void* user

用户传入参数

该结构体的文档由以下文件生成:
  • cm_audio_recorder.h


ML305A_ML307A_OpenCPU_API: Camera

结构体 | 宏定义 | 枚举 | 函数
Camera

结构体

struct | cm_camera_preview_cfg_t
camera预览接口配置参数 更多...
struct | cm_camera_capture_cfg_t
camera拍照接口配置参数 更多...
struct | cm_cam_sensor_ata_t
camera ata模式参数 更多...
struct | cm_cam_sensor_aec_t
camera 曝光参数 更多...
struct | cm_cam_sensor_spec_ops
camera操作函数 更多...
struct | cm_cam_regval_tab
i2c寄存器地址及写入值 更多...
struct | cm_cam_sensor_regs
i2c寄存器操作表 更多...
struct | cm_cam_sensor_i2c_attr
i2c参数 更多...
struct | cm_cam_sensor_global
预留参数相关结构体，暂无使用 更多...
struct | cm_cam_sensor_resolution
camera参数设置及初始化 更多...
struct | cm_cam_sensor_module
预留参数结构体 更多...
struct | cm_isp_tuning_tab
ISP 寄存器地址组及写入值 更多...
struct | cm_isp_tuning_data
ISP 寄存器操作表 更多...
struct | cm_cam_sensor_data_t
camera驱动结构体 更多...

宏定义

#define | MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
#define | MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
#define | MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
#define | MEDIA_BUS_FMT_SRGGB8_1X8 0x3014
#define | MEDIA_BUS_FMT_SBGGR10_1X10 0x3007
#define | MEDIA_BUS_FMT_SGBRG10_1X10 0x300e
#define | MEDIA_BUS_FMT_SGRBG10_1X10 0x300a
#define | MEDIA_BUS_FMT_SRGGB10_1X10 0x300f
#define | MEDIA_BUS_FMT_UYVY8_2X8 0x2006
#define | MEDIA_BUS_FMT_VYUY8_2X8 0x2007
#define | MEDIA_BUS_FMT_YUYV8_2X8 0x2008
#define | MEDIA_BUS_FMT_YVYU8_2X8 0x2009

枚举

enum cm_camera_out_fmt_e {
CAM_OUT_FMT_YUV422_YUYV = 0 , CAM_OUT_FMT_YUV422_YVYU , CAM_OUT_FMT_YUV422_UYVY , CAM_OUT_FMT_YUV422_VYUY ,
CAM_OUT_FMT_YUV420_NV12 = 6 , CAM_OUT_FMT_RAW8 = 10
}
camera数据输出类型 更多...
enum | cm_cam_sensor_banding { CAM_BANDING_50HZ = 0 , CAM_BANDING_60HZ = 1 , CAM_BANDING_AUTO = 2 }
camera 频率 更多...
enum | cm_cam_sensor_i2c_len { CAM_I2C_8BIT = 0 , CAM_I2C_16BIT , CAM_I2C_32BIT }
i2c寄存器支持的数据宽度 更多...
enum | cm_cam_sensor_res_prop { CAM_SENSOR_RES_BINING1 , CAM_SENSOR_RES_BINING2 , CAM_SENSOR_RES_CROPPED , CAM_SENSOR_RES_MAX }
预留参数相关结构体 更多...
enum cm_cam_sensor_fmt {
CAM_SENSOR_FMT_RAW8 = 0 , CAM_SENSOR_FMT_ONLY_Y , CAM_SENSOR_FMT_RAW10 , CAM_SENSOR_FMT_RAW12 ,
CAM_SENSOR_FMT_YUV422
}
camera输出数据类型 更多...

函数

int32_t | cm_camera_get_info (uint32_t *width, uint32_t *height)
获取底层驱动输出大小 更多...
int32_t | cm_camera_open (void)
打开相机 更多...
int32_t | cm_camera_close (void)
关闭相机 更多...
int32_t | cm_camera_preview_start (cm_camera_preview_cfg_t *cfg)
开始预览 更多...
int32_t | cm_camera_preview_stop (void)
关闭预览 更多...
int32_t | cm_camera_capture_take (cm_camera_capture_cfg_t *cfg)
拍照 更多...
void | cm_camera_sensor_set_mclk (int32_t enable)
使能mclk 更多...
void | cm_camera_sensor_set_data (cm_cam_sensor_data_t *data)
设置驱动参数 更多...
int32_t | cm_camera_sensor_i2c_read (const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t *val)
i2c读取 更多...
int32_t | cm_camera_sensor_i2c_write (const cm_cam_sensor_i2c_attr *attr, cm_cam_sensor_regs regs)
i2c写 更多...
int32_t | cm_camera_sensor_i2c_write_single (const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t val)
i2c写（单个数据） 更多...

详细描述

宏定义说明

◆ MEDIA_BUS_FMT_SBGGR8_1X8

#define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001

◆ MEDIA_BUS_FMT_SGBRG8_1X8

#define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013

◆ MEDIA_BUS_FMT_SGRBG8_1X8

#define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002

◆ MEDIA_BUS_FMT_SRGGB8_1X8

#define MEDIA_BUS_FMT_SRGGB8_1X8 0x3014

◆ MEDIA_BUS_FMT_SBGGR10_1X10

#define MEDIA_BUS_FMT_SBGGR10_1X10 0x3007

◆ MEDIA_BUS_FMT_SGBRG10_1X10

#define MEDIA_BUS_FMT_SGBRG10_1X10 0x300e

◆ MEDIA_BUS_FMT_SGRBG10_1X10

#define MEDIA_BUS_FMT_SGRBG10_1X10 0x300a

◆ MEDIA_BUS_FMT_SRGGB10_1X10

#define MEDIA_BUS_FMT_SRGGB10_1X10 0x300f

◆ MEDIA_BUS_FMT_UYVY8_2X8

#define MEDIA_BUS_FMT_UYVY8_2X8 0x2006

◆ MEDIA_BUS_FMT_VYUY8_2X8

#define MEDIA_BUS_FMT_VYUY8_2X8 0x2007

◆ MEDIA_BUS_FMT_YUYV8_2X8

#define MEDIA_BUS_FMT_YUYV8_2X8 0x2008

◆ MEDIA_BUS_FMT_YVYU8_2X8

#define MEDIA_BUS_FMT_YVYU8_2X8 0x2009

枚举类型说明

◆ cm_camera_out_fmt_e

enum cm_camera_out_fmt_e

camera数据输出类型

枚举值
CAM_OUT_FMT_YUV422_YUYV
CAM_OUT_FMT_YUV422_YVYU
CAM_OUT_FMT_YUV422_UYVY
CAM_OUT_FMT_YUV422_VYUY
CAM_OUT_FMT_YUV420_NV12
CAM_OUT_FMT_RAW8

◆ cm_cam_sensor_banding

enum cm_cam_sensor_banding

camera 频率

枚举值
CAM_BANDING_50HZ
CAM_BANDING_60HZ
CAM_BANDING_AUTO

◆ cm_cam_sensor_i2c_len

enum cm_cam_sensor_i2c_len

i2c寄存器支持的数据宽度

枚举值
CAM_I2C_8BIT
CAM_I2C_16BIT
CAM_I2C_32BIT

◆ cm_cam_sensor_res_prop

enum cm_cam_sensor_res_prop

预留参数相关结构体

枚举值
CAM_SENSOR_RES_BINING1
CAM_SENSOR_RES_BINING2
CAM_SENSOR_RES_CROPPED
CAM_SENSOR_RES_MAX

◆ cm_cam_sensor_fmt

enum cm_cam_sensor_fmt

camera输出数据类型

枚举值
CAM_SENSOR_FMT_RAW8
CAM_SENSOR_FMT_ONLY_Y
CAM_SENSOR_FMT_RAW10
CAM_SENSOR_FMT_RAW12
CAM_SENSOR_FMT_YUV422

函数说明

◆ cm_camera_get_info()

int32_t cm_camera_get_info | ( | uint32_t * | width,
 |  | uint32_t * | height
 | ) |  |

获取底层驱动输出大小

参数
[out] | width | 宽度
[out] | height | 高度
返回
0 成功；-1 失败

获取底层驱动输出大小

◆ cm_camera_open()

int32_t cm_camera_open ( void )

打开相机

返回
0 成功；-1 失败

打开相机

◆ cm_camera_close()

int32_t cm_camera_close ( void )

关闭相机

返回
0 成功；-1 失败

关闭相机

◆ cm_camera_preview_start()

int32_t cm_camera_preview_start ( cm_camera_preview_cfg_t * cfg )

开始预览

参数
[in] cfg 配置参数
返回
0 成功；-1 失败

开始预览，数据通过cfg中设置的回调函数返回，回调函数中可 调用cm_camera_preview_stop关闭预览，但不可调用cm_camera_close

◆ cm_camera_preview_stop()

int32_t cm_camera_preview_stop ( void )

关闭预览

返回
0 成功；-1 失败

关闭预览

◆ cm_camera_capture_take()

int32_t cm_camera_capture_take ( cm_camera_capture_cfg_t * cfg )

拍照

参数
[in] cfg 配置参数
返回
0 成功；-1 失败

拍照，数据自动保存至指定文件

◆ cm_camera_sensor_set_mclk()

void cm_camera_sensor_set_mclk ( int32_t enable )

使能mclk

参数
[in] enable 使能(1 打开， 0 关闭)
返回

用于相机上电逻辑，控制mclk时钟输出

◆ cm_camera_sensor_set_data()

void cm_camera_sensor_set_data ( cm_cam_sensor_data_t * data )

设置驱动参数

参数
[in] data 驱动参数
返回

操作相机前需设置

◆ cm_camera_sensor_i2c_read()

int32_t cm_camera_sensor_i2c_read | ( | const cm_cam_sensor_i2c_attr * | attr,
 |  | uint32_t | reg,
 |  | uint32_t * | val
 | ) |  |

i2c读取

参数
[in] | attr | i2c参数
[in] | reg | 寄存器地址
[out] | val | 读取值
返回
0 成功；-1 失败

通过i2c读取相机寄存器

◆ cm_camera_sensor_i2c_write()

int32_t cm_camera_sensor_i2c_write | ( | const cm_cam_sensor_i2c_attr * | attr,
 |  | cm_cam_sensor_regs | regs
 | ) |  |

i2c写

参数
[in] | attr | i2c参数
[in] | regs | 寄存器操作表
返回
0 成功；-1 失败

通过i2c写相机寄存器

◆ cm_camera_sensor_i2c_write_single()

int32_t cm_camera_sensor_i2c_write_single | ( | const cm_cam_sensor_i2c_attr * | attr,
 |  | uint32_t | reg,
 |  | uint32_t | val
 | ) |  |

i2c写（单个数据）

参数
[in] | attr | i2c参数
[in] | reg | 寄存器地址
[out] | val | 写入值
返回
0 成功；-1 失败

通过i2c写相机寄存器


ML305A_ML307A_OpenCPU_API: cm_camera_preview_cfg_t结构体 参考

成员变量
cm_camera_preview_cfg_t结构体 参考
Camera

camera预览接口配置参数 更多...

#include <cm_camera.h>

成员变量

cm_camera_out_fmt_e recordFormat
void(* | enqueueCamRecordBuffer )(void *pBuf, uint32_t len)
void(* | flushCamRecordBuffers )(void)

详细描述

camera预览接口配置参数

结构体成员变量说明

◆ recordFormat

cm_camera_out_fmt_e recordFormat

输出数据类型

◆ enqueueCamRecordBuffer

void(* enqueueCamRecordBuffer) (void *pBuf, uint32_t len)

输出数据回调函数

◆ flushCamRecordBuffers

void(* flushCamRecordBuffers) (void)

输出关闭回调

该结构体的文档由以下文件生成:
  • cm_camera.h


ML305A_ML307A_OpenCPU_API: cm_camera_capture_cfg_t结构体 参考

成员变量
cm_camera_capture_cfg_t结构体 参考
Camera

camera拍照接口配置参数 更多...

#include <cm_camera.h>

成员变量

cm_camera_out_fmt_e recordFormat
uint8_t * file_name

详细描述

camera拍照接口配置参数

结构体成员变量说明

◆ recordFormat

cm_camera_out_fmt_e recordFormat

输出数据类型

◆ file_name

uint8_t* file_name

输出文件名

该结构体的文档由以下文件生成:
  • cm_camera.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_ata_t结构体 参考

成员变量
cm_cam_sensor_ata_t结构体 参考
Camera

camera ata模式参数 更多...

#include <cm_camera_sensor.h>

成员变量

uint32_t | on
int32_t | read_crc_value

详细描述

camera ata模式参数

结构体成员变量说明

◆ on

uint32_t on

◆ read_crc_value

int32_t read_crc_value
该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_aec_t结构体 参考

成员变量
cm_cam_sensor_aec_t结构体 参考
Camera

camera 曝光参数 更多...

#include <cm_camera_sensor.h>

成员变量

uint32_t | exp_high
uint32_t | exp_low
uint32_t | gain
uint32_t | aec_en
uint32_t | min_fps
uint32_t | max_fps
cm_cam_sensor_banding banding
uint32_t | sensor_out_yuv

详细描述

camera 曝光参数

结构体成员变量说明

◆ exp_high

uint32_t exp_high

◆ exp_low

uint32_t exp_low

◆ gain

uint32_t gain

◆ aec_en

uint32_t aec_en

◆ min_fps

uint32_t min_fps

◆ max_fps

uint32_t max_fps

◆ banding

cm_cam_sensor_banding banding

◆ sensor_out_yuv

uint32_t sensor_out_yuv
该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_spec_ops结构体 参考

成员变量
cm_cam_sensor_spec_ops结构体 参考
Camera

camera操作函数 更多...

#include <cm_camera_sensor.h>

成员变量

int32_t * | get_pixel_rate
int32_t * | get_dphy_desc
int32_t * | update_otp
int32_t(* | s_power )(int32_t onoff)
int32_t(* | ata_open )(cm_cam_sensor_ata_t *ata)
int32_t(* | update_aec )(cm_cam_sensor_aec_t *aec)
int32_t * | set_effect
int32_t * | set_brightness
int32_t * | set_contrast
int32_t * | set_wb
int32_t * | set_saturation
int32_t * | set_banding

详细描述

camera操作函数

上层接口操作camera的实际驱动接口，内部需自行实现，目前系统只用到s_power、 ata_open、ata_open三个接口，其余预留，设置为NULL。

结构体成员变量说明

◆ get_pixel_rate

int32_t* get_pixel_rate

◆ get_dphy_desc

int32_t* get_dphy_desc

◆ update_otp

int32_t* update_otp

◆ s_power

int32_t(* s_power) (int32_t onoff)

camera上下电

◆ ata_open

int32_t(* ata_open) (cm_cam_sensor_ata_t *ata)

打开/关闭camera 模组进入test pattern的功能

◆ update_aec

int32_t(* update_aec) (cm_cam_sensor_aec_t *aec)

camera模组曝光参数设置

◆ set_effect

int32_t* set_effect

◆ set_brightness

int32_t* set_brightness

◆ set_contrast

int32_t* set_contrast

◆ set_wb

int32_t* set_wb

◆ set_saturation

int32_t* set_saturation

◆ set_banding

int32_t* set_banding
该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_regval_tab结构体 参考

成员变量
cm_cam_regval_tab结构体 参考
Camera

i2c寄存器地址及写入值 更多...

#include <cm_camera_sensor.h>

成员变量

uint16_t | reg
uint16_t | val
uint16_t | mask

详细描述

i2c寄存器地址及写入值

结构体成员变量说明

◆ reg

uint16_t reg

寄存器地址

◆ val

uint16_t val

数据值

◆ mask

uint16_t mask

延时时间ms

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_regs结构体 参考

成员变量
cm_cam_sensor_regs结构体 参考
Camera

i2c寄存器操作表 更多...

#include <cm_camera_sensor.h>

成员变量

const cm_cam_regval_tab * | tab
uint32_t | num

详细描述

i2c寄存器操作表

结构体成员变量说明

◆ tab

const cm_cam_regval_tab* tab

i2c寄存器操作表，可同时配置多个

◆ num

uint32_t num

i2c寄存器操作表个数

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_i2c_attr结构体 参考

成员变量
cm_cam_sensor_i2c_attr结构体 参考
Camera

i2c参数 更多...

#include <cm_camera_sensor.h>

成员变量

cm_cam_sensor_i2c_len reg_len
cm_cam_sensor_i2c_len val_len
uint8_t addr

详细描述

i2c参数

结构体成员变量说明

◆ reg_len

cm_cam_sensor_i2c_len reg_len

i2c寄存器宽度

◆ val_len

cm_cam_sensor_i2c_len val_len

i2c数据宽度

◆ addr

uint8_t addr

i2c设备地址

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_global结构体 参考

成员变量
cm_cam_sensor_global结构体 参考
Camera

预留参数相关结构体，暂无使用 更多...

#include <cm_camera_sensor.h>

成员变量

cm_cam_sensor_regs regs
int32_t sensor_out_format

详细描述

预留参数相关结构体，暂无使用

结构体成员变量说明

◆ regs

cm_cam_sensor_regs regs

◆ sensor_out_format

int32_t sensor_out_format
该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_resolution结构体 参考

成员变量
cm_cam_sensor_resolution结构体 参考
Camera

camera参数设置及初始化 更多...

#include <cm_camera_sensor.h>

成员变量

uint32_t | sensor_out_format
uint16_t | mbus_code
uint16_t | width
uint16_t | height
uint32_t | hts
uint32_t | min_vts
uint8_t | max_fps
uint8_t | min_fps
cm_cam_sensor_res_prop prop
cm_cam_sensor_regs regs

详细描述

camera参数设置及初始化

结构体成员变量说明

◆ sensor_out_format

uint32_t sensor_out_format

camera输出数据类型cm_cam_sensor_fmt

◆ mbus_code

uint16_t mbus_code

多媒体总线数据类型，相机调试时，如果存在色变，可修改该值

◆ width

uint16_t width

camera输出width像素数

◆ height

uint16_t height

camera输出height像素数

◆ hts

uint32_t hts

行周期值

◆ min_vts

uint32_t min_vts

最小场周期值

◆ max_fps

uint8_t max_fps

最大帧率

◆ min_fps

uint8_t min_fps

最小帧率

◆ prop

cm_cam_sensor_res_prop prop

预留参数

◆ regs

cm_cam_sensor_regs regs

模组init代码

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_module结构体 参考

成员变量
cm_cam_sensor_module结构体 参考
Camera

预留参数结构体 更多...

#include <cm_camera_sensor.h>

成员变量

uint32_t | id
char * | name
uint32_t | apeture_size

详细描述

预留参数结构体

结构体成员变量说明

◆ id

uint32_t id

◆ name

char* name

◆ apeture_size

uint32_t apeture_size
该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_isp_tuning_tab结构体 参考

成员变量
cm_isp_tuning_tab结构体 参考
Camera

ISP 寄存器地址组及写入值 更多...

#include <cm_camera_sensor.h>

成员变量

uint16_t | reg
uint16_t | val

详细描述

ISP 寄存器地址组及写入值

结构体成员变量说明

◆ reg

uint16_t reg

寄存器地址

◆ val

uint16_t val

写入值

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_isp_tuning_data结构体 参考

成员变量
cm_isp_tuning_data结构体 参考
Camera

ISP 寄存器操作表 更多...

#include <cm_camera_sensor.h>

成员变量

cm_isp_tuning_tab * tab
uint32_t num

详细描述

ISP 寄存器操作表

结构体成员变量说明

◆ tab

cm_isp_tuning_tab* tab

ISP寄存器操作表，可同时配置多个

◆ num

uint32_t num

ISP寄存器操作表，可同时配置多个

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: cm_cam_sensor_data_t结构体 参考

成员变量
cm_cam_sensor_data_t结构体 参考
Camera

camera驱动结构体 更多...

#include <cm_camera_sensor.h>

成员变量

char *const | name
cm_cam_sensor_spec_ops * ops
int32_t | position
cm_cam_sensor_i2c_attr * i2c_attr
int32_t | num_i2c_attr
cm_cam_sensor_regs id
cm_cam_sensor_global * global_setting
int32_t | num_global
cm_cam_sensor_resolution * res
int32_t | num_res
cm_cam_sensor_regs streamon
cm_cam_sensor_regs streamoff
cm_cam_sensor_regs expo_reg
cm_cam_sensor_regs vts_reg
cm_cam_sensor_regs gain_reg
cm_cam_sensor_regs hflip
cm_cam_sensor_regs vflip
cm_cam_sensor_module * module
int32_t | num_module
cm_isp_tuning_tab * tuning_tab
int32_t | num_tuning_tab
cm_isp_tuning_data | banding_tab [2]
int32_t | interface_type
uint8_t | lane_num
uint8_t | spi_sdr
uint8_t | spi_crc
int32_t | reset_delay
int32_t | cur_i2c_index
int32_t | cur_res_index

详细描述

camera驱动结构体

结构体成员变量说明

◆ name

char* const name

camera名称

◆ ops

cm_cam_sensor_spec_ops* ops

camera操作函数

◆ position

int32_t position

camera相机位置：0 后置，1 前置

◆ i2c_attr

cm_cam_sensor_i2c_attr* i2c_attr

camera i2c参数

◆ num_i2c_attr

int32_t num_i2c_attr

i2c挂载的设备数

◆ id

cm_cam_sensor_regs id

camera id寄存器地址及对应的预期值，用于判断camera是否匹配

◆ global_setting

cm_cam_sensor_global* global_setting

预留参数，暂未使用，可不设置

◆ num_global

int32_t num_global

预留参数，暂未使用,可不设置

◆ res

cm_cam_sensor_resolution* res

camera参数设置及初始化

◆ num_res

int32_t num_res

camera参数设置的组数

◆ streamon

cm_cam_sensor_regs streamon

camera streamon需要用到的寄存器组及写入值

◆ streamoff

cm_cam_sensor_regs streamoff

camera streamoff需要用到的寄存器组及写入值

◆ expo_reg

cm_cam_sensor_regs expo_reg

camera 曝光值需要用到的寄存器组及写入值

◆ vts_reg

cm_cam_sensor_regs vts_reg

camera 场周期值需要用到的寄存器组及写入值，预留值，暂未使用，可不设置

◆ gain_reg

cm_cam_sensor_regs gain_reg

camera 增益需要用到的寄存器组及写入值，预留值，暂未使用，可不设置

◆ hflip

cm_cam_sensor_regs hflip

camera 水平翻转需要用到的寄存器组及写入值，预留值，暂未使用，可不设置

◆ vflip

cm_cam_sensor_regs vflip

camera 垂直翻转需要用到的寄存器组及写入值，预留值，暂未使用，可不设置

◆ module

cm_cam_sensor_module* module

预留参数，暂未使用，可不设置

◆ num_module

int32_t num_module

预留参数，暂未使用，可不设置

◆ tuning_tab

cm_isp_tuning_tab* tuning_tab

ISP 寄存器地址组及写入值，用于ISP图像优化，由芯片厂商提供，一般设置为NULL

◆ num_tuning_tab

int32_t num_tuning_tab

ISP 寄存器地址组数

◆ banding_tab

cm_isp_tuning_data banding_tab[2]

ISP 寄存器地址组及写入值，用于ISP图像优化，由芯片厂商提供，一般设置为NULL

◆ interface_type

int32_t interface_type

camera接口类型，目前只支持设置0（SPI）

◆ lane_num

uint8_t lane_num

camera具体的接口规格，目前只支持设置1（SPI_2_LAN）

◆ spi_sdr

uint8_t spi_sdr

SPI采样模式，0：sdr，即单边采样模式；1：ddr，即双边采样模式

◆ spi_crc

uint8_t spi_crc

ISP crc校验功能，0：不使能crc校验；1: 使能crc校验

◆ reset_delay

int32_t reset_delay

reset延迟，暂未使用，可不设置

◆ cur_i2c_index

int32_t cur_i2c_index

i2c_attr中的I2C外设索引值，即当前使用哪一组i2c_attr

◆ cur_res_index

int32_t cur_res_index

res中的camera参数设置及初始化索引值，即当前使用哪一组res

该结构体的文档由以下文件生成:
  • cm_camera_sensor.h


ML305A_ML307A_OpenCPU_API: CPUINFO

结构体 | 函数 | 变量
CPUINFO

结构体

struct cm_thread_runtime_t

函数

int32_t | cm_cpuinfo_record_start (uint32_t mode)
开始统计CPU运行信息 更多...
int32_t | cm_cpuinfo_record_read (cm_thread_runtime_t info[], uint32_t *cnt, uint32_t *total_tick)
读取统计信息 更多...
int32_t | cm_cpuinfo_record_stop (void)
结束运行信息统计 更多...
const char * | cm_cpuinfo_get_cpuid (void)
获取cpu唯一标识 更多...

变量

osThreadId_t handle
uint32_t | scheduled_cnt
uint32_t | tick_cnt
uint32_t | last_tick

详细描述

函数说明

◆ cm_cpuinfo_record_start()

int32_t cm_cpuinfo_record_start ( uint32_t mode )

开始统计CPU运行信息

参数
[in] mode 统计模式，0：活跃线程；1：全部线程
返回
0：成功
其他：失败

开启记录后线程调度可能受影响

◆ cm_cpuinfo_record_read()

int32_t cm_cpuinfo_record_read | ( | cm_thread_runtime_t | info[],
 |  | uint32_t * | cnt,
 |  | uint32_t * | total_tick
 | ) |  |

读取统计信息

参数
[out] | info | 存储线程信息
[out] | cnt | 线程数量
[out] | total_tick | 从记录开始至读取时CPU的tick计数
返回
0：成功
其他：失败

cpu占用率 = cm_thread_runtime_t->tick_cnt / total_tick * 100%

◆ cm_cpuinfo_record_stop()

int32_t cm_cpuinfo_record_stop ( void )

结束运行信息统计

返回
0：成功
其他：失败

More details

◆ cm_cpuinfo_get_cpuid()

const char* cm_cpuinfo_get_cpuid ( void )

获取cpu唯一标识

返回
非空字符串：成功
NULL：失败

CPU序列号

变量说明

◆ handle

osThreadId_t handle

线程句柄

◆ scheduled_cnt

uint32_t scheduled_cnt

系统调度次数

◆ tick_cnt

uint32_t tick_cnt

累计占用tick计数

◆ last_tick

uint32_t last_tick

线程切入时系统tick计数


ML305A_ML307A_OpenCPU_API: cm_thread_runtime_t结构体 参考

成员变量
cm_thread_runtime_t结构体 参考
CPUINFO

#include <cm_cpuinfo.h>

成员变量

osThreadId_t handle
uint32_t | scheduled_cnt
uint32_t | tick_cnt
uint32_t | last_tick

详细描述

线程信息

该结构体的文档由以下文件生成:
  • cm_cpuinfo.h


ML305A_ML307A_OpenCPU_API: eloop

宏定义 | 类型定义 | 函数
eloop

宏定义

#define CM_ELOOP_WAIT_FOREVER 0xFFFFFFFF

类型定义

typedef struct cm_eloop_t * | cm_eloop_handle_t
typedef struct cm_eloop_event_t * | cm_eloop_event_handle_t
typedef void(* | cm_eloop_event_cb) (cm_eloop_event_handle_t event, void *cb_param)

函数

cm_eloop_handle_t | cm_eloop_default (void)
取得系统默认Event Loop对象 更多...
cm_eloop_handle_t | cm_eloop_create (uint32_t max_num)
创建Event Loop对象 更多...
void | cm_eloop_delete (cm_eloop_handle_t eloop)
删除Event Loop对象 更多...
int32_t | cm_eloop_wait_event (cm_eloop_handle_t eloop, uint32_t timeout)
等待Event触发或者超时时间到达 更多...
cm_eloop_event_handle_t | cm_eloop_register_event (cm_eloop_handle_t eloop, cm_eloop_event_cb event_cb, void *cb_param)
注册事件到Event Loop 更多...
void | cm_eloop_unregister_event (cm_eloop_event_handle_t event)
从Event Loop注销事件 更多...
int32_t | cm_eloop_post_event (cm_eloop_event_handle_t event)
发送事件到Event Loop 更多...

详细描述

宏定义说明

◆ CM_ELOOP_WAIT_FOREVER

#define CM_ELOOP_WAIT_FOREVER 0xFFFFFFFF

表示timeout不超时

类型定义说明

◆ cm_eloop_handle_t

typedef struct cm_eloop_t* cm_eloop_handle_t

◆ cm_eloop_event_handle_t

typedef struct cm_eloop_event_t* cm_eloop_event_handle_t

◆ cm_eloop_event_cb

typedef void(* cm_eloop_event_cb) (cm_eloop_event_handle_t event, void *cb_param)

Event Loop回调函数类型

参数
event | [in] 事件对象
cb_param | [in] 用户参数

函数说明

◆ cm_eloop_default()

cm_eloop_handle_t cm_eloop_default ( void )

取得系统默认Event Loop对象

返回
Event Loop对象

返回系统默认Event Loop对象

◆ cm_eloop_create()

cm_eloop_handle_t cm_eloop_create ( uint32_t max_num )

创建Event Loop对象

参数
[in] max_num 最大可注册的事件个数
返回

Event Loop对象或NULL

创建Event Loop对象(分配资源)

◆ cm_eloop_delete()

void cm_eloop_delete ( cm_eloop_handle_t eloop )

删除Event Loop对象

参数
[in] eloop 要释放的Event Loop对象

删除Event Loop对象(释放资源)

◆ cm_eloop_wait_event()

int32_t cm_eloop_wait_event | ( | cm_eloop_handle_t | eloop,
 |  | uint32_t | timeout
 | ) |  |

等待Event触发或者超时时间到达

参数
[in] | eloop | Event Loop对象
[in] | timeout | 超时时间(ms), CM_ELOOP_WAIT_FOREVER表示不超时
返回

0 - 已触发的事件个数

= 0 - 超时
< 0 - 出错

挂起当前线程, 等待注册的任意Event触发或者超时时间到达
如果有Event触发, 将在处理完对应的事件回调函数后再返回

◆ cm_eloop_register_event()

cm_eloop_event_handle_t cm_eloop_register_event | ( | cm_eloop_handle_t | eloop,
 |  | cm_eloop_event_cb | event_cb,
 |  | void * | cb_param
 | ) |  |

注册事件到Event Loop

参数
[in] | eloop | 要运行的Event Loop对象
[in] | event_cb | 事件回调函数
[in] | cb_param | 回调函数用户参数
返回

Event 对象或NULL

◆ cm_eloop_unregister_event()

void cm_eloop_unregister_event ( cm_eloop_event_handle_t event )

从Event Loop注销事件

参数
[in] event 要注销的事件

◆ cm_eloop_post_event()

int32_t cm_eloop_post_event ( cm_eloop_event_handle_t event )

发送事件到Event Loop

参数
[in] event 要发送的事件
返回

= 0 - 成功
< 0 - 失败


ML305A_ML307A_OpenCPU_API: fota

结构体 | 宏定义 | 类型定义 | 枚举 | 枚举值 | 函数 | 变量
fota

结构体

struct | cm_fota_reboot_time
struct | cm_fota_extendible_info_t
struct | cm_fota_info_fixed_t
struct | cm_fota_info_t

宏定义

#define | CM_FOTA_STRING_LEN 48
#define | CM_FOTA_LONG_STRING_LEN 256
#define | CM_FOTA_FIXED_RESERVED_LEN (512 - 8 - CM_FOTA_LONG_STRING_LEN - 2 * CM_FOTA_STRING_LEN)

类型定义

typedef void(* cm_fota_result_callback) (cm_fota_error_e error)
fota结果回调函数 更多...

枚举

enum cm_fota_error_e {
CM_FOTA_CMIOT_ERROR_UNKNOW = 850 , CM_FOTA_CMIOT_ERROR_CONFIG_FILE , CM_FOTA_CMIOT_ERROR_URL_TYPE , CM_FOTA_CMIOT_ERROR_WRITE_CONFIG ,
CM_FOTA_CMIOT_ERROR_UPDATE , CM_FOTA_CMIOT_ERROR_DOWNLOAD , CM_FOTA_CMIOT_ERROR_DOWNLOAD_MAX_RETRY , CM_FOTA_CMIOT_ERROR_NO_NETWORK
}
enum | cm_fota_asr_plan_e { CM_FOTA_ASR_PLAN_INVALID = 0 , CM_FOTA_ASR_PLAN_MINI_INTEGRATE , CM_FOTA_ASR_PLAN_MINI , CM_FOTA_ASR_PLAN_PRO }
enum | cm_fota_url_type_e { CM_FOTA_TYPE_INVALID = 0 , CM_FOTA_TYPE_FTP , CM_FOTA_TYPE_HTTP_HTTPS }
enum cm_fota_stage_e {
CM_FOTA_STAGE_NONE = 0 , CM_FOTA_STAGE_START , CM_FOTA_STAGE_BIN1_OTA , CM_FOTA_STAGE_BIN1_SUCC ,
CM_FOTA_STAGE_ERR_ALLOW_RETRY , CM_FOTA_STAGE_SUCC , CM_FOTA_INTEGRATE_STAGE_START , CM_FOTA_INTEGRATE_STAGE_BIN2 ,
CM_FOTA_STAGE_ERR
}

函数

int | cm_fota_set_url (char *url)
设置FOTA服务器url 更多...
int | cm_fota_set_auth (const char *username, const char *passwd)
设置FOTA服务器登录名和密码（仅FTP方式） 更多...
int | cm_fota_set_reboot_time (cm_fota_reboot_time *time)
设置FOTA失败时的下一次重启时间（重启后会继续尝试升级） 更多...
void | cm_fota_read_config (cm_fota_info_t *cfg)
获取FOTA服务器配置 更多...
void | cm_fota_set_ota_plan (cm_fota_asr_plan_e ota_plan)
配置FOTA OTA升级方案 更多...
cm_fota_asr_plan_e | cm_fota_get_ota_plan (void)
获取FOTA OTA升级方案 更多...
void | cm_fota_res_callback_register (cm_fota_result_callback cb)
SDK注册fota结果回调 更多...
int | cm_fota_exec_upgrade (void)
进入mini system执行fota升级 更多...

变量

int | first_timeout
int | second_timeout
int | third_timeout
int | fourth_timeout
int | fifth_timeout
int | sixth_timeout
int | constant_timeout
int | isSetTimeout
int | failure
cm_fota_reboot_time timeout
cm_fota_stage_e stage
cm_fota_url_type_e fota_mode
char | url [CM_FOTA_LONG_STRING_LEN]
char | username [CM_FOTA_STRING_LEN]
char | passwd [CM_FOTA_STRING_LEN]
char | reserved [CM_FOTA_FIXED_RESERVED_LEN]
cm_fota_info_fixed_t fixed_info
cm_fota_extendible_info_t extend_info

详细描述

宏定义说明

◆ CM_FOTA_STRING_LEN

#define CM_FOTA_STRING_LEN 48

◆ CM_FOTA_LONG_STRING_LEN

#define CM_FOTA_LONG_STRING_LEN 256

◆ CM_FOTA_FIXED_RESERVED_LEN

#define CM_FOTA_FIXED_RESERVED_LEN (512 - 8 - CM_FOTA_LONG_STRING_LEN - 2 * CM_FOTA_STRING_LEN)

类型定义说明

◆ cm_fota_result_callback

typedef void(* cm_fota_result_callback) (cm_fota_error_e error)

fota结果回调函数

参数
[in] error 错误码

整包 mini FOTA方案下，模组运行在大系统时，fota出现错误时才会回调

枚举类型说明

◆ cm_fota_error_e

enum cm_fota_error_e

FOTA相关结构体

枚举值
CM_FOTA_CMIOT_ERROR_UNKNOW
CM_FOTA_CMIOT_ERROR_CONFIG_FILE
CM_FOTA_CMIOT_ERROR_URL_TYPE
CM_FOTA_CMIOT_ERROR_WRITE_CONFIG
CM_FOTA_CMIOT_ERROR_UPDATE
CM_FOTA_CMIOT_ERROR_DOWNLOAD
CM_FOTA_CMIOT_ERROR_DOWNLOAD_MAX_RETRY
CM_FOTA_CMIOT_ERROR_NO_NETWORK

◆ cm_fota_asr_plan_e

enum cm_fota_asr_plan_e
枚举值
CM_FOTA_ASR_PLAN_INVALID | 不可用
CM_FOTA_ASR_PLAN_MINI_INTEGRATE | ASR 整包 mini FOTA方案，推荐用户使用该方案
CM_FOTA_ASR_PLAN_MINI | ASR 2包 mini FOTA方案，兼容老用户方案，新用户不建议使用该方案
CM_FOTA_ASR_PLAN_PRO | ASR PRO FOTA方案，不支持

◆ cm_fota_url_type_e

enum cm_fota_url_type_e
枚举值
CM_FOTA_TYPE_INVALID
CM_FOTA_TYPE_FTP
CM_FOTA_TYPE_HTTP_HTTPS

◆ cm_fota_stage_e

enum cm_fota_stage_e
枚举值
CM_FOTA_STAGE_NONE | 无FOTA
CM_FOTA_STAGE_START | 开始阶段,准备下载bin1文件
CM_FOTA_STAGE_BIN1_OTA | bin1文件下载完成,准备bootloader ota
CM_FOTA_STAGE_BIN1_SUCC | bootloader ota完成,准备下载bin2文件
CM_FOTA_STAGE_ERR_ALLOW_RETRY | FOTA失败,重启后运行再次尝试,一般是下载出错,可能与网络相关
CM_FOTA_STAGE_SUCC | FOTA完成
CM_FOTA_INTEGRATE_STAGE_START | FOTA mini整包升级方案开始
CM_FOTA_INTEGRATE_STAGE_BIN2 | FOTA mini整包升级方案开始下载bin2
CM_FOTA_STAGE_ERR | FOTA失败

函数说明

◆ cm_fota_set_url()

int cm_fota_set_url ( char * url )

设置FOTA服务器url

参数
[in] url 服务器url
返回
= 0 - 成功
其他 - 失败

字符串，可为HTTP服务器、FTP服务器，最大256字节，url中必须指定协议类型，比如"ftp://xxx.com:23/update1.bin_1"或"http://xxx.com:8080/update2.bin_1"
ML307A-DCLN ML307A-GCLN ML305A-DC支持HTTP（含HTTPS无证书校验）下载方式，ML307A-DSLN ML307A-GSLN ML305A-DS支持HTTP（含HTTPS无证书校验）、FTP下载方式，不支持FTPS下载方式
本平台使用双包升级方式（存在两个升级包）时，url中下载的文件名必须以.bin_1结尾，且.bin_1与.bin_2文件的名称必须一致，比如system_patch.bin_1和system_patch.bin_2
本平台使用完整包升级方式（存在一个升级包）时，url中下载的文件名无要求
FTP下载不支持ipv6方式，不可使用ipv6地址
设置的url须为可以直接访问的服务器地址，最小系统中无法处理服务器重定向操作

◆ cm_fota_set_auth()

int cm_fota_set_auth | ( | const char * | username,
 |  | const char * | passwd
 | ) |  |

设置FOTA服务器登录名和密码（仅FTP方式）

参数
[in] | username | 登录名
[in] | passwd | 密码
返回
= 0 - 成功
其他 - 失败

仅FTP下载方式适用，HTTP下载方式不适用

◆ cm_fota_set_reboot_time()

int cm_fota_set_reboot_time ( cm_fota_reboot_time * time )

设置FOTA失败时的下一次重启时间（重启后会继续尝试升级）

参数
[in] time 重启时间结构体（详情见cm_fota_reboot_time结构体定义）
返回
= 0 - 成功
其他 - 失败

FOTA过程会分别升级最小系统和应用APP，两者任一升级失败均会触发重启机制
定时起始时间为尝试FOTA升级的时间，非检测到FOTA失败的时间。例如，设置下一次重启时间为15分钟，模组8:30分尝试FOTA，8:35分检测到FOTA失败，则下一次重启时间为8:45分
下一次重启时间默认（用户未设置时）为{5，10, 20, 30, 40, 50，120}

◆ cm_fota_read_config()

void cm_fota_read_config ( cm_fota_info_t * cfg )

获取FOTA服务器配置

参数
[out] cfg 服务器配置

该接口用于查询fota_mode、url、username、passwd，不适用于查询stage及其他

◆ cm_fota_set_ota_plan()

void cm_fota_set_ota_plan ( cm_fota_asr_plan_e ota_plan )

配置FOTA OTA升级方案

参数
[in] ota_plan : CM_FOTA_ASR_PLAN_MINI_INTEGRATE - mini整包方案, CM_FOTA_ASR_PLAN_MINI - mini双包方案

未配置时，默认为mini整包方案

◆ cm_fota_get_ota_plan()

cm_fota_asr_plan_e cm_fota_get_ota_plan ( void )

获取FOTA OTA升级方案

返回
OTA升级方案

◆ cm_fota_res_callback_register()

void cm_fota_res_callback_register ( cm_fota_result_callback cb )

SDK注册fota结果回调

返回
void

用于大系统执行FOTA升级任务预校验时将结果反馈给SDK用户应用程序,callback可由客户定制
该接口仅适用于整包 mini FOTA方案（CM_FOTA_ASR_PLAN_MINI_INTEGRATE），不适用于2包 mini FOTA方案

◆ cm_fota_exec_upgrade()

int cm_fota_exec_upgrade ( void )

进入mini system执行fota升级

返回
= 0 - 成功
< 0 - 失败

一次FOTA期间模组会重启4次，需要数分钟时间。若每阶段触发该阶段任务超时未完成逻辑，则重启次数会相应增加
请至少在OpenCPU程序运行5秒中后再执行该接口，开机立即执行可能会因底层最小系统未完成初始化造成失败
fota升级前，配置url会进行文件系统操作，若文件系统剩余空间较小配置url可能会失败。建议使用fota功能的用户在文件系统中至少留有4096字节剩余空间（cm_fs_getinfo()接口可查询）

变量说明

◆ first_timeout

int first_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第一次尝试重启的超时时间

◆ second_timeout

int second_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第二次尝试重启的超时时间

◆ third_timeout

int third_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第三次尝试重启的超时时间

◆ fourth_timeout

int fourth_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第四次尝试重启的超时时间

◆ fifth_timeout

int fifth_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第五次尝试重启的超时时间

◆ sixth_timeout

int sixth_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第六次尝试重启的超时时间

◆ constant_timeout

int constant_timeout

单位：分钟；范围：3分钟至3天（3~3*24*60）；含义：一次升级期间任一阶段升级失败或超时未完成时，第七次及之后的尝试重启的超时时间

◆ isSetTimeout

int isSetTimeout

用户是否设置重启时间。非0：用户已成功设置；0：用户未设置或设置不合法，采用默认参数

◆ failure

int failure

失败次数

◆ timeout

cm_fota_reboot_time timeout

用户配置时间参数

◆ stage

cm_fota_stage_e stage

FOTA升级进行状态

◆ fota_mode

cm_fota_url_type_e fota_mode

fota升级模式

◆ url

char url[CM_FOTA_LONG_STRING_LEN]

服务器url

◆ username

char username[CM_FOTA_STRING_LEN]

用户名

◆ passwd

char passwd[CM_FOTA_STRING_LEN]

密码

◆ reserved

char reserved[CM_FOTA_FIXED_RESERVED_LEN]

◆ fixed_info

cm_fota_info_fixed_t fixed_info

FOTA配置保存NV固定部分结构

◆ extend_info

cm_fota_extendible_info_t extend_info

FOTA配置保存NV可扩展部分结构


ML305A_ML307A_OpenCPU_API: cm_fota_reboot_time结构体 参考

成员变量
cm_fota_reboot_time结构体 参考
fota

#include <cm_fota.h>

成员变量

int | first_timeout
int | second_timeout
int | third_timeout
int | fourth_timeout
int | fifth_timeout
int | sixth_timeout
int | constant_timeout

详细描述

重启时间结构体类型 FOTA机制为分别升级最小系统和应用APP，共计需要四个阶段，每个阶段任务完成后系统会适当延时保存数据后自动重启并进入下一阶段，正常情况下模组一次完整的FOTA升级需要经历4次重启
若模组FOTA过程中任一阶段失败或超时，则需要重启模组（重启模组后模组会重新尝试完成本阶段的任务），此场景下的重启时间由cm_fota_set_reboot_time()接口设置
开始计时时间为尝试FOTA的开始时间，非检测到FOTA失败的时间（超时未完成该阶段升级任务也是失败）。例如，尝试重启的超时时间为15分钟，模组8:30分尝试FOTA，8:35分检测到FOTA失败，则下一次重启时间为8:45分
网络较差或升级包较大时，尝试重启的超时时间不宜设置过短。例如，某场景下下载升级包的时间需要5分钟，则设置的时间建议至少为6分钟
默认（用户未设置时）为{5，10, 20, 30, 40, 50，120}，即在一直FOTA失败的场景下，模组首次失败（或超时未完成任务）5分钟后自行重启并重新尝试FOTA，再失败则10分钟后重启，之后分别是20分钟、30分钟、40分钟、50分钟、120分钟、120分钟、120分钟...

该结构体的文档由以下文件生成:
  • cm_fota.h


ML305A_ML307A_OpenCPU_API: cm_fota_extendible_info_t结构体 参考

成员变量
cm_fota_extendible_info_t结构体 参考
fota

#include <cm_fota.h>

成员变量

int | isSetTimeout
int | failure
cm_fota_reboot_time timeout
该结构体的文档由以下文件生成:
  • cm_fota.h


ML305A_ML307A_OpenCPU_API: cm_fota_info_fixed_t结构体 参考

成员变量
cm_fota_info_fixed_t结构体 参考
fota

#include <cm_fota.h>

成员变量

cm_fota_stage_e stage
cm_fota_url_type_e fota_mode
char | url [CM_FOTA_LONG_STRING_LEN]
char | username [CM_FOTA_STRING_LEN]
char | passwd [CM_FOTA_STRING_LEN]
char | reserved [CM_FOTA_FIXED_RESERVED_LEN]
该结构体的文档由以下文件生成:
  • cm_fota.h


ML305A_ML307A_OpenCPU_API: cm_fota_info_t结构体 参考

成员变量
cm_fota_info_t结构体 参考
fota

#include <cm_fota.h>

成员变量

cm_fota_info_fixed_t fixed_info
cm_fota_extendible_info_t extend_info
该结构体的文档由以下文件生成:
  • cm_fota.h


ML305A_ML307A_OpenCPU_API: Fs

结构体 | 宏定义 | 函数
Fs

结构体

struct cm_fs_system_info_t

宏定义

#define | CM_FS_RB (0)
#define | CM_FS_WB (1)
#define | CM_FS_AB (2)
#define | CM_FS_WBPLUS (3)
#define | CM_FS_ABPLUS (4)
#define | CM_FS_RBPLUS (5)
#define | CM_FS_SEEK_SET (0)
#define | CM_FS_SEEK_CUR (1)
#define | CM_FS_SEEK_END (2)

函数

int32_t | cm_fs_open (const char *filename, int32_t flag)
打开一个文件 更多...
int32_t | cm_fs_close (int32_t fd)
关闭一个文件 更多...
int32_t | cm_fs_read (int32_t fd, void *buf, uint32_t size)
读取文件内容 更多...
int32_t | cm_fs_write (int32_t fd, const void *buf, uint32_t size)
写入文件内容 更多...
int32_t | cm_fs_seek (int32_t fd, int32_t offset, int32_t base)
文件指针定位 更多...
int32_t | cm_fs_delete (const char *file_name)
删除文件 更多...
int32_t | cm_fs_move (const char *src, const char *dest)
更改文件名 更多...
int32_t | cm_fs_exist (const char *file_name)
检查文件是否存在 更多...
int32_t | cm_fs_filesize (const char *file_name)
获取文件大小 更多...
int32_t | cm_fs_getinfo (cm_fs_system_info_t *info)
获取文件系统信息 更多...

详细描述

宏定义说明

◆ CM_FS_RB

#define CM_FS_RB (0)

rb，打开一个二进制文件，文件必须存在，只允许读

◆ CM_FS_WB

#define CM_FS_WB (1)

wb，新建一个二进制文件，已存在的文件内容清空，只允许写

◆ CM_FS_AB

#define CM_FS_AB (2)

ab，打开或新建一个二进制文件，只允许在文件末尾追写

◆ CM_FS_WBPLUS

#define CM_FS_WBPLUS (3)

wb+，新建一个二进制文件，已存在的文件内容清空，允许读写

◆ CM_FS_ABPLUS

#define CM_FS_ABPLUS (4)

ab+，打开或新建一个二进制文件，可读，只允许在文件末尾追写

◆ CM_FS_RBPLUS

#define CM_FS_RBPLUS (5)

rb+，打开一个二进制文件，文件必须存在，允许读写

◆ CM_FS_SEEK_SET

#define CM_FS_SEEK_SET (0)

SEEK_SET，文件开头

◆ CM_FS_SEEK_CUR

#define CM_FS_SEEK_CUR (1)

SEEK_CUR，当前位置

◆ CM_FS_SEEK_END

#define CM_FS_SEEK_END (2)

SEEK_END，文件结尾

函数说明

◆ cm_fs_open()

int32_t cm_fs_open | ( | const char * | filename,
 |  | int32_t | flag
 | ) |  |

打开一个文件

参数
[in] | filename | 文件名称
[in] | flag | 打开参数
返回
>= 0 - 文件描述符
< 0 - 错误

文件系统中无路径/文件夹功能，勿在filename入参中传入路径信息

◆ cm_fs_close()

int32_t cm_fs_close ( int32_t fd )

关闭一个文件

参数
[in] fd 文件描述符
返回
= 0 - 成功
< 0 - 失败

◆ cm_fs_read()

int32_t cm_fs_read | ( | int32_t | fd,
 |  | void * | buf,
 |  | uint32_t | size
 | ) |  |

读取文件内容

参数
[in] | fd | 文件描述符
[out] | buf | 存储数据的缓冲区指针
[in] | size | 要读取的数据长度
返回
>= 0 - 实际的读取长度
< 0 - 读取失败

◆ cm_fs_write()

int32_t cm_fs_write | ( | int32_t | fd,
 |  | const void * | buf,
 |  | uint32_t | size
 | ) |  |

写入文件内容

参数
[in] | fd | 文件描述符
[in] | buf | 存储数据的缓冲区指针
[in] | size | 要写入的数据长度
返回
>= 0 - 实际的写入长度
< 0 - 写入失败

◆ cm_fs_seek()

int32_t cm_fs_seek | ( | int32_t | fd,
 |  | int32_t | offset,
 |  | int32_t | base
 | ) |  |

文件指针定位

参数
[in] | fd | 文件描述符
[in] | offset | 指针偏移量
[in] | base | 偏移起始点，CM_FS_SEEK_SET：文件开头 CM_FS_SEEK_CUR：当前位置 CM_FS_SEEK_END：文件末尾
返回
= 0 - 成功
< 0 - 失败

offset不支持为负数

◆ cm_fs_delete()

int32_t cm_fs_delete ( const char * file_name )

删除文件

参数
[in] file_name 文件路径
返回
>= 0 - 成功
< 0 - 失败

◆ cm_fs_move()

int32_t cm_fs_move | ( | const char * | src,
 |  | const char * | dest
 | ) |  |

更改文件名

参数
[in] | src | 原文件名
[in] | dest | 新文件名
返回
= 0 - 成功
< 0 - 失败

◆ cm_fs_exist()

int32_t cm_fs_exist ( const char * file_name )

检查文件是否存在

参数
[in] file_name 文件名称
返回
= 1 - 存在
= 0 - 不存在

文件系统中无路径/文件夹功能，勿在path入参中传入路径信息

◆ cm_fs_filesize()

int32_t cm_fs_filesize ( const char * file_name )

获取文件大小

参数
[in] file_name 文件路径
返回

>= 0 - 文件长度
< 0 - 操作失败

More details

◆ cm_fs_getinfo()

int32_t cm_fs_getinfo ( cm_fs_system_info_t * info )

获取文件系统信息

参数
[out] info 文件系统信息
返回
= 0 - 成功
< 0 - 失败


ML305A_ML307A_OpenCPU_API: cm_fs_system_info_t结构体 参考

成员变量
cm_fs_system_info_t结构体 参考
Fs

#include <cm_fs.h>

成员变量

uint32_t | free_size
uint32_t | total_size

结构体成员变量说明

◆ free_size

uint32_t free_size

当前可用文件系统大小

◆ total_size

uint32_t total_size

文件系统总大小

该结构体的文档由以下文件生成:
  • cm_fs.h


ML305A_ML307A_OpenCPU_API: FTP

结构体 | 枚举 | 函数
FTP

结构体

struct | cm_ftp_config_t
struct | cm_ftp_file_data_t

枚举

enum cm_ftp_state_e { FTP_STATE_DISCONNECTED = 0 , FTP_STATE_CONNECTED , FTP_STATE_GETTING , FTP_STATE_PUTTING }

函数

int32_t | cm_ftp_open (cm_ftp_config_t *config)
打开一个FTP连接 更多...
int32_t | cm_ftp_close (int32_t handle)
关闭一个FTP连接 更多...
int32_t | cm_ftp_create_dir (int32_t handle, const char *dir)
在服务器上创建文件夹 更多...
int32_t | cm_ftp_remove_dir (int32_t handle, const char *dir)
删除服务器上的文件夹 更多...
int32_t | cm_ftp_delete_file (int32_t handle, const char *file)
删除服务器上指定文件 更多...
int32_t | cm_ftp_set_current_dir (int32_t handle, const char *dir)
设置服务器上的当前工作目录 更多...
int32_t | cm_ftp_get_current_dir (int32_t handle, char *dir)
获取服务器上的当前工作目录 更多...
int32_t | cm_ftp_rename_file (int32_t handle, const char *old_file, const char *new_file)
重命名文件 更多...
int32_t | cm_ftp_get_file_size (int32_t handle, const char *file)
获取文件大小 更多...
int32_t | cm_ftp_find_first (int32_t handle, const char *path, cm_ftp_file_data_t *file_data)
FTP打开查找，并且获取文件夹下第一个文件或文件夹目录信息 更多...
int32_t | cm_ftp_find_next (int32_t handle, int32_t find_fd, cm_ftp_file_data_t *file_data)
FTP获取文件夹下文件信息 更多...
int32_t | cm_ftp_find_close (int32_t handle, int32_t find_fd)
关闭查找 更多...
int32_t | cm_ftp_get_file (int32_t handle, int32_t data_type, const char *file, int32_t offset, uint8_t *data, uint32_t len)
FTP从服务器获取文件 更多...
int32_t | cm_ftp_put_file (int32_t handle, int32_t mode, char *file, uint8_t *data, uint32_t len)
FTP向服务器推送文件 更多...
cm_ftp_state_e | cm_ftp_get_state (int32_t handle)
获取FTP连接状态 更多...

详细描述

枚举类型说明

◆ cm_ftp_state_e

enum cm_ftp_state_e

FTP状态

枚举值
FTP_STATE_DISCONNECTED | FTP连接断开
FTP_STATE_CONNECTED | FTP连接建立
FTP_STATE_GETTING | FTP正在下载文件
FTP_STATE_PUTTING | FTP正在上传文件

函数说明

◆ cm_ftp_open()

int32_t cm_ftp_open ( cm_ftp_config_t * config )

打开一个FTP连接

参数
[in] config FTP配置
返回
>= 0 - FTP连接句柄
< 0 - 错误

◆ cm_ftp_close()

int32_t cm_ftp_close ( int32_t handle )

关闭一个FTP连接

参数
[in] handle FTP连接句柄
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_create_dir()

int32_t cm_ftp_create_dir | ( | int32_t | handle,
 |  | const char * | dir
 | ) |  |

在服务器上创建文件夹

参数
[in] | handle | FTP连接句柄
[in] | dir | 要创建的文件夹
返回
= 0 - 成功
< 0 - 错误

◆ cm_ftp_remove_dir()

int32_t cm_ftp_remove_dir | ( | int32_t | handle,
 |  | const char * | dir
 | ) |  |

删除服务器上的文件夹

参数
[in] | handle | FTP连接句柄
[in] | dir | 文件夹路径
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_delete_file()

int32_t cm_ftp_delete_file | ( | int32_t | handle,
 |  | const char * | file
 | ) |  |

删除服务器上指定文件

参数
[in] | handle | FTP连接句柄
[in] | file | 文件路径
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_set_current_dir()

int32_t cm_ftp_set_current_dir | ( | int32_t | handle,
 |  | const char * | dir
 | ) |  |

设置服务器上的当前工作目录

参数
[in] | handle | FTP连接句柄
[in] | dir | 工作目录路径
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_get_current_dir()

int32_t cm_ftp_get_current_dir | ( | int32_t | handle,
 |  | char * | dir
 | ) |  |

获取服务器上的当前工作目录

参数
[in] | handle | FTP连接句柄
[out] | dir | 保存工作目录路径的指针
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_rename_file()

int32_t cm_ftp_rename_file | ( | int32_t | handle,
 |  | const char * | old_file,
 |  | const char * | new_file
 | ) |  |

重命名文件

参数
[in] | handle | FTP连接句柄
[in] | old_file | 原文件路径
[in] | new_file | 新文件路径
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_get_file_size()

int32_t cm_ftp_get_file_size | ( | int32_t | handle,
 |  | const char * | file
 | ) |  |

获取文件大小

参数
[in] | handle | FTP连接句柄
[in] | file | 文件路径
返回
>= 0 - 文件大小
< 0 - 失败

◆ cm_ftp_find_first()

int32_t cm_ftp_find_first | ( | int32_t | handle,
 |  | const char * | path,
 |  | cm_ftp_file_data_t * | file_data
 | ) |  |

FTP打开查找，并且获取文件夹下第一个文件或文件夹目录信息

参数
[in] | handle | FTP连接句柄
[in] | path | 文件夹路径
[out] | file_data | 对应路径下的第一个文件或（相对）路径信息
返回
>= 0 - 查找返回的FTP查找句柄
< 0 - 查找失败

◆ cm_ftp_find_next()

int32_t cm_ftp_find_next | ( | int32_t | handle,
 |  | int32_t | find_fd,
 |  | cm_ftp_file_data_t * | file_data
 | ) |  |

FTP获取文件夹下文件信息

参数
[in] | handle | FTP连接句柄
[in] | find_fd | 查找句柄（cm_ftp_find_first接口返回值）
[out] | file_data | 对应路径下的下一个文件或文件夹目录信息
返回
>= 0 - 还有文件或文件夹目录
< 0 - 没有剩余文件或文件夹目录

◆ cm_ftp_find_close()

int32_t cm_ftp_find_close | ( | int32_t | handle,
 |  | int32_t | find_fd
 | ) |  |

关闭查找

参数
[in] | handle | FTP连接句柄
[in] | find_fd | 查找句柄（cm_ftp_find_first接口返回值）
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_get_file()

int32_t cm_ftp_get_file | ( | int32_t | handle,
 |  | int32_t | data_type,
 |  | const char * | file,
 |  | int32_t | offset,
 |  | uint8_t * | data,
 |  | uint32_t | len
 | ) |  |

FTP从服务器获取文件

参数
[in] | handle | FTP连接句柄
[in] | data_type | FTP数据传输类型，0：Binary，1：ASCII
[in] | file | 要获取的文件路径
[in] | offset | 获取内容的偏移量
[out] | data | 存储获取内容的地址
[in] | len | 要获取的长度
返回
>= 0 - 实际获取的长度
< 0 - 失败

data_type未生效，传输类型实际生效参数为cm_ftp_open传入的配置参数

◆ cm_ftp_put_file()

int32_t cm_ftp_put_file | ( | int32_t | handle,
 |  | int32_t | mode,
 |  | char * | file,
 |  | uint8_t * | data,
 |  | uint32_t | len
 | ) |  |

FTP向服务器推送文件

参数
[in] | handle | FTP连接句柄
[in] | mode | 0:新建或覆盖 1：新建或追加
[in] | file | 要传输的文件路径
[in] | data | 要传输的文件数据指针
[in] | len | 要传输的文件数据长度
返回
= 0 - 成功
< 0 - 失败

◆ cm_ftp_get_state()

cm_ftp_state_e cm_ftp_get_state ( int32_t handle )

获取FTP连接状态

参数
[in] handle FTP连接句柄
返回
FTP连接状态，参考cm_ftp_state_e


ML305A_ML307A_OpenCPU_API: cm_ftp_config_t结构体 参考

成员变量
cm_ftp_config_t结构体 参考
FTP

#include <cm_ftp.h>

成员变量

uint8_t * | url
int32_t | port
uint8_t * | username
uint8_t * | passwd
int32_t | trans_mode
int32_t | data_type
int32_t | rsptimeout
int32_t | ssl_mode
int32_t | ssl_id
int32_t | cid

详细描述

FTP配置

结构体成员变量说明

◆ url

uint8_t* url

FTP服务器URL或IP

◆ port

int32_t port

FTP服务器端口

◆ username

uint8_t* username

FTP服务器用户名

◆ passwd

uint8_t* passwd

FTP服务器密码

◆ trans_mode

int32_t trans_mode

FTP传输模式，0：主动模式，1：被动模式。（该参数不生效，目前仅支持被动模式）

◆ data_type

int32_t data_type

FTP数据传输类型，0：Binary，1：ASCII

◆ rsptimeout

int32_t rsptimeout

FTP响应超时时间，单位ms，建议设置为1s以上

◆ ssl_mode

int32_t ssl_mode

FTP SSL模式，0：无SSL（目前不支持SSL）

◆ ssl_id

int32_t ssl_id

FTP SSL通道ID，取值范围参考SSL模块（目前不支持SSL）

◆ cid

int32_t cid

FTP PDP通道ID

该结构体的文档由以下文件生成:
  • cm_ftp.h


ML305A_ML307A_OpenCPU_API: cm_ftp_file_data_t结构体 参考

成员变量
cm_ftp_file_data_t结构体 参考
FTP

#include <cm_ftp.h>

成员变量

uint32_t | file_attr
uint32_t | file_size
uint8_t | file_name [256]
uint8_t | file_permision
uint32_t | file_modify_time

详细描述

FTP文件信息

结构体成员变量说明

◆ file_attr

uint32_t file_attr

0：（相对）路径 1：文件

◆ file_size

uint32_t file_size

file_attr = 1时为文件大小，否则该参数无效

◆ file_name

uint8_t file_name[256]

file_attr = 1时为文件名称， file_attr = 0时为（相对）路径名称

◆ file_permision

uint8_t file_permision

第0位代表是否可执行，第1位代表是否可写，第2位代表是否可读。0：是 1：否

◆ file_modify_time

uint32_t file_modify_time

修改时间，unix时间戳

该结构体的文档由以下文件生成:
  • cm_ftp.h


ML305A_ML307A_OpenCPU_API: Gnss

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
Gnss

结构体

struct | cm_agnss_location_t
struct | cm_gnss_location_info_t

宏定义

#define | CM_GNSS_NAME_GGA (1<<0)
#define | CM_GNSS_NAME_GSV (1<<1)
#define | CM_GNSS_NAME_GSA (1<<2)
#define | CM_GNSS_NAME_RMC (1<<3)
#define | CM_GNSS_NAME_VTG (1<<4)
#define | CM_GNSS_NAME_GLL (1<<5)
#define | CM_GNSS_NAME_ZDA (1<<6)
#define | CM_GNSS_NAME_DTM (1<<7)
#define | CM_GNSS_NAME_GNS (1<<8)
#define | CM_GNSS_NAME_GRS (1<<9)
#define | CM_GNSS_NAME_GST (1<<10)
#define | CM_GNSS_NAME_GBS (1<<11)
#define | CM_GNSS_NAME_TXT (1<<12)

类型定义

typedef void(* | cm_gnss_nmea_callback) (uint32_t type, const char *nmea, uint32_t len)
NMEA信息回调函数 更多...
typedef void(* | cm_agnss_data_callback) (cm_agnss_update_result_e mode, const char *update_time, uint32_t size)
辅助信息更新结果回调函数 更多...
typedef void(* | cm_gnss_rawdata_rsp_callback) (const char *data, uint32_t len)
发送透传信息给GPS芯片返回结果回调函数 更多...

枚举

enum | cm_agnss_enable_e { CM_AGNSS_DISABLE = 1 , CM_AGNSS_ENABLE }
enum cm_gnss_type_e {
CM_GNSS_GPS = 1 , CM_GNSS_BDS , CM_GNSS_GLONASS , CM_GNSS_BDS_GPS ,
CM_GNSS_GPS_GLONASS , CM_GNSS_BDS_GLONASS , CM_GNSS_BDS_GPS_GLONASS
}
enum cm_gnss_config_type_e {
CM_GNSS_CONFIG_TYPE_NMEA_MASK = 1 , CM_GNSS_CONFIG_TYPE_NMEA_CYCLE , CM_GNSS_CONFIG_TYPE_NMEA_PORT , CM_GNSS_CONFIG_TYPE_AGNSS_LOCATION ,
CM_GNSS_CONFIG_TYPE_AGNSS_TIME , CM_GNSS_CONFIG_TYPE_AGNSS_URL , CM_GNSS_CONFIG_TYPE_AGNSS_INTERVAL , CM_GNSS_CONFIG_TYPE_DGNSS_URL ,
CM_GNSS_CONFIG_TYPE_DGNSS_USER , CM_GNSS_CONFIG_TYPE_DGNSS_PWD , CM_GNSS_CONFIG_TYPE_DGNSS_MOUNT , CM_GNSS_CONFIG_TYPE_DGNSS_INTERVAL ,
CM_GNSS_CONFIG_TYPE_SLEEP
}
enum | cm_agnss_update_result_e { CM_AGNSS_UPDATE_INVALID = 0 , CM_AGNSS_UPDATE_VALID , CM_AGNSS_UPDATE_FAIL_JUDGE , CM_AGNSS_UPDATE_VOID }

函数

int32_t | cm_gnss_open (cm_gnss_type_e gnss_type, cm_agnss_enable_e agnss_enable)
gnss 功能打开 更多...
void | cm_gnss_close (void)
gnss 功能关闭 更多...
int32_t | cm_gnss_config (cm_gnss_config_type_e config_type, void *value)
gnss 参数信息配置 更多...
int32_t | cm_gnss_set_nmea_callback (cm_gnss_nmea_callback callback, uint32_t nmea_type)
gnss 注册NMEA 消息回调函数 更多...
int32_t | cm_gnss_reset (void)
gnss 重启 更多...
int32_t | cm_agnss_state_query (cm_agnss_update_result_e *agnss_mode, char *update_time, uint32_t update_time_len, uint32_t *data_size)
查询辅助定位数据是否有效 更多...
int32_t | cm_agnss_data_start_update (cm_agnss_data_callback callback)
更新辅助定位数据 更多...
int32_t | cm_dgnss_enable (void)
dgnss 功能打开 更多...
int32_t | cm_dgnss_disable (void)
dgnss 功能关闭 更多...
int32_t | cm_gnss_send_raw_data (const char *raw_data, uint32_t len, cm_gnss_rawdata_rsp_callback callback)
向GPS芯片发送命令 更多...
int32_t | cm_gnss_get_location_info (cm_gnss_location_info_t *info)
获取定位信息 更多...
int32_t | cm_gnss_req_nmea (void)
主动请求NMEA数据 更多...

详细描述

宏定义说明

◆ CM_GNSS_NAME_GGA

#define CM_GNSS_NAME_GGA (1<<0)

NMEA 协议信息输出类型宏定义

◆ CM_GNSS_NAME_GSV

#define CM_GNSS_NAME_GSV (1<<1)

◆ CM_GNSS_NAME_GSA

#define CM_GNSS_NAME_GSA (1<<2)

◆ CM_GNSS_NAME_RMC

#define CM_GNSS_NAME_RMC (1<<3)

◆ CM_GNSS_NAME_VTG

#define CM_GNSS_NAME_VTG (1<<4)

◆ CM_GNSS_NAME_GLL

#define CM_GNSS_NAME_GLL (1<<5)

◆ CM_GNSS_NAME_ZDA

#define CM_GNSS_NAME_ZDA (1<<6)

◆ CM_GNSS_NAME_DTM

#define CM_GNSS_NAME_DTM (1<<7)

◆ CM_GNSS_NAME_GNS

#define CM_GNSS_NAME_GNS (1<<8)

◆ CM_GNSS_NAME_GRS

#define CM_GNSS_NAME_GRS (1<<9)

◆ CM_GNSS_NAME_GST

#define CM_GNSS_NAME_GST (1<<10)

◆ CM_GNSS_NAME_GBS

#define CM_GNSS_NAME_GBS (1<<11)

◆ CM_GNSS_NAME_TXT

#define CM_GNSS_NAME_TXT (1<<12)

类型定义说明

◆ cm_gnss_nmea_callback

typedef void(* cm_gnss_nmea_callback) (uint32_t type, const char *nmea, uint32_t len)

NMEA信息回调函数

参数
[in] | type | NMEA 报文类型(例如：CM_GNSS_NAME_GGA | CM_GNSS_NAME_GSV)
[in] | nmea | NMEA 报文数据
[in] | len | NMEA 报文长度
返回
void

须在注册回调函数时传入

◆ cm_agnss_data_callback

typedef void(* cm_agnss_data_callback) (cm_agnss_update_result_e mode, const char *update_time, uint32_t size)

辅助信息更新结果回调函数

参数
[in] | mode | 辅助数据更新结果：0-辅助信息无效；1-辅助信息有效；2-无法判断有效性；3-辅助数据为空；
[in] | update_time | 辅助数据更新时间，年月日时分秒，各占2个字符
[in] | size | 辅助数据大小(不支持)；
返回
void

须在注册回调函数时传入

◆ cm_gnss_rawdata_rsp_callback

typedef void(* cm_gnss_rawdata_rsp_callback) (const char *data, uint32_t len)

发送透传信息给GPS芯片返回结果回调函数

参数
[in] data 返回结果数据
返回
void

须在注册回调函数时传入

枚举类型说明

◆ cm_agnss_enable_e

enum cm_agnss_enable_e

agnss output mode

枚举值
CM_AGNSS_DISABLE
CM_AGNSS_ENABLE

◆ cm_gnss_type_e

enum cm_gnss_type_e

gnss satellite system

枚举值
CM_GNSS_GPS
CM_GNSS_BDS
CM_GNSS_GLONASS
CM_GNSS_BDS_GPS
CM_GNSS_GPS_GLONASS
CM_GNSS_BDS_GLONASS
CM_GNSS_BDS_GPS_GLONASS

◆ cm_gnss_config_type_e

enum cm_gnss_config_type_e

gnss config type

枚举值
CM_GNSS_CONFIG_TYPE_NMEA_MASK |
CM_GNSS_CONFIG_TYPE_NMEA_CYCLE | NMEA输出配置，设置值(value)对应的bit置1表示开启对应输出 bit0: GGA;bit1: GSV;bit2: GSA;bit3: RMC;bit4: VTG;bit5: GLL；bit6: ZDA；bit10: GST；bit12: TXT；0xFFFF为透传模式；uint32_t
CM_GNSS_CONFIG_TYPE_NMEA_PORT | NMEA输出周期（1-60）秒，当为0时只能查询，整型
CM_GNSS_CONFIG_TYPE_AGNSS_LOCATION | 调整NMEA数据输出接口（字符串）
CM_GNSS_CONFIG_TYPE_AGNSS_TIME | AGNSS辅助定位注入位置信息设置,cm_agnss_location_t ,需要在cm_gnss_open函数之后执行
CM_GNSS_CONFIG_TYPE_AGNSS_URL | AGNSS辅助定位注入时间信息设置,struct tm,UTC time
CM_GNSS_CONFIG_TYPE_AGNSS_INTERVAL | AGNSS辅助定位服务器url，字符串（hostname:port,≤64字节）
CM_GNSS_CONFIG_TYPE_DGNSS_URL | AGNSS辅助定位数据自动更新间隔，（30-240）分钟，整型,默认值为0（禁止自动更新）
CM_GNSS_CONFIG_TYPE_DGNSS_USER | DGNSS差分定位服务器url，字符串（hostname:port，≤64字节）
CM_GNSS_CONFIG_TYPE_DGNSS_PWD | DGNSS差分定位用户名，字符串（≤64字节）
CM_GNSS_CONFIG_TYPE_DGNSS_MOUNT | DGNSS差分定位密码，字符串（≤64字节）
CM_GNSS_CONFIG_TYPE_DGNSS_INTERVAL | DNGSS差分定位挂载点，字符串（≤64字节）
CM_GNSS_CONFIG_TYPE_SLEEP | DGNSS差分定位数据接收间隔，秒，整型,默认值为1（>=1）

◆ cm_agnss_update_result_e

enum cm_agnss_update_result_e
枚举值
CM_AGNSS_UPDATE_INVALID |
CM_AGNSS_UPDATE_VALID | 辅助信息无效
CM_AGNSS_UPDATE_FAIL_JUDGE | 辅助信息有效
CM_AGNSS_UPDATE_VOID | 无法判断有效性

函数说明

◆ cm_gnss_open()

int32_t cm_gnss_open | ( | cm_gnss_type_e | gnss_type,
 |  | cm_agnss_enable_e | agnss_enable
 | ) |  |

gnss 功能打开

参数
[in] | gnss_type | gnss 导航系统选择
[in] | agnss_enable | 是否打开辅助定位
返回

= 0 - 成功
= -1 - 失败

若任意串口配置成任意特殊波特率后，GNSS功能将无法正常使用，特殊波特率范围及使用说明详见cm_uart.h；本模块与ML307A的uart2使用同一串口,两者不能同时使用。

◆ cm_gnss_close()

void cm_gnss_close ( void )

gnss 功能关闭

参数
[in] void
返回
void

◆ cm_gnss_config()

int32_t cm_gnss_config | ( | cm_gnss_config_type_e | config_type,
 |  | void * | value
 | ) |  |

gnss 参数信息配置

参数
[in] | config_type | 参数类型
[in] | value | 相应参数值
返回

= 0 - 成功
= -1 - 失败,

◆ cm_gnss_set_nmea_callback()

int32_t cm_gnss_set_nmea_callback | ( | cm_gnss_nmea_callback | callback,
 |  | uint32_t | nmea_type
 | ) |  |

gnss 注册NMEA 消息回调函数

参数
[in] | callback | 回调函数设置
[in] | nmea_type | 输出报文类型(例如：CM_GNSS_NAME_GGA | CM_GNSS_NAME_GSV,0xFFFF为透传模式 )
返回
= 0 - 成功
= -1 - 失败

◆ cm_gnss_reset()

int32_t cm_gnss_reset ( void )

gnss 重启

参数
[in] void
返回
= 0 - 成功
= -1 - 失败

◆ cm_agnss_state_query()

int32_t cm_agnss_state_query | ( | cm_agnss_update_result_e * | agnss_mode,
 |  | char * | update_time,
 |  | uint32_t | update_time_len,
 |  | uint32_t * | data_size
 | ) |  |

查询辅助定位数据是否有效

参数
[out] | agnss_mode | 辅助数据更新结果：0-辅助信息无效；1-辅助信息有效；2-无法判断有效性；3-辅助数据为空；
[out] | update_time | 辅助数据更新时间，年月日时分秒
[out] | update_time_len | 辅助数据更新时间长度（14个字节）
[out] | data_size | 辅助数据大小（不支持）
返回

= 0 - 成功
= -1 - 失败

辅助数据有效性120分钟。

◆ cm_agnss_data_start_update()

int32_t cm_agnss_data_start_update ( cm_agnss_data_callback callback )

更新辅助定位数据

参数
[in] callback 更新结果回调函数
返回

= 0 - 成功
= -1 - 失败

◆ cm_dgnss_enable()

int32_t cm_dgnss_enable ( void )

dgnss 功能打开

参数
[in] void
返回

= 0 - 成功
= -1 - 失败

不支持。

功能开启后，可以从NMEA/GGA数据中判断UE是否处于差分定位模式中。

◆ cm_dgnss_disable()

int32_t cm_dgnss_disable ( void )

dgnss 功能关闭

参数
[in] void
返回

= 0 - 成功
= -1 - 失败

不支持。

◆ cm_gnss_send_raw_data()

int32_t cm_gnss_send_raw_data | ( | const char * | raw_data,
 |  | uint32_t | len,
 |  | cm_gnss_rawdata_rsp_callback | callback
 | ) |  |

向GPS芯片发送命令

参数
[in] | raw_data | 原始数据指针地址
[in] | len | 原始数据长度
[in] | callback | 发送数据之后异步返回回调函数
返回

= 0 - 成功
= -1 - 失败

原始数据需要去掉报文头$和报文尾的校验位,即组合$和*号之间的数据，例如热重启发送“RESET,1”"$%s*checksum\r\n"

◆ cm_gnss_get_location_info()

int32_t cm_gnss_get_location_info ( cm_gnss_location_info_t * info )

获取定位信息

参数
[in] info 定位信息
返回

◆ cm_gnss_req_nmea()

int32_t cm_gnss_req_nmea ( void )

主动请求NMEA数据

参数
[in] void
返回

= 0 - 成功
= -1 - 失败


ML305A_ML307A_OpenCPU_API: cm_agnss_location_t结构体 参考

成员变量
cm_agnss_location_t结构体 参考
Gnss

#include <cm_gnss.h>

成员变量

float | latitude
float | longitude
uint8_t | mode

结构体成员变量说明

◆ latitude

float latitude

◆ longitude

float longitude

latitude,单位度， 保留4位小数

◆ mode

uint8_t mode

longitude,单位度，保留4位小数

该结构体的文档由以下文件生成:
  • cm_gnss.h


ML305A_ML307A_OpenCPU_API: cm_gnss_location_info_t结构体 参考

成员变量
cm_gnss_location_info_t结构体 参考
Gnss

#include <cm_gnss.h>

成员变量

float | latitude
float | longitude
float | hdop
float | altitude
uint8_t | fix
float | cog
float | spkm
float | spkn
uint8_t | nsat
uint8_t | dtype

结构体成员变量说明

◆ latitude

float latitude

◆ longitude

float longitude

latitude,单位度,默认值为0

◆ hdop

float hdop

longitude,单位度,默认值为0

◆ altitude

float altitude

水平精度因子，保留1位小数,默认值为0

◆ fix

uint8_t fix

海拔高度，单位米，保留1位小数,默认值为0

◆ cog

float cog

定位类型。Fix status. 0 = invalid, 1 = GPS fix, 2 = DGPS fix, 3 = PPS fix,默认值为0

◆ spkm

float spkm

运动角度，真北参照系，单位:度,默认值为0

◆ spkn

float spkn

水平运动速度，单位Km/h,默认值为0

◆ nsat

uint8_t nsat

水平运动速度，单位Knots,默认值为0

◆ dtype

uint8_t dtype

参与定位的卫星数,默认值为0

该结构体的文档由以下文件生成:
  • cm_gnss.h


ML305A_ML307A_OpenCPU_API: gpio

结构体 | 枚举 | 函数
gpio

结构体

struct cm_gpio_cfg_t

枚举

enum cm_gpio_num_e {
CM_GPIO_NUM_0 , CM_GPIO_NUM_1 , CM_GPIO_NUM_2 , CM_GPIO_NUM_3 ,
CM_GPIO_NUM_4 , CM_GPIO_NUM_5 , CM_GPIO_NUM_6 , CM_GPIO_NUM_7 ,
CM_GPIO_NUM_8 , CM_GPIO_NUM_9 , CM_GPIO_NUM_10 , CM_GPIO_NUM_11 ,
CM_GPIO_NUM_12 , CM_GPIO_NUM_13 , CM_GPIO_NUM_14 , CM_GPIO_NUM_15 ,
CM_GPIO_NUM_16 , CM_GPIO_NUM_17 , CM_GPIO_NUM_18 , CM_GPIO_NUM_19 ,
CM_GPIO_NUM_20 , CM_GPIO_NUM_21 , CM_GPIO_NUM_22 , CM_GPIO_NUM_23 ,
CM_GPIO_NUM_24 , CM_GPIO_NUM_25 , CM_GPIO_NUM_26 , CM_GPIO_NUM_27 ,
CM_GPIO_NUM_28 , CM_GPIO_NUM_29 , CM_GPIO_NUM_30 , CM_GPIO_NUM_31 ,
CM_GPIO_NUM_32 , CM_GPIO_NUM_33 , CM_GPIO_NUM_34 , CM_GPIO_NUM_35 ,
CM_GPIO_NUM_36 , CM_GPIO_NUM_MAX
}
enum | cm_gpio_mode_e { CM_GPIO_MODE_NUM }
enum | cm_gpio_direction_e { CM_GPIO_DIRECTION_INPUT = 0 , CM_GPIO_DIRECTION_OUTPUT }
enum | cm_gpio_pull_e { CM_GPIO_PULL_NONE , CM_GPIO_PULL_DOWN , CM_GPIO_PULL_UP }
enum cm_gpio_interrupt_e {
CM_GPIO_IT_EDGE_RISING , CM_GPIO_IT_EDGE_FALLING , CM_GPIO_IT_EDGE_BOTH , CM_GPIO_IT_LEVEL_HIGH ,
CM_GPIO_IT_LEVEL_LOW
}
enum | cm_gpio_level_e { CM_GPIO_LEVEL_LOW , CM_GPIO_LEVEL_HIGH }
enum cm_gpio_cmd_e {
CM_GPIO_CMD_SET_PULL , CM_GPIO_CMD_GET_PULL , CM_GPIO_CMD_SET_LEVEL , CM_GPIO_CMD_GET_LEVEL ,
CM_GPIO_CMD_SET_DIRECTION , CM_GPIO_CMD_GET_DIRECTION
}

函数

int32_t | cm_gpio_init (cm_gpio_num_e gpio_num, cm_gpio_cfg_t *cfg)
初始化GPIO 更多...
int32_t | cm_gpio_deinit (cm_gpio_num_e gpio_num)
去初始化 更多...
int32_t | cm_gpio_set_level (cm_gpio_num_e gpio_num, cm_gpio_level_e level)
设置输出电平 更多...
int32_t | cm_gpio_get_level (cm_gpio_num_e gpio_num, cm_gpio_level_e *level)
读取输入电平 更多...
int32_t | cm_gpio_set_pull (cm_gpio_num_e gpio_num, cm_gpio_pull_e type)
设置上/下拉 更多...
int32_t | cm_gpio_get_pull (cm_gpio_num_e gpio_num, cm_gpio_pull_e *type)
读取上/下拉 更多...
int32_t | cm_gpio_set_direction (cm_gpio_num_e gpio_num, cm_gpio_direction_e dir)
I/O方向模式配置 更多...
int32_t | cm_gpio_get_direction (cm_gpio_num_e gpio_num, cm_gpio_direction_e *dir)
获取I/O方向模式配置 更多...
int32_t | cm_gpio_interrupt_register (cm_gpio_num_e gpio_num, void *interrupt_cb)
注册中断回调函数 更多...
int32_t | cm_gpio_interrupt_enable (cm_gpio_num_e gpio_num, cm_gpio_interrupt_e intr_mode)
使能中断 更多...
int32_t | cm_gpio_interrupt_disable (cm_gpio_num_e gpio_num)
失能中断 更多...
int32_t | cm_gpio_ioctl (cm_gpio_num_e gpio_num, int32_t cmd, void *arg)
GPIO控制 更多...

详细描述

枚举类型说明

◆ cm_gpio_num_e

enum cm_gpio_num_e

引脚ID,详情参照资源综述

枚举值
CM_GPIO_NUM_0
CM_GPIO_NUM_1
CM_GPIO_NUM_2
CM_GPIO_NUM_3
CM_GPIO_NUM_4
CM_GPIO_NUM_5
CM_GPIO_NUM_6
CM_GPIO_NUM_7
CM_GPIO_NUM_8
CM_GPIO_NUM_9
CM_GPIO_NUM_10
CM_GPIO_NUM_11
CM_GPIO_NUM_12
CM_GPIO_NUM_13
CM_GPIO_NUM_14
CM_GPIO_NUM_15
CM_GPIO_NUM_16
CM_GPIO_NUM_17
CM_GPIO_NUM_18
CM_GPIO_NUM_19
CM_GPIO_NUM_20
CM_GPIO_NUM_21
CM_GPIO_NUM_22
CM_GPIO_NUM_23
CM_GPIO_NUM_24
CM_GPIO_NUM_25
CM_GPIO_NUM_26
CM_GPIO_NUM_27
CM_GPIO_NUM_28
CM_GPIO_NUM_29
CM_GPIO_NUM_30
CM_GPIO_NUM_31
CM_GPIO_NUM_32
CM_GPIO_NUM_33
CM_GPIO_NUM_34
CM_GPIO_NUM_35
CM_GPIO_NUM_36
CM_GPIO_NUM_MAX

◆ cm_gpio_mode_e

enum cm_gpio_mode_e
枚举值
CM_GPIO_MODE_NUM

不可用 工作模式数量

◆ cm_gpio_direction_e

enum cm_gpio_direction_e

I/O方向

枚举值
CM_GPIO_DIRECTION_INPUT
CM_GPIO_DIRECTION_OUTPUT

◆ cm_gpio_pull_e

enum cm_gpio_pull_e

上/下拉

枚举值
CM_GPIO_PULL_NONE
CM_GPIO_PULL_DOWN
CM_GPIO_PULL_UP

◆ cm_gpio_interrupt_e

enum cm_gpio_interrupt_e

边沿+电平触发

枚举值
CM_GPIO_IT_EDGE_RISING |
CM_GPIO_IT_EDGE_FALLING |
CM_GPIO_IT_EDGE_BOTH |
CM_GPIO_IT_LEVEL_HIGH | 不支持
CM_GPIO_IT_LEVEL_LOW | 不支持

◆ cm_gpio_level_e

enum cm_gpio_level_e

高低电平

枚举值
CM_GPIO_LEVEL_LOW
CM_GPIO_LEVEL_HIGH

◆ cm_gpio_cmd_e

enum cm_gpio_cmd_e

命令码

枚举值
CM_GPIO_CMD_SET_PULL | 上下拉设置命令码
CM_GPIO_CMD_GET_PULL | 上下拉获取命令码
CM_GPIO_CMD_SET_LEVEL | 驱动能力设置命令码
CM_GPIO_CMD_GET_LEVEL | 驱动能力获取命令码
CM_GPIO_CMD_SET_DIRECTION | 输入输出设置命令码
CM_GPIO_CMD_GET_DIRECTION | 输入输出获取命令码

函数说明

◆ cm_gpio_init()

int32_t cm_gpio_init | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_cfg_t * | cfg
 | ) |  |

初始化GPIO

参数
[in] | gpio_num | GPIO号
[in] | cfg | 配置
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

初始化之前一定要先设置引脚复用

◆ cm_gpio_deinit()

int32_t cm_gpio_deinit ( cm_gpio_num_e gpio_num )

去初始化

参数
[in] gpio_num GPIO号
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_set_level()

int32_t cm_gpio_set_level | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_level_e | level
 | ) |  |

设置输出电平

参数
[in] | gpio_num | GPIO号
[in] | level | 输出电平
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_get_level()

int32_t cm_gpio_get_level | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_level_e * | level
 | ) |  |

读取输入电平

参数
[in] | gpio_num | GPIO号
[out] | level | 输入电平
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_set_pull()

int32_t cm_gpio_set_pull | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_pull_e | type
 | ) |  |

设置上/下拉

参数
[in] | gpio_num | GPIO号
[in] | type | 上下拉配置
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_get_pull()

int32_t cm_gpio_get_pull | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_pull_e * | type
 | ) |  |

读取上/下拉

参数
[in] | gpio_num | GPIO号
[out] | type | 上下拉配置
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_set_direction()

int32_t cm_gpio_set_direction | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_direction_e | dir
 | ) |  |

I/O方向模式配置

参数
[in] | gpio_num | GPIO号
[in] | dir | 输入/输出
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_get_direction()

int32_t cm_gpio_get_direction | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_direction_e * | dir
 | ) |  |

获取I/O方向模式配置

参数
[in] | gpio_num | GPIO号
[out] | dir | 输入/输出
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_interrupt_register()

int32_t cm_gpio_interrupt_register | ( | cm_gpio_num_e | gpio_num,
 |  | void * | interrupt_cb
 | ) |  |

注册中断回调函数

参数
[in] | gpio_num | GPIO号
[in] | interrupt_cb | 中断回调函数
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

中断函数中不要处理耗时任务和打印log日志

◆ cm_gpio_interrupt_enable()

int32_t cm_gpio_interrupt_enable | ( | cm_gpio_num_e | gpio_num,
 |  | cm_gpio_interrupt_e | intr_mode
 | ) |  |

使能中断

参数
[in] | gpio_num | GPIO号
[in] | intr_mode | 中断触发方式
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_interrupt_disable()

int32_t cm_gpio_interrupt_disable ( cm_gpio_num_e gpio_num )

失能中断

参数
[in] gpio_num GPIO号
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_gpio_ioctl()

int32_t cm_gpio_ioctl | ( | cm_gpio_num_e | gpio_num,
 |  | int32_t | cmd,
 |  | void * | arg
 | ) |  |

GPIO控制

参数
[in] | gpio_num | GPIO号
[in] | cmd | 命令码
[in/out] | arg 命令
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

根据不同的cmd值（命令码），arg参数类型须对应配置。
cmd = GPIO_CMD_SET_PULL, arg传入cm_gpio_pull_e *
cmd = GPIO_CMD_GET_PULL, arg传入cm_gpio_pull_e *
cmd = GPIO_CMD_SET_LEVEL, arg传入cm_gpio_level_e *
cmd = GPIO_CMD_GET_LEVEL, arg传入cm_gpio_level_e *
cmd = GPIO_CMD_SET_DIRECTION, arg传入cm_gpio_direction_e *
cmd = GPIO_CMD_GET_DIRECTION, arg传入cm_gpio_direction_e *


ML305A_ML307A_OpenCPU_API: cm_gpio_cfg_t结构体 参考

成员变量
cm_gpio_cfg_t结构体 参考
gpio

#include <cm_gpio.h>

成员变量

cm_gpio_mode_e mode
cm_gpio_direction_e direction
cm_gpio_pull_e pull

详细描述

配置

结构体成员变量说明

◆ mode

cm_gpio_mode_e mode

不支持

◆ direction

cm_gpio_direction_e direction

◆ pull

cm_gpio_pull_e pull
该结构体的文档由以下文件生成:
  • cm_gpio.h


ML305A_ML307A_OpenCPU_API: http

模块 | 函数
http

模块

Define
Enum
Struct

函数

uint8_t * | cm_httpclient_uri_encode (const uint8_t *src, const uint32_t len)
uri编码(不对字母数字以及-_.!~*'();/?:&=+$,#进行编码) 更多...
uint8_t * | cm_httpclient_uri_encode_component (const uint8_t *src, const uint32_t len)
uri编码(不对字母数字以及-_.!~*'()进行编码) 更多...
cm_httpclient_ret_code_e | cm_httpclient_create (const uint8_t *url, cm_httpclient_event_callback_func callback, cm_httpclient_handle_t *handle)
创建客户端实例 更多...
cm_httpclient_ret_code_e | cm_httpclient_delete (cm_httpclient_handle_t handle)
删除客户端实例 更多...
bool | cm_httpclient_is_busy (cm_httpclient_handle_t handle)
检测是否在执行请求 更多...
cm_httpclient_ret_code_e | cm_httpclient_set_cfg (cm_httpclient_handle_t handle, cm_httpclient_cfg_t cfg)
客户端参数设置 更多...
void | cm_httpclient_terminate (cm_httpclient_handle_t handle)
终止http连接 更多...
cm_httpclient_ret_code_e | cm_httpclient_custom_header_set (cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len)
设置通用报头 更多...
cm_httpclient_ret_code_e | cm_httpclient_custom_header_free (cm_httpclient_handle_t handle)
释放通用报头 更多...
cm_httpclient_ret_code_e | cm_httpclient_specific_header_set (cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len)
设置特定报头 更多...
cm_httpclient_ret_code_e | cm_httpclient_specific_header_free (cm_httpclient_handle_t handle)
释放特定报头 更多...
cm_httpclient_ret_code_e | cm_httpclient_request_start (cm_httpclient_handle_t handle, cm_httpclient_request_type_e method, const uint8_t *path, bool chunked, uint32_t content_length)
开始发送请求 更多...
cm_httpclient_ret_code_e | cm_httpclient_request_send (cm_httpclient_handle_t handle, const uint8_t *content, uint32_t content_len)
发送消息体 更多...
cm_httpclient_ret_code_e | cm_httpclient_request_end (cm_httpclient_handle_t handle)
请求发送结束 更多...
int32_t | cm_httpclient_get_response_code (cm_httpclient_handle_t handle)
获取响应结果码 更多...
uint32_t | cm_httpclient_parse_header (const uint8_t *header, const uint8_t *key, uint8_t **value)
解析报头 更多...
cm_httpclient_ret_code_e | cm_httpclient_sync_request (cm_httpclient_handle_t handle, cm_httpclient_sync_param_t param, cm_httpclient_sync_response_t *response)
发送请求(同步接口) 更多...
void | cm_httpclient_sync_free_data (cm_httpclient_handle_t handle)
释放响应数据(同步接口) 更多...

详细描述

函数说明

◆ cm_httpclient_uri_encode()

uint8_t* cm_httpclient_uri_encode | ( | const uint8_t * | src,
 |  | const uint32_t | len
 | ) |  |

uri编码(不对字母数字以及-_.!~*'();/?:&=+$,#进行编码)

参数
[in] | src | 原始数据
[in] | len | 原始数据长度
返回
编码数据/NULL 失败

uri编码，不对字母数字以及-_.!~*'();/?:&=+$,#进行编码，返回值为内部分配空间使用完后，需自行释放。不支持中文域名解析。

◆ cm_httpclient_uri_encode_component()

uint8_t* cm_httpclient_uri_encode_component | ( | const uint8_t * | src,
 |  | const uint32_t | len
 | ) |  |

uri编码(不对字母数字以及-_.!~*'()进行编码)

参数
[in] | src | 原始数据
[in] | len | 原始数据长度
返回
编码数据/NULL 失败

uri编码，不对字母数字以及-_.!~*'()进行编码，返回值为内部分配空间使用完后，需自行释放。不支持中文域名解析。

◆ cm_httpclient_create()

cm_httpclient_ret_code_e cm_httpclient_create | ( | const uint8_t * | url,
 |  | cm_httpclient_event_callback_func | callback,
 |  | cm_httpclient_handle_t * | handle
 | ) |  |

创建客户端实例

参数
[in] | url | 服务器地址（服务器地址url需要填写完整，例如（服务器url仅为格式示例）"https://39.106.55.200:80"）
[in] | callback | 客户端相关回调函数（使用cm_httpclient_sync_request()同步接口可忽略该参数，传NULL即可）
[out] | handle | 实例句柄
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

创建客户端实例

◆ cm_httpclient_delete()

cm_httpclient_ret_code_e cm_httpclient_delete ( cm_httpclient_handle_t handle )

删除客户端实例

参数
[in] handle 客户端实例句柄
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

本接口会将close socket（HTTP）操作发送至eloop模块中让其执行close socket操作。本接口返回成功代表操作已发送至eloop中，不代表已完成实例删除操作。用户连续两次调用本接口时建议中间保证100ms的延时。

◆ cm_httpclient_is_busy()

bool cm_httpclient_is_busy ( cm_httpclient_handle_t handle )

检测是否在执行请求

参数
[in] client 客户端实例句柄
返回
false 未执行请求/ true 正在执行请求

检测是否在执行请求

◆ cm_httpclient_set_cfg()

cm_httpclient_ret_code_e cm_httpclient_set_cfg | ( | cm_httpclient_handle_t | handle,
 |  | cm_httpclient_cfg_t | cfg
 | ) |  |

客户端参数设置

参数
[in] | handle | 客户端实例句柄
[in] | cfg | 客户端配置
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

客户端参数设置，创建实例后设置,请求过程中不可设置；服务器应答重定向信息的情况下，采用cm_httpclient_set_cfg()配置的参数连接重定向的服务器

◆ cm_httpclient_terminate()

void cm_httpclient_terminate ( cm_httpclient_handle_t handle )

终止http连接

参数
[in] handle 客户端实例句柄
返回

终止http连接

◆ cm_httpclient_custom_header_set()

cm_httpclient_ret_code_e cm_httpclient_custom_header_set | ( | cm_httpclient_handle_t | handle,
 |  | uint8_t * | header,
 |  | uint16_t | header_len
 | ) |  |

设置通用报头

参数
[in] | handle | 客户端实例句柄
[in] | header | 报头内容
[in] | header_len | 长度
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

设置通用报头，实例期间有效，不设置时，发送请求时将自动添加默认报头。 直接引用header指针，不做拷贝，需保证请求过程中不做修改和释放，如外部释放，也 需调用cm_httpclient_custom_header_free接口释放内部设置。

◆ cm_httpclient_custom_header_free()

cm_httpclient_ret_code_e cm_httpclient_custom_header_free ( cm_httpclient_handle_t handle )

释放通用报头

参数
[in] handle 客户端实例句柄
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

重置客户端内部指针为NULL、长度为0。

◆ cm_httpclient_specific_header_set()

cm_httpclient_ret_code_e cm_httpclient_specific_header_set | ( | cm_httpclient_handle_t | handle,
 |  | uint8_t * | header,
 |  | uint16_t | header_len
 | ) |  |

设置特定报头

参数
[in] | handle | 客户端实例句柄
[in] | header | 报头内容
[in] | header_len | 长度
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

设置特定报头，用于设置报头中，在不同请求时存在变化的字段， 如果通用报头中同样存在该字段，将在发送请求时自动替换为当前设置值。 直接引用header指针，不做拷贝，需保证请求过程中不做修改和释放，如外部释放，也 需调用cm_httpclient_specific_header_free接口释放内部设置。

◆ cm_httpclient_specific_header_free()

cm_httpclient_ret_code_e cm_httpclient_specific_header_free ( cm_httpclient_handle_t handle )

释放特定报头

参数
[in] handle 客户端实例句柄
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

重置客户端内部指针为NULL、长度为0。

◆ cm_httpclient_request_start()

cm_httpclient_ret_code_e cm_httpclient_request_start | ( | cm_httpclient_handle_t | handle,
 |  | cm_httpclient_request_type_e | method,
 |  | const uint8_t * | path,
 |  | bool | chunked,
 |  | uint32_t | content_length
 | ) |  |

开始发送请求

参数
[in] | handle | 客户端实例句柄
[in] | method | 请求类型
[in] | path | 请求路径
[in] | chunked | 是否为chunked模式
[in] | content_length | content数据总长度（chunked模式时无效）
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

开始发送请求，主要为建立连接，并发送报头，将在request_start_func回调中指示开始完成 ，后续可发送content数据。

◆ cm_httpclient_request_send()

cm_httpclient_ret_code_e cm_httpclient_request_send | ( | cm_httpclient_handle_t | handle,
 |  | const uint8_t * | content,
 |  | uint32_t | content_len
 | ) |  |

发送消息体

参数
[in] | handle | 客户端实例句柄
[in] | content | 消息体内容
[in] | content_len | 消息体长度
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

发送消息体，执行request_start_func回调后可使用。
socket发送缓存空间64240，单次发送超过64240长度数据时可能会造成缓存区溢出从而导致发送失败。

◆ cm_httpclient_request_end()

cm_httpclient_ret_code_e cm_httpclient_request_end ( cm_httpclient_handle_t handle )

请求发送结束

参数
[in] handle 客户端实例句柄
返回
0 成功/其他 失败（见cm_httpclient_ret_code_e）

请求发送结束，chunked模式下将发送结束包，普通模式下无实际效果，可不执行。

◆ cm_httpclient_get_response_code()

int32_t cm_httpclient_get_response_code ( cm_httpclient_handle_t handle )

获取响应结果码

参数
[in] handle 客户端实例句柄
返回
-1 失败/其他 结果码

获取响应结果码。

◆ cm_httpclient_parse_header()

uint32_t cm_httpclient_parse_header | ( | const uint8_t * | header,
 |  | const uint8_t * | key,
 |  | uint8_t ** | value
 | ) |  |

解析报头

参数
[in] | header | 需解析的报头
[in] | key | 需要找到的字段key
[out] | value | 需要找到的字段数据
返回
解析到的数据长度

解析报头，用于解析接收到的报头，按键值对进行解析，输入相应key，返回对应value， value输出的为header中的指针位置，未单独分配空间。

◆ cm_httpclient_sync_request()

cm_httpclient_ret_code_e cm_httpclient_sync_request | ( | cm_httpclient_handle_t | handle,
 |  | cm_httpclient_sync_param_t | param,
 |  | cm_httpclient_sync_response_t * | response
 | ) |  |

发送请求(同步接口)

参数
[in] | handle | 客户端实例句柄
[in] | param | 输入参数（见cm_httpclient_sync_param_t）
[out] | response | 响应结果（见cm_httpclient_sync_response_t）
返回
见cm_httpclient_ret_code_e

发送http请求同步接口，只可用于非chunk模式发送，需先创建实例并完成相关参数设置， 响应结果中的数据未内部动态分配空间，使用完后可通过cm_httpclient_sync_free_data接口释放， 下次请求时也会自动释放。
socket发送缓存空间64240，单次发送超过64240长度数据时可能会造成缓存区溢出从而导致发送失败。

◆ cm_httpclient_sync_free_data()

void cm_httpclient_sync_free_data ( cm_httpclient_handle_t handle )

释放响应数据(同步接口)

参数
[in] handle 客户端实例句柄
返回

释放响应数据。


ML305A_ML307A_OpenCPU_API: Define

宏定义
Define
http

宏定义

#define | true (1)
#define | false (0)
#define | bool int
#define | NULL ((void *)0)
#define | HTTP_DEFAULT_PORT 80
#define | HTTPS_DEFAULT_PORT 443
#define | HTTPCLIENT_CTX_MAX_NUM 4
#define | HTTPCLIENT_CONNECT_TIMEOUT_MAXTIME 180
#define | HTTPCLIENT_WAITRSP_TIMEOUT_MAXTIME 60
#define | HTTPCLIENT_CONNECT_TIMEOUT_DEFAULT 60
#define | HTTPCLIENT_WAITRSP_TIMEOUT_DEFAULT 0

详细描述

宏定义说明

◆ true

#define true (1)

◆ false

#define false (0)

◆ bool

#define bool int

◆ NULL

#define NULL ((void *)0)

◆ HTTP_DEFAULT_PORT

#define HTTP_DEFAULT_PORT 80

HTTP默认端口

◆ HTTPS_DEFAULT_PORT

#define HTTPS_DEFAULT_PORT 443

HTTPS默认端口

◆ HTTPCLIENT_CTX_MAX_NUM

#define HTTPCLIENT_CTX_MAX_NUM 4

HTTP可创建实例个数

◆ HTTPCLIENT_CONNECT_TIMEOUT_MAXTIME

#define HTTPCLIENT_CONNECT_TIMEOUT_MAXTIME 180

HTTP连接超时最大时间

◆ HTTPCLIENT_WAITRSP_TIMEOUT_MAXTIME

#define HTTPCLIENT_WAITRSP_TIMEOUT_MAXTIME 60

HTTP请求响应超时最大时间

◆ HTTPCLIENT_CONNECT_TIMEOUT_DEFAULT

#define HTTPCLIENT_CONNECT_TIMEOUT_DEFAULT 60

HTTP连接超时默认时间

◆ HTTPCLIENT_WAITRSP_TIMEOUT_DEFAULT

#define HTTPCLIENT_WAITRSP_TIMEOUT_DEFAULT 0

HTTP请求响应超时默认时间


ML305A_ML307A_OpenCPU_API: Enum

枚举
Enum
http

枚举

enum cm_httpclient_request_type_e {
HTTPCLIENT_REQUEST_NONE = 0 , HTTPCLIENT_REQUEST_GET , HTTPCLIENT_REQUEST_POST , HTTPCLIENT_REQUEST_PUT ,
HTTPCLIENT_REQUEST_DELETE , HTTPCLIENT_REQUEST_HEAD , HTTPCLIENT_REQUEST_MAX
}
enum cm_httpclient_callback_event_e {
CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND =1 , CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND , CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND , CM_HTTP_CALLBACK_EVENT_RSP_END_IND ,
CM_HTTP_CALLBACK_EVENT_ERROR_IND
}
enum cm_httpclient_error_event_e {
CM_HTTP_EVENT_CODE_DNS_FAIL =1 , CM_HTTP_EVENT_CODE_CONNECT_FAIL , CM_HTTP_EVENT_CODE_CONNECT_TIMEOUT , CM_HTTP_EVENT_CODE_SSL_CONNECT_FAIL ,
CM_HTTP_EVENT_CODE_CONNECT_BREAK , CM_HTTP_EVENT_CODE_WAITRSP_TIMEOUT , CM_HTTP_EVENT_CODE_DATA_PARSE_FAIL , CM_HTTP_EVENT_CODE_CACHR_NOT_ENOUGH ,
CM_HTTP_EVENT_CODE_DATA_DROP , CM_HTTP_EVENT_CODE_WRITE_FILE_FAIL , CM_HTTP_EVENT_CODE_UNKNOWN =255
}
enum cm_httpclient_ret_code_e {
CM_HTTP_RET_CODE_OK = 0 , CM_HTTP_RET_CODE_OPERATION_NOT_ALLOWED = 3 , CM_HTTP_RET_CODE_MALLOC_FAIL = 23 , CM_HTTP_RET_CODE_PARAM_ERROR = 50 ,
CM_HTTP_RET_CODE_UNKNOWN_ERROR = 650 , CM_HTTP_RET_CODE_NO_MORE_FREE_CLIENT = 651 , CM_HTTP_RET_CODE_CLIENT_NOT_CREATE = 652 , CM_HTTP_RET_CODE_CLIENT_IS_BUSY = 653 ,
CM_HTTP_RET_CODE_URL_PARSE_FAIL = 654 , CM_HTTP_RET_CODE_SSL_NOT_ENABLE = 655 , CM_HTTP_RET_CODE_CONNECT_FAIL = 656 , CM_HTTP_RET_CODE_SEND_DATA_FAIL = 657 ,
CM_HTTP_RET_CODE_OPEN_FILE_FAIL = 658
}

详细描述

枚举类型说明

◆ cm_httpclient_request_type_e

enum cm_httpclient_request_type_e

HTTP请求类型

枚举值
HTTPCLIENT_REQUEST_NONE
HTTPCLIENT_REQUEST_GET
HTTPCLIENT_REQUEST_POST
HTTPCLIENT_REQUEST_PUT
HTTPCLIENT_REQUEST_DELETE
HTTPCLIENT_REQUEST_HEAD
HTTPCLIENT_REQUEST_MAX

◆ cm_httpclient_callback_event_e

enum cm_httpclient_callback_event_e

HTTP回调事件

枚举值
CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND | 请求启动成功事件
CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND | 接收到报头事件
CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND | 接收到消息体事件
CM_HTTP_CALLBACK_EVENT_RSP_END_IND | 请求响应结束事件
CM_HTTP_CALLBACK_EVENT_ERROR_IND | 请求失败事件

◆ cm_httpclient_error_event_e

enum cm_httpclient_error_event_e

HTTP异常状态码

枚举值
CM_HTTP_EVENT_CODE_DNS_FAIL | DNS解析失败
CM_HTTP_EVENT_CODE_CONNECT_FAIL | 连接服务器失败
CM_HTTP_EVENT_CODE_CONNECT_TIMEOUT | 连接超时
CM_HTTP_EVENT_CODE_SSL_CONNECT_FAIL | SSL握手失败
CM_HTTP_EVENT_CODE_CONNECT_BREAK | 连接异常断开
CM_HTTP_EVENT_CODE_WAITRSP_TIMEOUT | 等待响应超时
CM_HTTP_EVENT_CODE_DATA_PARSE_FAIL | 数据解析失败
CM_HTTP_EVENT_CODE_CACHR_NOT_ENOUGH | 缓存空间不足
CM_HTTP_EVENT_CODE_DATA_DROP | 数据丢包
CM_HTTP_EVENT_CODE_WRITE_FILE_FAIL | 写文件失败
CM_HTTP_EVENT_CODE_UNKNOWN | 未知错误

◆ cm_httpclient_ret_code_e

enum cm_httpclient_ret_code_e

HTTP结果码

枚举值
CM_HTTP_RET_CODE_OK | 成功
CM_HTTP_RET_CODE_OPERATION_NOT_ALLOWED | 操作不被允许 3
CM_HTTP_RET_CODE_MALLOC_FAIL | 内存分配失败 23
CM_HTTP_RET_CODE_PARAM_ERROR | 参数错误 50
CM_HTTP_RET_CODE_UNKNOWN_ERROR | 未知错误 650
CM_HTTP_RET_CODE_NO_MORE_FREE_CLIENT | 没有空闲客户端 651
CM_HTTP_RET_CODE_CLIENT_NOT_CREATE | 客户端未创建 652
CM_HTTP_RET_CODE_CLIENT_IS_BUSY | 客户端忙 653
CM_HTTP_RET_CODE_URL_PARSE_FAIL | URL解析失败 654
CM_HTTP_RET_CODE_SSL_NOT_ENABLE | SSL未使能 655
CM_HTTP_RET_CODE_CONNECT_FAIL | 连接失败 656
CM_HTTP_RET_CODE_SEND_DATA_FAIL | 数据发送失败 657
CM_HTTP_RET_CODE_OPEN_FILE_FAIL | 打开文件失败 658


ML305A_ML307A_OpenCPU_API: Struct

结构体 | 类型定义
Struct
http

结构体

struct | cm_httpclient_callback_rsp_header_param_t
struct | cm_httpclient_callback_rsp_content_param_t
struct | cm_httpclient_cfg_t
struct | cm_httpclient_sync_param_t
struct | cm_httpclient_sync_response_t

类型定义

typedef void * | cm_httpclient_handle_t
typedef void(* | cm_httpclient_event_callback_func) (cm_httpclient_handle_t client_handle, cm_httpclient_callback_event_e event, void *param)

详细描述

类型定义说明

◆ cm_httpclient_handle_t

typedef void* cm_httpclient_handle_t

HTTP实例句柄

◆ cm_httpclient_event_callback_func

typedef void(* cm_httpclient_event_callback_func) (cm_httpclient_handle_t client_handle, cm_httpclient_callback_event_e event, void *param)

HTTP回调


ML305A_ML307A_OpenCPU_API: cm_httpclient_callback_rsp_header_param_t结构体 参考

成员变量
cm_httpclient_callback_rsp_header_param_t结构体 参考
http » Struct

#include <cm_http.h>

成员变量

uint16_t | response_code
uint16_t | response_header_len
const uint8_t * | response_header

详细描述

HTTP相关回调函数

结构体成员变量说明

◆ response_code

uint16_t response_code

◆ response_header_len

uint16_t response_header_len

◆ response_header

const uint8_t* response_header
该结构体的文档由以下文件生成:
  • cm_http.h


ML305A_ML307A_OpenCPU_API: cm_httpclient_callback_rsp_content_param_t结构体 参考

成员变量
cm_httpclient_callback_rsp_content_param_t结构体 参考
http » Struct

#include <cm_http.h>

成员变量

uint32_t | total_len
uint32_t | sum_len
uint32_t | current_len
const uint8_t * | response_content

详细描述

HTTP相关回调函数

结构体成员变量说明

◆ total_len

uint32_t total_len

数据总长度（chunked模式时为0）

◆ sum_len

uint32_t sum_len

已接收长度

◆ current_len

uint32_t current_len

当前包长度

◆ response_content

const uint8_t* response_content

数据

该结构体的文档由以下文件生成:
  • cm_http.h


ML305A_ML307A_OpenCPU_API: cm_httpclient_cfg_t结构体 参考

成员变量
cm_httpclient_cfg_t结构体 参考
http » Struct

#include <cm_http.h>

成员变量

uint8_t | ssl_enable
int32_t | ssl_id
uint8_t | cid
uint8_t | conn_timeout
uint8_t | rsp_timeout
uint8_t | dns_priority

详细描述

HTTP可配参数

结构体成员变量说明

◆ ssl_enable

uint8_t ssl_enable

是否使用HTTPS

◆ ssl_id

int32_t ssl_id

ssl 索引号

◆ cid

uint8_t cid

PDP索引

◆ conn_timeout

uint8_t conn_timeout

连接超时时间

◆ rsp_timeout

uint8_t rsp_timeout

响应超时时间

◆ dns_priority

uint8_t dns_priority

dns解析优先级 0：使用全局优先级。1：v4优先。2：v6优先

该结构体的文档由以下文件生成:
  • cm_http.h


ML305A_ML307A_OpenCPU_API: cm_httpclient_sync_param_t结构体 参考

成员变量
cm_httpclient_sync_param_t结构体 参考
http » Struct

#include <cm_http.h>

成员变量

cm_httpclient_request_type_e method
const uint8_t * | path
uint32_t | content_length
uint8_t * | content

详细描述

HTTP 同步接口输入参数

结构体成员变量说明

◆ method

cm_httpclient_request_type_e method

请求类型

◆ path

const uint8_t* path

请求路径

◆ content_length

uint32_t content_length

数据长度

◆ content

uint8_t* content

数据

该结构体的文档由以下文件生成:
  • cm_http.h


ML305A_ML307A_OpenCPU_API: cm_httpclient_sync_response_t结构体 参考

成员变量
cm_httpclient_sync_response_t结构体 参考
http » Struct

#include <cm_http.h>

成员变量

uint32_t | response_code
uint32_t | response_header_len
uint32_t | response_content_len
uint8_t * | response_header
uint8_t * | response_content

详细描述

HTTP 同步接口响应数据

结构体成员变量说明

◆ response_code

uint32_t response_code

请求成功时的响应结果码

◆ response_header_len

uint32_t response_header_len

响应报头长度

◆ response_content_len

uint32_t response_content_len

响应消息体长度

◆ response_header

uint8_t* response_header

响应报头（内部分配空间，使用完后可调用cm_httpclient_sync_free_data释放）

◆ response_content

uint8_t* response_content

响应消息体（内部分配空间，使用完后可调用cm_httpclient_sync_free_data释放）

该结构体的文档由以下文件生成:
  • cm_http.h


ML305A_ML307A_OpenCPU_API: i2c

结构体 | 宏定义 | 枚举 | 函数
i2c

结构体

struct cm_i2c_cfg_t
I2C 配置 更多...

宏定义

#define | CM_I2C_CLK_100KHZ (100000U)
#define | CM_I2C_CLK_400KHZ (400000U)

枚举

enum | cm_i2c_dev_e { CM_I2C_DEV_0 = 0 , CM_I2C_DEV_1 , CM_I2C_DEV_2 , CM_I2C_DEV_NUM }
I2C 通道 更多...
enum | cm_i2c_mode_e { CM_I2C_MODE_MASTER = 0 , CM_I2C_MODE_SLAVER }
I2C 支持主从模式 更多...
enum | cm_i2c_addr_type_e { CM_I2C_ADDR_TYPE_7BIT , CM_I2C_ADDR_TYPE_10BIT }

函数

int32_t | cm_i2c_open (cm_i2c_dev_e dev, cm_i2c_cfg_t *cfg)
i2c开启 更多...
int32_t | cm_i2c_close (cm_i2c_dev_e dev)
i2c关闭 更多...
int32_t | cm_i2c_write (cm_i2c_dev_e dev, uint16_t slave_addr, const void *data, uint32_t len)
i2c写数据 更多...
int32_t | cm_i2c_read (cm_i2c_dev_e dev, uint16_t slave_addr, void *data, uint32_t len)
i2c读数据 更多...

详细描述

宏定义说明

◆ CM_I2C_CLK_100KHZ

#define CM_I2C_CLK_100KHZ (100000U)

时钟频率

◆ CM_I2C_CLK_400KHZ

#define CM_I2C_CLK_400KHZ (400000U)

枚举类型说明

◆ cm_i2c_dev_e

enum cm_i2c_dev_e

I2C 通道

枚举值
CM_I2C_DEV_0 | ML305A系列CAMERA专用，不支持配置
CM_I2C_DEV_1 | I2C1
CM_I2C_DEV_2 | I2C2
CM_I2C_DEV_NUM | I2C设备个数

◆ cm_i2c_mode_e

enum cm_i2c_mode_e

I2C 支持主从模式

枚举值
CM_I2C_MODE_MASTER | 主模式
CM_I2C_MODE_SLAVER | 从模式(不支持)

◆ cm_i2c_addr_type_e

enum cm_i2c_addr_type_e

寻址

枚举值
CM_I2C_ADDR_TYPE_7BIT | 7bit地址
CM_I2C_ADDR_TYPE_10BIT | 10bit地址(不支持)

函数说明

◆ cm_i2c_open()

int32_t cm_i2c_open | ( | cm_i2c_dev_e | dev,
 |  | cm_i2c_cfg_t * | cfg
 | ) |  |

i2c开启

参数
[in] | dev | i2c设备ID
[in] | cfg | i2c配置
返回

= 0 - 成功.
< 0 - 失败, 返回值为错误码.

仅支持主机模式.

◆ cm_i2c_close()

int32_t cm_i2c_close ( cm_i2c_dev_e dev )

i2c关闭

参数
[in] dev i2c设备ID
返回

= 0 - 成功.
< 0 - 失败, 返回值为错误码.

More details

◆ cm_i2c_write()

int32_t cm_i2c_write | ( | cm_i2c_dev_e | dev,
 |  | uint16_t | slave_addr,
 |  | const void * | data,
 |  | uint32_t | len
 | ) |  |

i2c写数据

参数
[in] | dev | i2c设备
[in] | slave_addr | i2c设备地址
[in] | data | 待写数据
[in] | len | 待写数据长度
返回

= 实际写入长度 - 成功.
< 0 - 失败, 返回值为错误码.

More details

◆ cm_i2c_read()

int32_t cm_i2c_read | ( | cm_i2c_dev_e | dev,
 |  | uint16_t | slave_addr,
 |  | void * | data,
 |  | uint32_t | len
 | ) |  |

i2c读数据

参数
[in] | dev | i2c设备
[in] | slave_addr | i2c设备地址
[out] | data | 读取数据存放地址，需先申请内存
[in] | len | 读取数据长度
返回

= 实际读出长度 - 成功.
< 0 - 失败, 返回值为错误码.

More details


ML305A_ML307A_OpenCPU_API: cm_i2c_cfg_t结构体 参考

成员变量
cm_i2c_cfg_t结构体 参考
i2c

I2C 配置 更多...

#include <cm_i2c.h>

成员变量

cm_i2c_addr_type_e addr_type
cm_i2c_mode_e mode
int clk

详细描述

I2C 配置

结构体成员变量说明

◆ addr_type

cm_i2c_addr_type_e addr_type

◆ mode

cm_i2c_mode_e mode

◆ clk

int clk
该结构体的文档由以下文件生成:
  • cm_i2c.h


ML305A_ML307A_OpenCPU_API: Iomux

枚举 | 函数
Iomux

枚举

enum cm_iomux_pin_e {
CM_IOMUX_PIN_0 = 0 , CM_IOMUX_PIN_1 , CM_IOMUX_PIN_2 , CM_IOMUX_PIN_3 ,
CM_IOMUX_PIN_4 , CM_IOMUX_PIN_5 , CM_IOMUX_PIN_6 , CM_IOMUX_PIN_7 ,
CM_IOMUX_PIN_8 , CM_IOMUX_PIN_9 , CM_IOMUX_PIN_10 , CM_IOMUX_PIN_11 ,
CM_IOMUX_PIN_12 , CM_IOMUX_PIN_13 , CM_IOMUX_PIN_14 , CM_IOMUX_PIN_15 ,
CM_IOMUX_PIN_16 , CM_IOMUX_PIN_17 , CM_IOMUX_PIN_18 , CM_IOMUX_PIN_19 ,
CM_IOMUX_PIN_20 , CM_IOMUX_PIN_21 , CM_IOMUX_PIN_22 , CM_IOMUX_PIN_23 ,
CM_IOMUX_PIN_24 , CM_IOMUX_PIN_25 , CM_IOMUX_PIN_26 , CM_IOMUX_PIN_27 ,
CM_IOMUX_PIN_28 , CM_IOMUX_PIN_29 , CM_IOMUX_PIN_30 , CM_IOMUX_PIN_31 ,
CM_IOMUX_PIN_32 , CM_IOMUX_PIN_33 , CM_IOMUX_PIN_34 , CM_IOMUX_PIN_35 ,
CM_IOMUX_PIN_36 , CM_IOMUX_PIN_37 , CM_IOMUX_PIN_38 , CM_IOMUX_PIN_39 ,
CM_IOMUX_PIN_40 , CM_IOMUX_PIN_41 , CM_IOMUX_PIN_42 , CM_IOMUX_PIN_43 ,
CM_IOMUX_PIN_44 , CM_IOMUX_PIN_45 , CM_IOMUX_PIN_46 , CM_IOMUX_PIN_47 ,
CM_IOMUX_PIN_48 , CM_IOMUX_PIN_49 , CM_IOMUX_PIN_50 , CM_IOMUX_PIN_51 ,
CM_IOMUX_PIN_52 , CM_IOMUX_PIN_53 , CM_IOMUX_PIN_54 , CM_IOMUX_PIN_55 ,
CM_IOMUX_PIN_56 , CM_IOMUX_PIN_57 , CM_IOMUX_PIN_58 , CM_IOMUX_PIN_59 ,
CM_IOMUX_PIN_60 , CM_IOMUX_PIN_61 , CM_IOMUX_PIN_62 , CM_IOMUX_PIN_63 ,
CM_IOMUX_PIN_64 , CM_IOMUX_PIN_65 , CM_IOMUX_PIN_66 , CM_IOMUX_PIN_67 ,
CM_IOMUX_PIN_68 , CM_IOMUX_PIN_69 , CM_IOMUX_PIN_70 , CM_IOMUX_PIN_71 ,
CM_IOMUX_PIN_72 , CM_IOMUX_PIN_73 , CM_IOMUX_PIN_74 , CM_IOMUX_PIN_75 ,
CM_IOMUX_PIN_76 , CM_IOMUX_PIN_77 , CM_IOMUX_PIN_78 , CM_IOMUX_PIN_79 ,
CM_IOMUX_PIN_80 , CM_IOMUX_PIN_81 , CM_IOMUX_PIN_82 , CM_IOMUX_PIN_83 ,
CM_IOMUX_PIN_84 , CM_IOMUX_PIN_85 , CM_IOMUX_PIN_86 , CM_IOMUX_PIN_87 ,
CM_IOMUX_PIN_88 , CM_IOMUX_PIN_89 , CM_IOMUX_PIN_90 , CM_IOMUX_PIN_91 ,
CM_IOMUX_PIN_92 , CM_IOMUX_PIN_93 , CM_IOMUX_PIN_94 , CM_IOMUX_PIN_95 ,
CM_IOMUX_PIN_96 , CM_IOMUX_PIN_97 , CM_IOMUX_PIN_98 , CM_IOMUX_PIN_99 ,
CM_IOMUX_PIN_100 , CM_IOMUX_PIN_101 , CM_IOMUX_PIN_102 , CM_IOMUX_PIN_103 ,
CM_IOMUX_PIN_104 , CM_IOMUX_PIN_105 , CM_IOMUX_PIN_106 , CM_IOMUX_PIN_107 ,
CM_IOMUX_PIN_108 , CM_IOMUX_PIN_109 , CM_IOMUX_PIN_110 , CM_IOMUX_PIN_111 ,
CM_IOMUX_PIN_112 , CM_IOMUX_PIN_113 , CM_IOMUX_PIN_114 , CM_IOMUX_PIN_115 ,
CM_IOMUX_PIN_116 , CM_IOMUX_PIN_117 , CM_IOMUX_PIN_118 , CM_IOMUX_PIN_119 ,
CM_IOMUX_PIN_120 , CM_IOMUX_PIN_121 , CM_IOMUX_PIN_122 , CM_IOMUX_PIN_123 ,
CM_IOMUX_PIN_124 , CM_IOMUX_PIN_125 , CM_IOMUX_PIN_126 , CM_IOMUX_PIN_127 ,
CM_IOMUX_PIN_128 , CM_IOMUX_PIN_129 , CM_IOMUX_PIN_130 , CM_IOMUX_PIN_131 ,
CM_IOMUX_PIN_132 , CM_IOMUX_PIN_133 , CM_IOMUX_PIN_134 , CM_IOMUX_PIN_135 ,
CM_IOMUX_PIN_136 , CM_IOMUX_PIN_137 , CM_IOMUX_PIN_138 , CM_IOMUX_PIN_139 ,
CM_IOMUX_PIN_140 , CM_IOMUX_PIN_141 , CM_IOMUX_PIN_142 , CM_IOMUX_PIN_143 ,
CM_IOMUX_PIN_144 , CM_IOMUX_PIN_145 , CM_IOMUX_PIN_146 , CM_IOMUX_PIN_147 ,
CM_IOMUX_PIN_148 , CM_IOMUX_PIN_149 , CM_IOMUX_PIN_150 , CM_IOMUX_PIN_151 ,
CM_IOMUX_PIN_152 , CM_IOMUX_PIN_153 , CM_IOMUX_PIN_154 , CM_IOMUX_PIN_MAX
}
enum cm_iomux_func_e {
CM_IOMUX_FUNC_FUNCTION0 , CM_IOMUX_FUNC_FUNCTION1 , CM_IOMUX_FUNC_FUNCTION2 , CM_IOMUX_FUNC_FUNCTION3 ,
CM_IOMUX_FUNC_FUNCTIONNUM_END
}
enum cm_iomux_pincmd_e {
CM_IOMUX_PINCMD0_SLEEP , CM_IOMUX_PINCMD1_LPMEDEG , CM_IOMUX_PINCMD2_DRIVEABILITY , CM_IOMUX_PINCMD3_PULL ,
CM_IOMUX_PINCMDNUM_END
}
enum cm_iomux_pincmd0_e {
CM_IOMUX_PINCMD0_FUNC0_SLEEP_NONE , CM_IOMUX_PINCMD0_FUNC1_SLEEP_DIR , CM_IOMUX_PINCMD0_FUNC2_SLEEP_DATA , CM_IOMUX_PINCMD0_FUNC3_SLEEP_FLOAT ,
CM_IOMUX_PINCMD0_FUNC4_SLEEP_OUTPUT_HIGH , CM_IOMUX_PINCMD0_FUNC5_SLEEP_OUTPUT_LOW , CM_IOMUX_PINCMD0_FUNCNUM_END
}
enum cm_iomux_pincmd1_e {
CM_IOMUX_PINCMD1_FUNC0_LPM_EDGE_NONE , CM_IOMUX_PINCMD1_FUNC1_LPM_EDGE_RISE , CM_IOMUX_PINCMD1_FUNC2_LPM_EDGE_FALL , CM_IOMUX_PINCMD1_FUNC3_EDGE_BOTH ,
CM_IOMUX_PINCMD1_FUNCNUM_END
}
enum cm_iomux_pincmd2_e {
CM_IOMUX_PINCMD2_FUNC0_DRIVE_VERY_SLOW , CM_IOMUX_PINCMD2_FUNC1_DRIVE_SLOW , CM_IOMUX_PINCMD2_FUNC2_DRIVE_MEDIUM , CM_IOMUX_PINCMD2_FUNC3_DRIVE_FAST ,
CM_IOMUX_PINCMD2_FUNC4_MASK , CM_IOMUX_PINCMD2_FUNCNUM_END
}
enum cm_iomux_pincmd3_e {
CM_IOMUX_PINCMD3_FUNC0_PULL_NONE , CM_IOMUX_PINCMD3_FUNC1_PULL_LOW , CM_IOMUX_PINCMD3_FUNC2_PULL_HIGH , CM_IOMUX_PINCMD3_FUNC3_PULL_BOTH ,
CM_IOMUX_PINCMD3_FUNC4_PULL_FLOAT , CM_IOMUX_PINCMD3_FUNCNUM_END
}

函数

int32_t | cm_iomux_set_pin_func (cm_iomux_pin_e pin, cm_iomux_func_e fun)
IOMUX 设置引脚复用功能 更多...
int32_t | cm_iomux_get_pin_func (cm_iomux_pin_e pin, cm_iomux_func_e *fun)
IOMUX 获取引脚功能 更多...
int32_t | cm_iomux_set_pin_cmd (cm_iomux_pin_e pin, cm_iomux_pincmd_e cmd, uint8_t cmd_arg)
IOMUX PIN脚控制 更多...

详细描述

枚举类型说明

◆ cm_iomux_pin_e

enum cm_iomux_pin_e

IOMUX PIN definition 和模组实际PIN脚对应一致,请参照资源综述

枚举值
CM_IOMUX_PIN_0
CM_IOMUX_PIN_1
CM_IOMUX_PIN_2
CM_IOMUX_PIN_3
CM_IOMUX_PIN_4
CM_IOMUX_PIN_5
CM_IOMUX_PIN_6
CM_IOMUX_PIN_7
CM_IOMUX_PIN_8
CM_IOMUX_PIN_9
CM_IOMUX_PIN_10
CM_IOMUX_PIN_11
CM_IOMUX_PIN_12
CM_IOMUX_PIN_13
CM_IOMUX_PIN_14
CM_IOMUX_PIN_15
CM_IOMUX_PIN_16
CM_IOMUX_PIN_17
CM_IOMUX_PIN_18
CM_IOMUX_PIN_19
CM_IOMUX_PIN_20
CM_IOMUX_PIN_21
CM_IOMUX_PIN_22
CM_IOMUX_PIN_23
CM_IOMUX_PIN_24
CM_IOMUX_PIN_25
CM_IOMUX_PIN_26
CM_IOMUX_PIN_27
CM_IOMUX_PIN_28
CM_IOMUX_PIN_29
CM_IOMUX_PIN_30
CM_IOMUX_PIN_31
CM_IOMUX_PIN_32
CM_IOMUX_PIN_33
CM_IOMUX_PIN_34
CM_IOMUX_PIN_35
CM_IOMUX_PIN_36
CM_IOMUX_PIN_37
CM_IOMUX_PIN_38
CM_IOMUX_PIN_39
CM_IOMUX_PIN_40
CM_IOMUX_PIN_41
CM_IOMUX_PIN_42
CM_IOMUX_PIN_43
CM_IOMUX_PIN_44
CM_IOMUX_PIN_45
CM_IOMUX_PIN_46
CM_IOMUX_PIN_47
CM_IOMUX_PIN_48
CM_IOMUX_PIN_49
CM_IOMUX_PIN_50
CM_IOMUX_PIN_51
CM_IOMUX_PIN_52
CM_IOMUX_PIN_53
CM_IOMUX_PIN_54
CM_IOMUX_PIN_55
CM_IOMUX_PIN_56
CM_IOMUX_PIN_57
CM_IOMUX_PIN_58
CM_IOMUX_PIN_59
CM_IOMUX_PIN_60
CM_IOMUX_PIN_61
CM_IOMUX_PIN_62
CM_IOMUX_PIN_63
CM_IOMUX_PIN_64
CM_IOMUX_PIN_65
CM_IOMUX_PIN_66
CM_IOMUX_PIN_67
CM_IOMUX_PIN_68
CM_IOMUX_PIN_69
CM_IOMUX_PIN_70
CM_IOMUX_PIN_71
CM_IOMUX_PIN_72
CM_IOMUX_PIN_73
CM_IOMUX_PIN_74
CM_IOMUX_PIN_75
CM_IOMUX_PIN_76
CM_IOMUX_PIN_77
CM_IOMUX_PIN_78
CM_IOMUX_PIN_79
CM_IOMUX_PIN_80
CM_IOMUX_PIN_81
CM_IOMUX_PIN_82
CM_IOMUX_PIN_83
CM_IOMUX_PIN_84
CM_IOMUX_PIN_85
CM_IOMUX_PIN_86
CM_IOMUX_PIN_87
CM_IOMUX_PIN_88
CM_IOMUX_PIN_89
CM_IOMUX_PIN_90
CM_IOMUX_PIN_91
CM_IOMUX_PIN_92
CM_IOMUX_PIN_93
CM_IOMUX_PIN_94
CM_IOMUX_PIN_95
CM_IOMUX_PIN_96
CM_IOMUX_PIN_97
CM_IOMUX_PIN_98
CM_IOMUX_PIN_99
CM_IOMUX_PIN_100
CM_IOMUX_PIN_101
CM_IOMUX_PIN_102
CM_IOMUX_PIN_103
CM_IOMUX_PIN_104
CM_IOMUX_PIN_105
CM_IOMUX_PIN_106
CM_IOMUX_PIN_107
CM_IOMUX_PIN_108
CM_IOMUX_PIN_109
CM_IOMUX_PIN_110
CM_IOMUX_PIN_111
CM_IOMUX_PIN_112
CM_IOMUX_PIN_113
CM_IOMUX_PIN_114
CM_IOMUX_PIN_115
CM_IOMUX_PIN_116
CM_IOMUX_PIN_117
CM_IOMUX_PIN_118
CM_IOMUX_PIN_119
CM_IOMUX_PIN_120
CM_IOMUX_PIN_121
CM_IOMUX_PIN_122
CM_IOMUX_PIN_123
CM_IOMUX_PIN_124
CM_IOMUX_PIN_125
CM_IOMUX_PIN_126
CM_IOMUX_PIN_127
CM_IOMUX_PIN_128
CM_IOMUX_PIN_129
CM_IOMUX_PIN_130
CM_IOMUX_PIN_131
CM_IOMUX_PIN_132
CM_IOMUX_PIN_133
CM_IOMUX_PIN_134
CM_IOMUX_PIN_135
CM_IOMUX_PIN_136
CM_IOMUX_PIN_137
CM_IOMUX_PIN_138
CM_IOMUX_PIN_139
CM_IOMUX_PIN_140
CM_IOMUX_PIN_141
CM_IOMUX_PIN_142
CM_IOMUX_PIN_143
CM_IOMUX_PIN_144
CM_IOMUX_PIN_145
CM_IOMUX_PIN_146
CM_IOMUX_PIN_147
CM_IOMUX_PIN_148
CM_IOMUX_PIN_149
CM_IOMUX_PIN_150
CM_IOMUX_PIN_151
CM_IOMUX_PIN_152
CM_IOMUX_PIN_153
CM_IOMUX_PIN_154
CM_IOMUX_PIN_MAX

◆ cm_iomux_func_e

enum cm_iomux_func_e
枚举值
CM_IOMUX_FUNC_FUNCTION0 | 不支持
CM_IOMUX_FUNC_FUNCTION1 | 功能1
CM_IOMUX_FUNC_FUNCTION2 | 功能2
CM_IOMUX_FUNC_FUNCTION3 | 功能3
CM_IOMUX_FUNC_FUNCTIONNUM_END |

◆ cm_iomux_pincmd_e

enum cm_iomux_pincmd_e
枚举值
CM_IOMUX_PINCMD0_SLEEP | 休眠状态
CM_IOMUX_PINCMD1_LPMEDEG | 边沿检测
CM_IOMUX_PINCMD2_DRIVEABILITY | 驱动能力
CM_IOMUX_PINCMD3_PULL | 上下拉
CM_IOMUX_PINCMDNUM_END |

◆ cm_iomux_pincmd0_e

enum cm_iomux_pincmd0_e
枚举值
CM_IOMUX_PINCMD0_FUNC0_SLEEP_NONE | 不使能 pad 的 sleep 功能
CM_IOMUX_PINCMD0_FUNC1_SLEEP_DIR | 不使能 sleep，只是设置为 sleep 时候，输入状态
CM_IOMUX_PINCMD0_FUNC2_SLEEP_DATA | 不使能 sleep，只是设置为 sleep 时候，输出状态
CM_IOMUX_PINCMD0_FUNC3_SLEEP_FLOAT | 使能 sleep 功能，设置为 sleep 时候，输入状态
CM_IOMUX_PINCMD0_FUNC4_SLEEP_OUTPUT_HIGH | 使能 sleep 功能，设置为 sleep 时候，输出高状态
CM_IOMUX_PINCMD0_FUNC5_SLEEP_OUTPUT_LOW | 使能 sleep 功能，设置为 sleep 时候，输出低状态
CM_IOMUX_PINCMD0_FUNCNUM_END |

◆ cm_iomux_pincmd1_e

enum cm_iomux_pincmd1_e
枚举值
CM_IOMUX_PINCMD1_FUNC0_LPM_EDGE_NONE | 不使能 pad 的边沿检测功能,需配合休眠解锁cm_pm_work_unlock函数使用
CM_IOMUX_PINCMD1_FUNC1_LPM_EDGE_RISE | 使能 pad 的边沿检测功能，且是上升沿。并提供唤醒事件,需配合休眠锁cm_pm_work_lock函数使用
CM_IOMUX_PINCMD1_FUNC2_LPM_EDGE_FALL | 使能 pad 的边沿检测功能，且是下降沿。并提供唤醒事件.需配合休眠锁cm_pm_work_lock函数使用
CM_IOMUX_PINCMD1_FUNC3_EDGE_BOTH | 使能 pad 的边沿检测功能，且是双沿。并提供唤醒事件.需配合休眠锁cm_pm_work_lock函数使用
CM_IOMUX_PINCMD1_FUNCNUM_END |

◆ cm_iomux_pincmd2_e

enum cm_iomux_pincmd2_e
枚举值
CM_IOMUX_PINCMD2_FUNC0_DRIVE_VERY_SLOW
CM_IOMUX_PINCMD2_FUNC1_DRIVE_SLOW
CM_IOMUX_PINCMD2_FUNC2_DRIVE_MEDIUM
CM_IOMUX_PINCMD2_FUNC3_DRIVE_FAST
CM_IOMUX_PINCMD2_FUNC4_MASK
CM_IOMUX_PINCMD2_FUNCNUM_END

◆ cm_iomux_pincmd3_e

enum cm_iomux_pincmd3_e
枚举值
CM_IOMUX_PINCMD3_FUNC0_PULL_NONE | 不使能内部的上拉下拉功能
CM_IOMUX_PINCMD3_FUNC1_PULL_LOW | 使能下拉
CM_IOMUX_PINCMD3_FUNC2_PULL_HIGH | 使能上拉
CM_IOMUX_PINCMD3_FUNC3_PULL_BOTH | 使能上下拉
CM_IOMUX_PINCMD3_FUNC4_PULL_FLOAT | 浮空功能
CM_IOMUX_PINCMD3_FUNCNUM_END |

函数说明

◆ cm_iomux_set_pin_func()

int32_t cm_iomux_set_pin_func | ( | cm_iomux_pin_e | pin,
 |  | cm_iomux_func_e | fun
 | ) |  |

IOMUX 设置引脚复用功能

参数
[in] | pin | PIN 定义号
[in] | fun | FUN 定义号
返回

= 0 - 成功
= -1 - 失败

◆ cm_iomux_get_pin_func()

int32_t cm_iomux_get_pin_func | ( | cm_iomux_pin_e | pin,
 |  | cm_iomux_func_e * | fun
 | ) |  |

IOMUX 获取引脚功能

参数
[in] | pin | PIN 定义号
[out] | fun | FUN 定义号
返回

= 0 - 成功
< 0 - 失败

◆ cm_iomux_set_pin_cmd()

int32_t cm_iomux_set_pin_cmd | ( | cm_iomux_pin_e | pin,
 |  | cm_iomux_pincmd_e | cmd,
 |  | uint8_t | cmd_arg
 | ) |  |

IOMUX PIN脚控制

参数
[in] | pin | PIN 定义号
[in] | cmd | 功能定义
[in] | cmd_arg | 具体功能值
返回

= 0 - 成功
< 0 - 失败


ML305A_ML307A_OpenCPU_API: keypad

结构体 | 类型定义 | 枚举 | 函数
keypad

结构体

struct cm_keypad_cfg_t

类型定义

typedef uint32_t | cm_keypad_map_t
key map 更多...
typedef enum cm_keypad_kp_mkin | cm_keypad_kp_mkin_e
typedef enum cm_keypad_kp_mkout | cm_keypad_kp_mkout_e
typedef void(* | cm_key_event_callback_t) (cm_keypad_map_t key, cm_keypad_event_e event)
keypad事件回调函数 更多...

枚举

enum cm_keypad_event_e { CM_KEY_EVENT_RELEASE = 0 , CM_KEY_EVENT_PRESS = 1 }
key事件类型 更多...
enum cm_keypad_kp_mkin {
CM_KP_MKI0 = 0 , CM_KP_MKI1 , CM_KP_MKI2 , CM_KP_MKI3 ,
CM_KP_MKI4 , CM_KP_MKI5 , CM_KP_MKI6 , CM_KP_MKI7 ,
CM_KP_MKI_NO_VALID
}
enum cm_keypad_kp_mkout {
CM_KP_MKO0 = 0 , CM_KP_MKO1 , CM_KP_MKO2 , CM_KP_MKO3 ,
CM_KP_MKO4 , CM_KP_MKO5 , CM_KP_MKO6 , CM_KP_MKO7 ,
CM_KP_MKO_NO_VALID
}

函数

int32_t | cm_keypad_config (cm_keypad_cfg_t *cm_keypad_cfg)
keypad配置 更多...
int32_t | cm_keypad_init (void)
keypad初始化 更多...
int32_t | cm_keypad_register (cm_key_event_callback_t cb)
keypad事件回调注册 更多...
int32_t | cm_keypad_unregister (cm_key_event_callback_t cb)
keypad事件回调注销 更多...
void | cm_keypad_deinit (void)
keypad去初始化 更多...

详细描述

类型定义说明

◆ cm_keypad_map_t

typedef uint32_t cm_keypad_map_t

key map

◆ cm_keypad_kp_mkin_e

typedef enum cm_keypad_kp_mkin cm_keypad_kp_mkin_e

◆ cm_keypad_kp_mkout_e

typedef enum cm_keypad_kp_mkout cm_keypad_kp_mkout_e

◆ cm_key_event_callback_t

typedef void(* cm_key_event_callback_t) (cm_keypad_map_t key, cm_keypad_event_e event)

keypad事件回调函数

参数
[in] | key | 键值
[in] | event | 按键事件

枚举类型说明

◆ cm_keypad_event_e

enum cm_keypad_event_e

key事件类型

枚举值
CM_KEY_EVENT_RELEASE | 按键被释放
CM_KEY_EVENT_PRESS | 按键被按下

◆ cm_keypad_kp_mkin

enum cm_keypad_kp_mkin
枚举值
CM_KP_MKI0
CM_KP_MKI1
CM_KP_MKI2
CM_KP_MKI3
CM_KP_MKI4
CM_KP_MKI5
CM_KP_MKI6
CM_KP_MKI7
CM_KP_MKI_NO_VALID

◆ cm_keypad_kp_mkout

enum cm_keypad_kp_mkout
枚举值
CM_KP_MKO0
CM_KP_MKO1
CM_KP_MKO2
CM_KP_MKO3
CM_KP_MKO4
CM_KP_MKO5
CM_KP_MKO6
CM_KP_MKO7
CM_KP_MKO_NO_VALID

函数说明

◆ cm_keypad_config()

int32_t cm_keypad_config ( cm_keypad_cfg_t * cm_keypad_cfg )

keypad配置

参数
[in] cm_keypad_cfg keypad 配置参数指针
返回
= 0 - 成功
= -1 - 失败

需在cm_keypad_init函数之前使用

◆ cm_keypad_init()

int32_t cm_keypad_init ( void )

keypad初始化

返回
= 0 - 成功
= -1 - 失败

◆ cm_keypad_register()

int32_t cm_keypad_register ( cm_key_event_callback_t cb )

keypad事件回调注册

参数
[in] cb keypad回调函数
返回
= 0 - 成功
= -1 - 失败

最大允许注册的回调函数个数为10

◆ cm_keypad_unregister()

int32_t cm_keypad_unregister ( cm_key_event_callback_t cb )

keypad事件回调注销

参数
[in] cb keypad回调函数
返回
= 0 - 成功
= -1 - 失败

最大允许注册的回调函数个数为10

◆ cm_keypad_deinit()

void cm_keypad_deinit ( void )

keypad去初始化

由于任务删除不能释放已经分配的内存，因此重复初始化keypad功能会造成内存泄露


ML305A_ML307A_OpenCPU_API: cm_keypad_cfg_t结构体 参考

成员变量
cm_keypad_cfg_t结构体 参考
keypad

#include <cm_keypad.h>

成员变量

cm_keypad_kp_mkin_e * cm_col
cm_keypad_kp_mkout_e * cm_row
uint8_t | cm_col_len
uint8_t | cm_row_len

详细描述

配置

结构体成员变量说明

◆ cm_col

cm_keypad_kp_mkin_e* cm_col

◆ cm_row

cm_keypad_kp_mkout_e* cm_row

◆ cm_col_len

uint8_t cm_col_len

◆ cm_row_len

uint8_t cm_row_len
该结构体的文档由以下文件生成:
  • cm_keypad.h


ML305A_ML307A_OpenCPU_API: Lbs

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
Lbs

结构体

struct | cm_lbs_location_rsp_t
struct | cm_lbs_amap_location_attr_t
struct | cm_lbs_mantu_location_attr_t
struct | cm_lbs_oneospos_attr_t

宏定义

#define | CM_LBS_NVCONFIG_ONEOSPOS_PIDLEN (64)
#define | CM_LBS_NVCONFIG_AMAP_KEYLEN (128)
#define | CM_LBS_NVCONFIG_AMAP_SIGNALEN (128)

类型定义

typedef void(* cm_lbs_callback) (cm_lbs_callback_event_e event, cm_lbs_location_rsp_t *location, void *cb_arg)

枚举

enum cm_lbs_location_platform_e {
CM_LBS_PLAT_START , CM_LBS_PLAT_AMAP10 = 10 , CM_LBS_PLAT_AMAP20 = 11 , CM_LBS_PLAT_MANTU = 20 ,
CM_LBS_PLAT_BAIDU = 30 , CM_LBS_PLAT_ONEOSPOS = 40 , CM_LBS_PLAT_END
}
enum cm_lbs_callback_event_e {
CM_LBS_LOCATION_OK = 0 , CM_LBS_NET_ERR = -1 , CM_LBS_TIMEOUT = -2 , CM_LBS_KEY_ERR = -3 ,
CM_LBS_PARAM_INVALID = -4 , CM_LBS_OVER_DAYQUTA = -5 , CM_LBS_OVER_QUOTA = -6 , CM_LBS_OVER_QPS = -7 ,
CM_LBS_UNKNOW_ERR = -100
}

函数

int32_t | cm_lbs_init (cm_lbs_location_platform_e platform, void *attr)
int32_t | cm_lbs_location (cm_lbs_callback cb, void *cb_arg)
void | cm_lbs_deinit (void)
int32_t | cm_lbs_get_attr (int platform, void *attr)

详细描述

@ NOTE：lbs 定位时会连接定位服务器，需要使用http连接，因此调用 @ int32_t cm_lbs_location(cm_lbs_callback cb,void *cb_arg); @ 函数期间会占用1路http,定位完成之后会释放该路http @ 目前LBS支持的型号有：ML307A-DCLN/ DSLN/GSLN @ 目前LBS支持的型号有：ML305A-DC/DS

宏定义说明

◆ CM_LBS_NVCONFIG_ONEOSPOS_PIDLEN

#define CM_LBS_NVCONFIG_ONEOSPOS_PIDLEN (64)

◆ CM_LBS_NVCONFIG_AMAP_KEYLEN

#define CM_LBS_NVCONFIG_AMAP_KEYLEN (128)

◆ CM_LBS_NVCONFIG_AMAP_SIGNALEN

#define CM_LBS_NVCONFIG_AMAP_SIGNALEN (128)

类型定义说明

◆ cm_lbs_callback

typedef void(* cm_lbs_callback) (cm_lbs_callback_event_e event, cm_lbs_location_rsp_t *location, void *cb_arg)

LBS定位回调函数

枚举类型说明

◆ cm_lbs_location_platform_e

enum cm_lbs_location_platform_e

LBS平台枚举

枚举值
CM_LBS_PLAT_START |
CM_LBS_PLAT_AMAP10 | 高德定位1.0
CM_LBS_PLAT_AMAP20 | 高德定位2.0
CM_LBS_PLAT_MANTU | 漫图定位,不支持
CM_LBS_PLAT_BAIDU | 百度定位,不支持
CM_LBS_PLAT_ONEOSPOS | OneOsPos定位
CM_LBS_PLAT_END |

◆ cm_lbs_callback_event_e

enum cm_lbs_callback_event_e

LBS定位错误信息

枚举值
CM_LBS_LOCATION_OK | 定位成功
CM_LBS_NET_ERR | 网络异常
CM_LBS_TIMEOUT | 请求超时
CM_LBS_KEY_ERR | KEY非法或过期
CM_LBS_PARAM_INVALID | 请求参数无效
CM_LBS_OVER_DAYQUTA | 请求超出日配额
CM_LBS_OVER_QUOTA | 请求超出总配额
CM_LBS_OVER_QPS | 请求超出QPS
CM_LBS_UNKNOW_ERR | 未知错误

函数说明

◆ cm_lbs_init()

int32_t cm_lbs_init | ( | cm_lbs_location_platform_e | platform,
 |  | void * | attr
 | ) |  |

◆ cm_lbs_location()

int32_t cm_lbs_location | ( | cm_lbs_callback | cb,
 |  | void * | cb_arg
 | ) |  |

◆ cm_lbs_deinit()

void cm_lbs_deinit ( void )

◆ cm_lbs_get_attr()

int32_t cm_lbs_get_attr | ( | int | platform,
 |  | void * | attr
 | ) |  |


ML305A_ML307A_OpenCPU_API: cm_lbs_location_rsp_t结构体 参考

成员变量
cm_lbs_location_rsp_t结构体 参考
Lbs

#include <cm_lbs.h>

成员变量

int | platform
cm_lbs_callback_event_e state
char * | longitude
char * | latitude
char * | radius
char * | country
char * | province
char * | city
char * | citycode
char * | adcode
char * | poi
char * | location_describe

详细描述

LBS定位结果，具体信息根据平台反馈结果而定，无结果项返回为NULL

结构体成员变量说明

◆ platform

int platform

定位所用平台

◆ state

cm_lbs_callback_event_e state

定位结果状态

◆ longitude

char* longitude

经度

◆ latitude

char* latitude

纬度

◆ radius

char* radius

精度半径

◆ country

char* country

国家

◆ province

char* province

省份

◆ city

char* city

市

◆ citycode

char* citycode

城市编码

◆ adcode

char* adcode

区域编码

◆ poi

char* poi

道路名称

◆ location_describe

char* location_describe

具体位置描述

该结构体的文档由以下文件生成:
  • cm_lbs.h


ML305A_ML307A_OpenCPU_API: cm_lbs_amap_location_attr_t结构体 参考

成员变量
cm_lbs_amap_location_attr_t结构体 参考
Lbs

#include <cm_lbs.h>

成员变量

uint8_t * | api_key
int | time_out
int | digital_sign_enable
uint8_t * | digital_key
int | show_fields_enable
int | nearbts_enable

详细描述

LBS高德定位版本枚举 高德智能硬件定位配置参数

结构体成员变量说明

◆ api_key

uint8_t* api_key

apikey

◆ time_out

int time_out

超时时间 sec,(0-60s)

◆ digital_sign_enable

int digital_sign_enable

是否启动数字签名

◆ digital_key

uint8_t* digital_key

数字签名key

◆ show_fields_enable

int show_fields_enable

高德定位2.0是否请求具体的位置描述 0：不请求 1：请求；高德定位1.0默认开启，无此项配置

◆ nearbts_enable

int nearbts_enable

是否启用邻区

该结构体的文档由以下文件生成:
  • cm_lbs.h


ML305A_ML307A_OpenCPU_API: cm_lbs_mantu_location_attr_t结构体 参考

成员变量
cm_lbs_mantu_location_attr_t结构体 参考
Lbs

#include <cm_lbs.h>

成员变量

uint8_t | appid [64]
uint8_t | password [64]
uint8_t | transid [64]
int | time_out

详细描述

漫图定位配置参数

结构体成员变量说明

◆ appid

uint8_t appid[64]

应用编码 由onelink平台提供

◆ password

uint8_t password[64]

api接入密码 由中国移动物联网onelink平台提供

◆ transid

uint8_t transid[64]

事务编码 由客户按照 APPID+YYYYMMDDHHMISS+8位数字序列自主生成

◆ time_out

int time_out

超时时间 sec,(0-60s)

该结构体的文档由以下文件生成:
  • cm_lbs.h


ML305A_ML307A_OpenCPU_API: cm_lbs_oneospos_attr_t结构体 参考

成员变量
cm_lbs_oneospos_attr_t结构体 参考
Lbs

#include <cm_lbs.h>

成员变量

char * | pid
int | time_out
int | nearbts_enable

结构体成员变量说明

◆ pid

char* pid

设备pid

◆ time_out

int time_out

请求超时时间,(0-60s)

◆ nearbts_enable

int nearbts_enable

是否启用邻区

该结构体的文档由以下文件生成:
  • cm_lbs.h


ML305A_ML307A_OpenCPU_API: LCD

宏定义 | 函数
LCD

宏定义

#define | LCD_PIN_RST 77
#define | LCD_PIN_SPI_4L_DCX 14
#define | LCD_PIN_SPI_CS 13
#define | LCD_PIN_BACKLIGHT 23

函数

void | cm_lcd_write_cmd (unsigned char cmd)
配置时发送cmd 更多...
void | cm_lcd_write_data (unsigned char data)
配置时发送data 更多...
void | cm_lcd_write_buf (unsigned char *data, int len)
发送刷屏数据 更多...
void | cm_lcd_init (void)
lcd 驱动初始化 更多...
void | cm_lcd_deinit (void)
lcd 驱动去初始化 更多...
uint32_t | cm_lcd_read_id (void)
lcd 获取ID 更多...
int32_t | cm_lcd_read_id_v2 (const uint32_t cmd, int cmd_len, void *id, int id_len)
lcd 获取ID 更多...

详细描述

宏定义说明

◆ LCD_PIN_RST

#define LCD_PIN_RST 77

◆ LCD_PIN_SPI_4L_DCX

#define LCD_PIN_SPI_4L_DCX 14

◆ LCD_PIN_SPI_CS

#define LCD_PIN_SPI_CS 13

◆ LCD_PIN_BACKLIGHT

#define LCD_PIN_BACKLIGHT 23

函数说明

◆ cm_lcd_write_cmd()

void cm_lcd_write_cmd ( unsigned char cmd )

配置时发送cmd

参数
[in] cmd 需要发送的命令
返回

More details

◆ cm_lcd_write_data()

void cm_lcd_write_data ( unsigned char data )

配置时发送data

参数
[in] data 需要发送的数据
返回

More details

◆ cm_lcd_write_buf()

void cm_lcd_write_buf | ( | unsigned char * | data,
 |  | int | len
 | ) |  |

发送刷屏数据

参数
[in] | data | 需要发送的数据
[in] | len | 数据长度
返回

More details

◆ cm_lcd_init()

void cm_lcd_init ( void )

lcd 驱动初始化

返回

More details

◆ cm_lcd_deinit()

void cm_lcd_deinit ( void )

lcd 驱动去初始化

返回

More details

◆ cm_lcd_read_id()

uint32_t cm_lcd_read_id ( void )

lcd 获取ID

返回

0 - lcd ID

= 0 - 失败

只适配ST7735S

◆ cm_lcd_read_id_v2()

int32_t cm_lcd_read_id_v2 | ( | const uint32_t | cmd,
 |  | int | cmd_len,
 |  | void * | id,
 |  | int | id_len
 | ) |  |

lcd 获取ID

参数
[in] | cmd | 需要发送的指令
[in] | cmd_len | 指令长度（最大4字节）
[out] | id | 输出的id
[in] | id_len | id长度（最大4字节）
返回
= 0 - 成功
< 0 - 失败

More details


ML305A_ML307A_OpenCPU_API: tts

结构体 | 类型定义 | 枚举 | 函数
tts

结构体

struct | cm_local_tts_cfg_t
struct | cm_local_tts_synth_data_t
struct | cm_tts_cfg_t

类型定义

typedef void(* | cm_local_tts_callback) (cm_local_tts_event_e event, void *param)
TTS转码回调函数 更多...
typedef void(* | cm_tts_callback) (cm_tts_event_e event, void *param)
TTS回调函数 更多...

枚举

enum | cm_local_tts_encode_e { CM_LOCAL_TTS_ENCODE_TYPE_GB2312 = 1 , CM_LOCAL_TTS_ENCODE_TYPE_UTF8 }
中文文本编码方式 更多...
enum | cm_local_tts_digit_e { CM_LOCAL_TTS_DIGIT_AUTO = 0 , CM_LOCAL_TTS_DIGIT_AS_NUMBER , CM_LOCAL_TTS_DIGIT_AS_VALUE }
数字播放方式 更多...
enum | cm_local_tts_tone_e { CM_LOCAL_TTS_TONE_NORMAL = 1 }
音调 更多...
enum | cm_local_tts_effect_e { CM_LOCAL_TTS_EFFECT_NORMAL = 1 }
音效 更多...
enum | cm_local_tts_state_e { CM_LOCAL_TTS_STATE_IDLE = 1 , CM_LOCAL_TTS_STATE_WORKING }
TTS状态 更多...
enum cm_local_tts_event_e {
CM_LOCAL_TTS_EVENT_SYNTH_DATA = 1 , CM_LOCAL_TTS_EVENT_SYNTH_FAIL , CM_LOCAL_TTS_EVENT_SYNTH_INTERRUPT , CM_LOCAL_TTS_EVENT_SYNTH_FINISH ,
CM_LOCAL_TTS_EVENT_PLAY_FAIL , CM_LOCAL_TTS_EVENT_PLAY_INTERRUPT , CM_LOCAL_TTS_EVENT_PLAY_FINISH
}
enum | cm_tts_encode_e { CM_TTS_ENCODE_TYPE_UCS2 = 0 , CM_TTS_ENCODE_TYPE_GBK , CM_TTS_ENCODE_TYPE_UTF8 , CM_TTS_ENCODE_TYPE_GB2312 }
中文文本编码方式 更多...
enum | cm_tts_rdn_e { CM_TTS_RDN_AUTO = 0 , CM_TTS_RDN_AS_VALUE , CM_TTS_RDN_AS_NUMBER , CM_TTS_RDN_AS_STR }
数字播放方式 更多...
enum cm_tts_pitch_e {
CM_TTS_PITCH_0 = 0 , CM_TTS_PITCH_1 , CM_TTS_PITCH_2 , CM_TTS_PITCH_3 ,
CM_TTS_PITCH_4 , CM_TTS_PITCH_5 , CM_TTS_PITCH_6 , CM_TTS_PITCH_7 ,
CM_TTS_PITCH_8 , CM_TTS_PITCH_9 , CM_TTS_PITCH_10 , CM_TTS_PITCH_11 ,
CM_TTS_PITCH_12 , CM_TTS_PITCH_13 , CM_TTS_PITCH_14 , CM_TTS_PITCH_15
}
音调 更多...
enum cm_tts_voice_e {
CM_TTS_VOICE_0 = 0 , CM_TTS_VOICE_1 = 1 , CM_TTS_VOICE_2 = 2 , CM_TTS_VOICE_3 = 3 ,
CM_TTS_VOICE_4 = 4
}
音效 更多...
enum | cm_tts_channel_e { CM_TTS_CHANNEL_0 = 0 , CM_TTS_CHANNEL_1 = 1 , CM_TTS_CHANNEL_2 = 2 , CM_TTS_CHANNEL_3 = 3 }
播放通道 更多...
enum | cm_tts_state_e { CM_TTS_STATE_IDLE = 0 , CM_TTS_STATE_INTERRUPT , CM_TTS_STATE_FAIL , CM_TTS_STATE_WORKING }
TTS状态 更多...
enum cm_tts_event_e {
CM_TTS_EVENT_SYNTH_DATA = 1 , CM_TTS_EVENT_SYNTH_FAIL , CM_TTS_EVENT_SYNTH_INTERRUPT , CM_TTS_EVENT_SYNTH_FINISH ,
CM_TTS_EVENT_PLAY_FAIL , CM_TTS_EVENT_PLAY_INTERRUPT , CM_TTS_EVENT_PLAY_FINISH
}

函数

int32_t | cm_local_tts_init (cm_local_tts_cfg_t *cfg)
TTS初始化 更多...
void | cm_local_tts_deinit (void)
TTS去初始化 更多...
int32_t | cm_local_tts_synth (const void *text, int32_t len, cm_local_tts_callback cb, void *cb_param)
文字转语音PCM数据（不播放，转码后为PCM数据，采样率8k） 更多...
int32_t | cm_local_tts_play (const char *text, int32_t len, cm_local_tts_callback cb, void *cb_param)
TTS播放文字 更多...
int32_t | cm_local_tts_play_stop (void)
停止TTS播放文字 更多...
int32_t | cm_tts_init (cm_tts_cfg_t *cfg)
TTS初始化 更多...
void | cm_tts_deinit (void)
TTS去初始化 更多...
int32_t | cm_tts_play (const void *text, int32_t len, cm_tts_callback cb, void *cb_param)
TTS播放文字 更多...
int32_t | cm_tts_play_stop (void)
停止TTS播放文字 更多...
cm_tts_state_e | cm_tts_get_state (void)
获取TTS状态 更多...

详细描述

类型定义说明

◆ cm_local_tts_callback

typedef void(* cm_local_tts_callback) (cm_local_tts_event_e event, void *param)

TTS转码回调函数

参数
[in] | event | 事件类型
[in] | param | 事件参数（事件类型为CM_LOCAL_TTS_EVENT_SYNTH_DATA时，需要将param强转为cm_local_tts_synth_data_t型。其余情况该参数为用户传入参数）

◆ cm_tts_callback

typedef void(* cm_tts_callback) (cm_tts_event_e event, void *param)

TTS回调函数

参数
[in] | event | 事件类型
[in] | param | 事件参数（该参数为用户传入参数）

枚举类型说明

◆ cm_local_tts_encode_e

enum cm_local_tts_encode_e

中文文本编码方式

范围根据实际情况确定

枚举值
CM_LOCAL_TTS_ENCODE_TYPE_GB2312 | 普通字符为ASCII格式，汉字为GBK格式，不支持
CM_LOCAL_TTS_ENCODE_TYPE_UTF8 | 普通字符为ASCII格式，汉字为UTF-8格式

◆ cm_local_tts_digit_e

enum cm_local_tts_digit_e

数字播放方式

枚举值
CM_LOCAL_TTS_DIGIT_AUTO | 自动模式
CM_LOCAL_TTS_DIGIT_AS_NUMBER | 数字模式
CM_LOCAL_TTS_DIGIT_AS_VALUE | 数值模式

◆ cm_local_tts_tone_e

enum cm_local_tts_tone_e

音调

范围根据实际情况确定

枚举值
CM_LOCAL_TTS_TONE_NORMAL

默认音调

◆ cm_local_tts_effect_e

enum cm_local_tts_effect_e

音效

范围根据实际情况确定

枚举值
CM_LOCAL_TTS_EFFECT_NORMAL

默认音效

◆ cm_local_tts_state_e

enum cm_local_tts_state_e

TTS状态

枚举值
CM_LOCAL_TTS_STATE_IDLE | TTS空闲
CM_LOCAL_TTS_STATE_WORKING | TTS工作中

◆ cm_local_tts_event_e

enum cm_local_tts_event_e

TTS回调的事件类型

枚举值
CM_LOCAL_TTS_EVENT_SYNTH_DATA | 语音合成数据上报，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_LOCAL_TTS_EVENT_SYNTH_FAIL | 语音合成失败，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_LOCAL_TTS_EVENT_SYNTH_INTERRUPT | 语音合成（异常）中断，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_LOCAL_TTS_EVENT_SYNTH_FINISH | 语音合成完成，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_LOCAL_TTS_EVENT_PLAY_FAIL | 语音播放失败，调用cm_tts_play()接口时可能上报的事件
CM_LOCAL_TTS_EVENT_PLAY_INTERRUPT | 语音播放中断，调用cm_tts_play()接口时可能上报的事件
CM_LOCAL_TTS_EVENT_PLAY_FINISH | 语音播放完成，调用cm_tts_play()接口时可能上报的事件

◆ cm_tts_encode_e

enum cm_tts_encode_e

中文文本编码方式

范围根据实际情况确定

枚举值
CM_TTS_ENCODE_TYPE_UCS2 | UCS2编码模式
CM_TTS_ENCODE_TYPE_GBK | 普通字符为ASCII格式，汉字为GBK格式
CM_TTS_ENCODE_TYPE_UTF8 | 普通字符为ASCII格式，汉字为UTF-8格式
CM_TTS_ENCODE_TYPE_GB2312 | 普通字符为ASCII格式，汉字为GB2312格式

◆ cm_tts_rdn_e

enum cm_tts_rdn_e

数字播放方式

枚举值
CM_TTS_RDN_AUTO | 自动模式
CM_TTS_RDN_AS_VALUE | 数值模式
CM_TTS_RDN_AS_NUMBER | 数字模式
CM_TTS_RDN_AS_STR | 数字字符串优先

◆ cm_tts_pitch_e

enum cm_tts_pitch_e

音调

范围根据实际情况确定

枚举值
CM_TTS_PITCH_0 |
CM_TTS_PITCH_1 |
CM_TTS_PITCH_2 |
CM_TTS_PITCH_3 |
CM_TTS_PITCH_4 |
CM_TTS_PITCH_5 | 默认音调
CM_TTS_PITCH_6 |
CM_TTS_PITCH_7 |
CM_TTS_PITCH_8 |
CM_TTS_PITCH_9 |
CM_TTS_PITCH_10 |
CM_TTS_PITCH_11 |
CM_TTS_PITCH_12 |
CM_TTS_PITCH_13 |
CM_TTS_PITCH_14 |
CM_TTS_PITCH_15 |

◆ cm_tts_voice_e

enum cm_tts_voice_e

音效

范围根据实际情况确定

枚举值
CM_TTS_VOICE_0 | 默认音效,0为度小美
CM_TTS_VOICE_1 | 1为度小宇
CM_TTS_VOICE_2 | 2为度小宇
CM_TTS_VOICE_3 | 3为度逍遥
CM_TTS_VOICE_4 | 4为度丫丫

◆ cm_tts_channel_e

enum cm_tts_channel_e

播放通道

范围根据实际情况确定

枚举值
CM_TTS_CHANNEL_0 | 0 - 听筒
CM_TTS_CHANNEL_1 | 1 - 耳机
CM_TTS_CHANNEL_2 | 2 - 扬声器
CM_TTS_CHANNEL_3 | 3 - 远端（通话过程中在对端播放）

◆ cm_tts_state_e

enum cm_tts_state_e

TTS状态

枚举值
CM_TTS_STATE_IDLE | TTS空闲/播放结束（当前在线TTS版本存在缺陷，语音播放时也可能处于该状态）
CM_TTS_STATE_INTERRUPT | TTS播放异常中断
CM_TTS_STATE_FAIL | TTS播放失败
CM_TTS_STATE_WORKING | TTS工作中,不可使用（正在播放或其他音频功能正在使用）

◆ cm_tts_event_e

enum cm_tts_event_e

TTS回调的事件类型

枚举值
CM_TTS_EVENT_SYNTH_DATA | 语音合成数据上报，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_TTS_EVENT_SYNTH_FAIL | 语音合成失败，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_TTS_EVENT_SYNTH_INTERRUPT | 语音合成（异常）中断，调用cm_tts_synth()接口时可能上报的事件，不支持
CM_TTS_EVENT_SYNTH_FINISH | 语音合成完成，调用cm_tts_text_to_pcm()接口时可能上报的事件，不支持
CM_TTS_EVENT_PLAY_FAIL | 语音播放失败，调用cm_tts_play()接口时可能上报的事件
CM_TTS_EVENT_PLAY_INTERRUPT | 语音播放中断，调用cm_tts_play()接口时可能上报的事件
CM_TTS_EVENT_PLAY_FINISH | 语音播放完成，调用cm_tts_play()接口时可能上报的事件，不支持（回调通知仍会通知该事件，但该事件的通知不能正确反应播放完成，用户不应使用该事件做判断）

函数说明

◆ cm_local_tts_init()

int32_t cm_local_tts_init ( cm_local_tts_cfg_t * cfg )

TTS初始化

参数
[in] cfg 配置参数指针
返回
= 0 - 成功
= -1 - 失败

仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS等）支持离线TTS功能

◆ cm_local_tts_deinit()

void cm_local_tts_deinit ( void )

TTS去初始化

仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS等）支持离线TTS功能

◆ cm_local_tts_synth()

int32_t cm_local_tts_synth | ( | const void * | text,
 |  | int32_t | len,
 |  | cm_local_tts_callback | cb,
 |  | void * | cb_param
 | ) |  |

文字转语音PCM数据（不播放，转码后为PCM数据，采样率8k）

参数
[in] | text | 将要转码的文字
[in] | len | text的字符串长度
[in] | cb | TTS回调函数（回调函数不能阻塞）
[in] | cb_param | 用户参数（参见cm_local_tts_callback回调函数中param参数描述）
返回
= 0 - 成功
= -1 - 失败

同步函数，转码过程中该接口阻塞。仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS等）支持离线TTS功能
因程序在flash中运行速度较慢，出于内存空间和转码阻塞时间平衡性考虑，部分文字转语音PCM数据接口依赖的.o文件转至RAM中运行以提升处理速度，但该接口仍存在一定的阻塞时间
据统计，转码约10秒播放时间长度的文字该接口阻塞时长约1.1秒
如应用对TTS播放实时性要求高，建议事先执行转码操作并将转码数据保存至缓存中，待需要播放时从缓存中取数据并调用音频接口进行播放

◆ cm_local_tts_play()

int32_t cm_local_tts_play | ( | const char * | text,
 |  | int32_t | len,
 |  | cm_local_tts_callback | cb,
 |  | void * | cb_param
 | ) |  |

TTS播放文字

参数
[in] | text | 将要播放的文字
[in] | len | text的字符串长度
[in] | cb | TTS回调函数（回调函数不能阻塞）
[in] | cb_param | 用户参数（参见cm_tts_callback回调函数中param参数描述）
返回
= 0 - 成功
= -1 - 失败

转码完成后，此函数返回。函数返回不等效于播放完成
仅支持中文文本播放，不支持英文文本播放
最多支持播放10秒的TTS数据，超出10秒的TTS数据会丢弃（代码开源，用户可自行修改）
仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS等）支持离线TTS功能

◆ cm_local_tts_play_stop()

int32_t cm_local_tts_play_stop ( void )

停止TTS播放文字

返回
= 0 - 成功
= -1 - 失败

仅8M版本（ML307A-DSLN ML307A-GSLN ML305A-DS等）支持离线TTS功能

◆ cm_tts_init()

int32_t cm_tts_init ( cm_tts_cfg_t * cfg )

TTS初始化

参数
[in] cfg 配置参数指针
返回
= 0 - 成功
= -1 - 失败

在线TTS使用百度TTS，不支持中文文本编码方式设置，百度在线TTS仅可使用urlencode格式编码
cfg参数设置存在较多限制条件，请参照cm_tts_cfg_t结构体中说明进行cfg参数设置

◆ cm_tts_deinit()

void cm_tts_deinit ( void )

TTS去初始化

◆ cm_tts_play()

int32_t cm_tts_play | ( | const void * | text,
 |  | int32_t | len,
 |  | cm_tts_callback | cb,
 |  | void * | cb_param
 | ) |  |

TTS播放文字

参数
[in] | text | 将要播放的文字
[in] | len | text的字符串长度
[in] | cb | TTS回调函数（回调函数不能阻塞）
[in] | cb_param | 用户参数（参见cm_tts_callback回调函数中param参数描述）
返回
= 0 - 成功
= -1 - 失败

异步函数，播放任务建立后，此函数会立即返回
暂仅支持百度在线TTS，使用在线TTS功能需要占用一路HTTP通道
在线TTS使用百度TTS，text不支持中文文本编码方式设置，百度在线TTS中text仅可使用urlencode格式编码，仅支持播放不超时10秒时长的数据

◆ cm_tts_play_stop()

int32_t cm_tts_play_stop ( void )

停止TTS播放文字

返回
= 0 - 成功
= -1 - 失败

◆ cm_tts_get_state()

cm_tts_state_e cm_tts_get_state ( void )

获取TTS状态

返回
当前TTS状态


ML305A_ML307A_OpenCPU_API: cm_local_tts_cfg_t结构体 参考

成员变量
cm_local_tts_cfg_t结构体 参考
tts

#include <cm_local_tts.h>

成员变量

int32_t | speed
int32_t | volume
cm_local_tts_encode_e encode
cm_local_tts_digit_e digit
cm_local_tts_tone_e tone
cm_local_tts_effect_e effect

详细描述

TTS参数配置设置类型

结构体成员变量说明

◆ speed

int32_t speed

语速，范围0~15。语速设置对英文字符无效。

◆ volume

int32_t volume

TTS转化时音量，范围0~15

◆ encode

cm_local_tts_encode_e encode

中文文本编码方式

◆ digit

cm_local_tts_digit_e digit

数字播放模式

◆ tone

cm_local_tts_tone_e tone

音调，暂不支持

◆ effect

cm_local_tts_effect_e effect

音效，暂不支持

该结构体的文档由以下文件生成:
  • cm_local_tts.h


ML305A_ML307A_OpenCPU_API: cm_local_tts_synth_data_t结构体 参考

成员变量
cm_local_tts_synth_data_t结构体 参考
tts

#include <cm_local_tts.h>

成员变量

uint8_t * | data
uint32_t | len
void * | user

结构体成员变量说明

◆ data

uint8_t* data

语音合成数据（PCM）

◆ len

uint32_t len

语音合成数据长度

◆ user

void* user

用户传入参数

该结构体的文档由以下文件生成:
  • cm_local_tts.h


ML305A_ML307A_OpenCPU_API: cm_tts_cfg_t结构体 参考

成员变量
cm_tts_cfg_t结构体 参考
tts

#include <cm_tts.h>

成员变量

int32_t | speed
int32_t | volume
cm_tts_encode_e encode
cm_tts_rdn_e rdn
cm_tts_pitch_e pitch
cm_tts_voice_e voice
int32_t | channel
char * | url
char * | apiKey
char * | secretKey

详细描述

TTS设置类型，包括在线TTS传到云上的配置

结构体成员变量说明

◆ speed

int32_t speed

语速，范围根据实际情况确定,范围0-15

◆ volume

int32_t volume

TTS转化时音量，范围根据实际情况确定,范围0-15

◆ encode

cm_tts_encode_e encode

中文文本编码方式,（百度在线TTS）暂仅支持(且必须)设置为2（不生效，实际使用urlencode格式编码）

◆ rdn

cm_tts_rdn_e rdn

数字播放模式,暂仅支持(且必须)设置为0

◆ pitch

cm_tts_pitch_e pitch

音调,范围0-15

◆ voice

cm_tts_voice_e voice

音效,范围0-4

◆ channel

int32_t channel

播放通道，暂仅支持(且必须)设置为2（不生效，本平台仅有一个音频输出通道）

◆ url

char* url

TTS语音转换平台网址，仅支持百度在线TTS，配置其他URL不生效

◆ apiKey

char* apiKey

client_id （即注册账号的apikey)

◆ secretKey

char* secretKey

client_secret (secretKey)

该结构体的文档由以下文件生成:
  • cm_tts.h


ML305A_ML307A_OpenCPU_API: mem

结构体 | 变量
mem

结构体

struct cm_heap_stats_t

变量

uint32_t | total_size
uint32_t | allocated
uint32_t | free
uint32_t | max_continuity_free
uint32_t | allocated_peak
uint32_t | allocated_times
uint32_t | free_times
int32_t | cm_mem_get_heap_stats (cm_heap_stats_t *stats)
获取目前系统heap状态 更多...
void * | cm_malloc (size_t size)
申请内存 更多...
void * | cm_realloc (void *ptr, size_t size)
申请内存 更多...
void * | cm_calloc (size_t nitems, size_t size)
申请内存 更多...
void | cm_free (void *ptr)
释放内存 更多...

详细描述

函数说明

◆ cm_mem_get_heap_stats()

int32_t cm_mem_get_heap_stats ( cm_heap_stats_t * stats )

获取目前系统heap状态

参数
[out] stats heap状态
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

获取的为MemPool信息

◆ cm_malloc()

void* cm_malloc ( size_t size )

申请内存

参数
[in] size 申请长度
返回
返回内存地址

内存操作接口请勿使用C库接口，申请长度不能超过剩余可分配大小

◆ cm_realloc()

void* cm_realloc | ( | void * | ptr,
 |  | size_t | size
 | ) |  |

申请内存

参数
[in] | ptr | 待重新分配的内存块
[in] | size | 内存块的新大小
返回
返回内存地址

内存操作接口请勿使用C库接口，申请长度不能超过剩余可分配大小

◆ cm_calloc()

void* cm_calloc | ( | size_t | nitems,
 |  | size_t | size
 | ) |  |

申请内存

参数
[in] | nitems | 要被分配的元素个数
[in] | size | 元素的大小
返回
返回内存地址

内存操作接口请勿使用C库接口，申请长度不能超过剩余可分配大小

◆ cm_free()

void cm_free ( void * ptr )

释放内存

参数
[in] buf 待释放内存
返回
空

内存操作接口请勿使用C库接口

变量说明

◆ total_size

uint32_t total_size

总量大小

◆ allocated

uint32_t allocated

目前已分配大小

◆ free

uint32_t free

剩余可分配大小

◆ max_continuity_free

uint32_t max_continuity_free

本平台无效

◆ allocated_peak

uint32_t allocated_peak

本平台无效

◆ allocated_times

uint32_t allocated_times

本平台无效

◆ free_times

uint32_t free_times

本平台无效


ML305A_ML307A_OpenCPU_API: cm_heap_stats_t结构体 参考

成员变量
cm_heap_stats_t结构体 参考
mem

#include <cm_mem.h>

成员变量

uint32_t | total_size
uint32_t | allocated
uint32_t | free
uint32_t | max_continuity_free
uint32_t | allocated_peak
uint32_t | allocated_times
uint32_t | free_times

详细描述

heap状态

该结构体的文档由以下文件生成:
  • cm_mem.h


ML305A_ML307A_OpenCPU_API: modem

结构体 | 函数
modem

结构体

struct | cm_radio_info_t
struct | cm_cell_info_t

函数

int32_t | cm_modem_info_cell (cm_cell_info_t cell_info[], uint16_t cell_info_num)
获取模组小区信息 更多...
int32_t | cm_modem_info_radio (cm_radio_info_t *radio_info)
获取模组无线信息 更多...

详细描述

函数说明

◆ cm_modem_info_cell()

int32_t cm_modem_info_cell | ( | cm_cell_info_t | cell_info[],
 |  | uint16_t | cell_info_num
 | ) |  |

获取模组小区信息

参数
[out] | cell_info[] | 小区信息数组
[in] | cell_info_num | 欲获取小区信息个数（暂时只支持当前小区信息，该参数无效）
返回
>= 0 - 实际获取到的小区信息个数
< 0 - 失败, 返回值为错误码

More details

◆ cm_modem_info_radio()

int32_t cm_modem_info_radio ( cm_radio_info_t * radio_info )

获取模组无线信息

参数
[out] radio_info 无线信息
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

该函数无法获取rat，需通过虚拟AT+COPS？获取


ML305A_ML307A_OpenCPU_API: cm_radio_info_t结构体 参考

成员变量
cm_radio_info_t结构体 参考
modem

#include <cm_modem_info.h>

成员变量

uint8_t | rat
uint16_t | rsrp
uint16_t | rsrq
uint16_t | rssi
uint16_t | rxlev
uint16_t | tx_power
uint32_t | tx_time
uint32_t | rx_time
uint32_t | last_cellid
uint8_t | last_ecl
uint16_t | last_snr
uint32_t | last_earfcn
uint16_t | last_pci

详细描述

无线信息

结构体成员变量说明

◆ rat

uint8_t rat

◆ rsrp

uint16_t rsrp

无线接入模式

◆ rsrq

uint16_t rsrq

信号接收功率

◆ rssi

uint16_t rssi

信号接收质量

◆ rxlev

uint16_t rxlev

信号强度指示

◆ tx_power

uint16_t tx_power

信号接收电平

◆ tx_time

uint32_t tx_time

最近一次发射功率

◆ rx_time

uint32_t rx_time

上行累计发送时长

◆ last_cellid

uint32_t last_cellid

下行累计接收时长

◆ last_ecl

uint8_t last_ecl

上一次SB1服务小区ID

◆ last_snr

uint16_t last_snr

上一次ECL值

◆ last_earfcn

uint32_t last_earfcn

上一次信噪比

◆ last_pci

uint16_t last_pci

上一次绝对射频频道编号

该结构体的文档由以下文件生成:
  • cm_modem_info.h


ML305A_ML307A_OpenCPU_API: cm_cell_info_t结构体 参考

成员变量
cm_cell_info_t结构体 参考
modem

#include <cm_modem_info.h>

成员变量

bool primary_cell
uint8_t | mcc [8]
uint8_t | mnc [8]
uint32_t | earfcn
uint8_t | earfcn_offset
uint16_t | tac
uint16_t | pci
uint16_t | rsrp
uint16_t | rsrq
uint16_t | rssi
uint16_t | snr
uint32_t | bandwidth
uint32_t | cid

详细描述

小区信息

结构体成员变量说明

◆ primary_cell

bool primary_cell

◆ mcc

uint8_t mcc[8]

是否为当前驻留小区

◆ mnc

uint8_t mnc[8]

移动国家代码

◆ earfcn

uint32_t earfcn

移动网络代码

◆ earfcn_offset

uint8_t earfcn_offset

绝对射频频道编号

◆ tac

uint16_t tac

绝对射频频偏

◆ pci

uint16_t pci

类型分配码

◆ rsrp

uint16_t rsrp

小区物理ID

◆ rsrq

uint16_t rsrq

信号接收功率

◆ rssi

uint16_t rssi

信号接收质量

◆ snr

uint16_t snr

信号强度指示

◆ bandwidth

uint32_t bandwidth

信噪比

◆ cid

uint32_t cid

带宽

该结构体的文档由以下文件生成:
  • cm_modem_info.h


ML305A_ML307A_OpenCPU_API: mqtt

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
mqtt

结构体

struct | cm_mqtt_topic_t
struct | cm_mqtt_connect_options_t
struct | cm_mqtt_client_cb_t

宏定义

#define | CM_MQTT_RETAIN_0 (0x0)
#define | CM_MQTT_RETAIN_1 (0x1)
#define | CM_MQTT_QOS_0 (0x0)
#define | CM_MQTT_QOS_1 (0x1 << 1)
#define | CM_MQTT_QOS_2 (0x2 << 1)
#define | CM_MQTT_DUP_0 (0x0)
#define | CM_MQTT_DUP_1 (0x1 << 3)
#define | CM_MQTT_TOPIC_SUBSCRIBING 0
#define | CM_MQTT_TOPIC_SUBSCRIBED 1
#define | CM_MQTT_TOPIC_UNSUBSCRIBING 2

类型定义

typedef struct _cm_mqtt_client_t cm_mqtt_client_t

枚举

enum cm_mqtt_state_e { CM_MQTT_STATE_DISCONNECTED , CM_MQTT_STATE_CONNECTED , CM_MQTT_STATE_CONNECTING , CM_MQTT_STATE_RECONNECTING }
enum cm_mqtt_conn_state_e {
CM_MQTT_CONN_STATE_SUCCESS = 0 , CM_MQTT_CONN_STATE_RECONNECTING , CM_MQTT_CONN_STATE_CLIENT_SHUTDOWN , CM_MQTT_CONN_STATE_SERVER_REJECED ,
CM_MQTT_CONN_STATE_SERVER_SHUTDOWN , CM_MQTT_CONN_STATE_PING_TIMEOUT , CM_MQTT_CONN_STATE_NET_ERR , CM_MQTT_CONN_STATE_UNKNOWN_ERR = 255
}
enum cm_mqtt_option_e {
CM_MQTT_OPT_START = 0 , CM_MQTT_OPT_CID = CM_MQTT_OPT_START , CM_MQTT_OPT_VERSION , CM_MQTT_OPT_DNS_PRIORITY ,
CM_MQTT_OPT_SSL_ENABLE , CM_MQTT_OPT_SSL_ID , CM_MQTT_OPT_PING_CYCLE , CM_MQTT_OPT_PKT_TIMEOUT ,
CM_MQTT_OPT_RETRY_TIMES , CM_MQTT_OPT_RECONN_MODE , CM_MQTT_OPT_RECONN_TIMES , CM_MQTT_OPT_RECONN_CYCLE ,
CM_MQTT_OPT_EVENT , CM_MQTT_OPT_EVENT_CONNACK_CB , CM_MQTT_OPT_EVENT_PUBLISH_CB , CM_MQTT_OPT_EVENT_PUBACK_CB ,
CM_MQTT_OPT_EVENT_PUBREC_CB , CM_MQTT_OPT_EVENT_PUBREL_CB , CM_MQTT_OPT_EVENT_PUBCOMP_CB , CM_MQTT_OPT_EVENT_SUBACK_CB ,
CM_MQTT_OPT_EVENT_UNSUBACK_CB , CM_MQTT_OPT_EVENT_PINGRESP_CB , CM_MQTT_OPT_EVENT_TIMEOUT_CB , CM_MQTT_OPT_END
}
enum cm_mqtt_err_code_e {
CM_MQTT_RET_OK = 0 , CM_MQTT_RET_INVALID_PARAM = -1 , CM_MQTT_RET_NOT_CONNECT = -2 , CM_MQTT_RET_CONNECTING = -3 ,
CM_MQTT_RET_ALREADY_CONNECTED = -4 , CM_MQTT_RET_NET_ERR = -5 , CM_MQTT_RET_MEM_ERR = -6 , CM_MQTT_RET_STATE_ERR = -7 ,
CM_MQTT_RET_DNS_ERR = -8 , CM_MQTT_RET_UNKNOWN_ERR = -99
}

函数

cm_mqtt_client_t * | cm_mqtt_client_create (void)
创建mqtt client 更多...
int | cm_mqtt_client_destroy (cm_mqtt_client_t *client)
销毁mqtt client 更多...
int | cm_mqtt_client_connect (cm_mqtt_client_t *client, cm_mqtt_connect_options_t *option)
连接 更多...
int | cm_mqtt_client_publish (cm_mqtt_client_t *client, const char *topic, const char *payload, int payload_len, char publish_flags)
发布消息 更多...
int | cm_mqtt_client_subscribe (cm_mqtt_client_t *client, const char *topic[], const char qos[], int count)
订阅 更多...
int | cm_mqtt_client_unsubscribe (cm_mqtt_client_t *client, const char *topic[], int count)
取消订阅 更多...
int | cm_mqtt_client_disconnect (cm_mqtt_client_t *client)
断开连接 更多...
int | cm_mqtt_client_set_opt (cm_mqtt_client_t *client, cm_mqtt_option_e option, void *param)
client参数设置 更多...
int | cm_mqtt_client_get_msgid (cm_mqtt_client_t *client)
获取client当前的消息ID 更多...
int | cm_mqtt_client_get_state (cm_mqtt_client_t *client)
获取client当前的状态 更多...
linklist_t * | cm_mqtt_client_get_sub_topics (cm_mqtt_client_t *client)
获取client订阅列表 更多...

详细描述

宏定义说明

◆ CM_MQTT_RETAIN_0

#define CM_MQTT_RETAIN_0 (0x0)

◆ CM_MQTT_RETAIN_1

#define CM_MQTT_RETAIN_1 (0x1)

◆ CM_MQTT_QOS_0

#define CM_MQTT_QOS_0 (0x0)

◆ CM_MQTT_QOS_1

#define CM_MQTT_QOS_1 (0x1 << 1)

◆ CM_MQTT_QOS_2

#define CM_MQTT_QOS_2 (0x2 << 1)

◆ CM_MQTT_DUP_0

#define CM_MQTT_DUP_0 (0x0)

◆ CM_MQTT_DUP_1

#define CM_MQTT_DUP_1 (0x1 << 3)

◆ CM_MQTT_TOPIC_SUBSCRIBING

#define CM_MQTT_TOPIC_SUBSCRIBING 0

◆ CM_MQTT_TOPIC_SUBSCRIBED

#define CM_MQTT_TOPIC_SUBSCRIBED 1

◆ CM_MQTT_TOPIC_UNSUBSCRIBING

#define CM_MQTT_TOPIC_UNSUBSCRIBING 2

类型定义说明

◆ cm_mqtt_client_t

typedef struct _cm_mqtt_client_t cm_mqtt_client_t

枚举类型说明

◆ cm_mqtt_state_e

enum cm_mqtt_state_e

client状态信息

枚举值
CM_MQTT_STATE_DISCONNECTED | 连接断开
CM_MQTT_STATE_CONNECTED | 已连接
CM_MQTT_STATE_CONNECTING | 连接中
CM_MQTT_STATE_RECONNECTING | 重连中

◆ cm_mqtt_conn_state_e

enum cm_mqtt_conn_state_e

异步状态信息

枚举值
CM_MQTT_CONN_STATE_SUCCESS | 连接成功
CM_MQTT_CONN_STATE_RECONNECTING | 正在重连
CM_MQTT_CONN_STATE_CLIENT_SHUTDOWN | client断开
CM_MQTT_CONN_STATE_SERVER_REJECED | server拒绝
CM_MQTT_CONN_STATE_SERVER_SHUTDOWN | server断开
CM_MQTT_CONN_STATE_PING_TIMEOUT | ping超时
CM_MQTT_CONN_STATE_NET_ERR | 网络异常
CM_MQTT_CONN_STATE_UNKNOWN_ERR | 未知错误

◆ cm_mqtt_option_e

enum cm_mqtt_option_e

client设置参数枚举，用于mqtt参数设置

枚举值
CM_MQTT_OPT_START |
CM_MQTT_OPT_CID |
CM_MQTT_OPT_VERSION |
CM_MQTT_OPT_DNS_PRIORITY | MQTT dns解析优先级, 0(默认):使用全局优先级, 1:v4优先, 2:v6优先
CM_MQTT_OPT_SSL_ENABLE | SSL开启，1：MQTTS，0：MQTT
CM_MQTT_OPT_SSL_ID | SSL通道
CM_MQTT_OPT_PING_CYCLE | 发送ping包的周期，单位:s
CM_MQTT_OPT_PKT_TIMEOUT | 发送超时，单位:s
CM_MQTT_OPT_RETRY_TIMES | 重传次数
CM_MQTT_OPT_RECONN_MODE | 重连模式，0:以固定间隔尝试重连，1:以上次重连间隔的2倍尝试重连
CM_MQTT_OPT_RECONN_TIMES | 重连次数
CM_MQTT_OPT_RECONN_CYCLE | 重连间隔，单位:s
CM_MQTT_OPT_EVENT | 回调函数集合
CM_MQTT_OPT_EVENT_CONNACK_CB |
CM_MQTT_OPT_EVENT_PUBLISH_CB |
CM_MQTT_OPT_EVENT_PUBACK_CB |
CM_MQTT_OPT_EVENT_PUBREC_CB |
CM_MQTT_OPT_EVENT_PUBREL_CB |
CM_MQTT_OPT_EVENT_PUBCOMP_CB |
CM_MQTT_OPT_EVENT_SUBACK_CB |
CM_MQTT_OPT_EVENT_UNSUBACK_CB |
CM_MQTT_OPT_EVENT_PINGRESP_CB |
CM_MQTT_OPT_EVENT_TIMEOUT_CB |
CM_MQTT_OPT_END |

◆ cm_mqtt_err_code_e

enum cm_mqtt_err_code_e

错误码定义

枚举值
CM_MQTT_RET_OK
CM_MQTT_RET_INVALID_PARAM
CM_MQTT_RET_NOT_CONNECT
CM_MQTT_RET_CONNECTING
CM_MQTT_RET_ALREADY_CONNECTED
CM_MQTT_RET_NET_ERR
CM_MQTT_RET_MEM_ERR
CM_MQTT_RET_STATE_ERR
CM_MQTT_RET_DNS_ERR
CM_MQTT_RET_UNKNOWN_ERR

函数说明

◆ cm_mqtt_client_create()

cm_mqtt_client_t* cm_mqtt_client_create ( void )

创建mqtt client

返回
成功返回mqtt client，失败返回NULL

从client列表中创建空闲的client，最大只能同时创建5路通道

◆ cm_mqtt_client_destroy()

int cm_mqtt_client_destroy ( cm_mqtt_client_t * client )

销毁mqtt client

参数
[in] client mqtt client
返回
成功返回0，失败返回-1

清除并释放client，异步

◆ cm_mqtt_client_connect()

int cm_mqtt_client_connect | ( | cm_mqtt_client_t * | client,
 |  | cm_mqtt_connect_options_t * | option
 | ) |  |

连接

参数
[in] | client | mqtt client
[in] | option | 连接选项
返回
成功返回0，失败返回错误码，参考cm_mqtt_err_code_e

异步接口，连接结果和状态请根据对应回调函数判断

◆ cm_mqtt_client_publish()

int cm_mqtt_client_publish | ( | cm_mqtt_client_t * | client,
 |  | const char * | topic,
 |  | const char * | payload,
 |  | int | payload_len,
 |  | char | publish_flags
 | ) |  |

发布消息

参数
[in] | client | mqtt client
[in] | topic | 主题
[in] | payload | 负载
[in] | payload_len | 负载长度
[in] | publish_flags | 固定头部信息
返回
成功返回publish长度，失败返回错误码，参考cm_mqtt_err_code_e

异步接口，是否发布成功请根据对应回调函数判断

◆ cm_mqtt_client_subscribe()

int cm_mqtt_client_subscribe | ( | cm_mqtt_client_t * | client,
 |  | const char * | topic[],
 |  | const char | qos[],
 |  | int | count
 | ) |  |

订阅

参数
[in] | client | mqtt client
[in] | topic | 主题列表
[in] | qos | qos列表
[in] | count | 主题个数
返回
成功返回0，失败返回错误码，参考cm_mqtt_err_code_e

一个topic必须对应一个qos值，单个qos值为char型数据，取值范围是0/1/2，表示实际qos0/qos1/qos2
异步接口，是否订阅成功请根据对应回调函数判断

◆ cm_mqtt_client_unsubscribe()

int cm_mqtt_client_unsubscribe | ( | cm_mqtt_client_t * | client,
 |  | const char * | topic[],
 |  | int | count
 | ) |  |

取消订阅

参数
[in] | client | mqtt client
[in] | topic | 主题列表
[in] | count | 主题个数
返回
成功返回0，失败返回错误码，参考cm_mqtt_err_code_e

异步接口，是否取消订阅成功请根据对应回调函数判断

◆ cm_mqtt_client_disconnect()

int cm_mqtt_client_disconnect ( cm_mqtt_client_t * client )

断开连接

参数
[in] client mqtt客户端
返回
成功返回0，失败返回-1

异步接口，是否成功断开连接结果请根据对应回调函数判断

◆ cm_mqtt_client_set_opt()

int cm_mqtt_client_set_opt | ( | cm_mqtt_client_t * | client,
 |  | cm_mqtt_option_e | option,
 |  | void * | param
 | ) |  |

client参数设置

参数
[in] | client | mqtt客户端
[in] | option | 设置项
[in] | param | 设置参数
返回
成功返回0，失败返回错误码，详见cm_mqtt_err_code_e

◆ cm_mqtt_client_get_msgid()

int cm_mqtt_client_get_msgid ( cm_mqtt_client_t * client )

获取client当前的消息ID

参数
[in] client mqtt客户端
返回
成功返回消息ID，失败返回-1

◆ cm_mqtt_client_get_state()

int cm_mqtt_client_get_state ( cm_mqtt_client_t * client )

获取client当前的状态

参数
[in] client mqtt客户端
返回
成功返回client当前的状态，详见cm_mqtt_state_e，失败返回-1

◆ cm_mqtt_client_get_sub_topics()

linklist_t* cm_mqtt_client_get_sub_topics ( cm_mqtt_client_t * client )

获取client订阅列表

参数
[in] client mqtt客户端
返回
成功返回订阅列表，失败返回NULL


ML305A_ML307A_OpenCPU_API: cm_mqtt_topic_t结构体 参考

成员变量
cm_mqtt_topic_t结构体 参考
mqtt

#include <cm_mqtt.h>

成员变量

char | state
char | qos
unsigned short | msg_id
int | topic_len
char | topic [0]

详细描述

topic信息

结构体成员变量说明

◆ state

char state

订阅状态，0:订阅中,1:已订阅,2:取消订阅中

◆ qos

char qos

qos等级

◆ msg_id

unsigned short msg_id

消息ID

◆ topic_len

int topic_len

topic长度

◆ topic

char topic[0]

topic内容

该结构体的文档由以下文件生成:
  • cm_mqtt.h


ML305A_ML307A_OpenCPU_API: cm_mqtt_connect_options_t结构体 参考

成员变量
cm_mqtt_connect_options_t结构体 参考
mqtt

#include <cm_mqtt.h>

成员变量

unsigned short | hostport
const char * | hostname
const char * | clientid
const char * | username
const char * | password
const char * | will_topic
const char * | will_message
int | will_message_len
char | will_flag
char | will_qos
char | will_retain
char | clean_session
char | conn_flags
unsigned short | keepalive

详细描述

连接选项

结构体成员变量说明

◆ hostport

unsigned short hostport

服务器端口号

◆ hostname

const char* hostname

服务器域名或IP

◆ clientid

const char* clientid

clientid

◆ username

const char* username

用户名

◆ password

const char* password

密码

◆ will_topic

const char* will_topic

遗嘱标题

◆ will_message

const char* will_message

遗嘱信息

◆ will_message_len

int will_message_len

遗嘱信息长度

◆ will_flag

char will_flag

遗嘱标志

◆ will_qos

char will_qos

qos

◆ will_retain

char will_retain

retain

◆ clean_session

char clean_session

清除标志

◆ conn_flags

char conn_flags

连接标志

◆ keepalive

unsigned short keepalive

保活时间

该结构体的文档由以下文件生成:
  • cm_mqtt.h


ML305A_ML307A_OpenCPU_API: cm_mqtt_client_cb_t结构体 参考

成员变量
cm_mqtt_client_cb_t结构体 参考
mqtt

#include <cm_mqtt.h>

成员变量

int(* | connack_cb )(cm_mqtt_client_t *client, int session, cm_mqtt_conn_state_e conn_res)
int(* | publish_cb )(cm_mqtt_client_t *client, unsigned short msgid, char *topic, int total_len, int payload_len, char *payload)
int(* | puback_cb )(cm_mqtt_client_t *client, unsigned short msgid, char dup)
int(* | pubrec_cb )(cm_mqtt_client_t *client, unsigned short msgid, char dup)
int(* | pubrel_cb )(cm_mqtt_client_t *client, unsigned short msgid, char dup)
int(* | pubcomp_cb )(cm_mqtt_client_t *client, unsigned short msgid, char dup)
int(* | suback_cb )(cm_mqtt_client_t *client, unsigned short msgid, int count, int qos[])
int(* | unsuback_cb )(cm_mqtt_client_t *client, unsigned short msgid)
int(* | pingresp_cb )(cm_mqtt_client_t *client, int ret)
int(* | timeout_cb )(cm_mqtt_client_t *client, unsigned short msgid)

详细描述

回调函数

结构体成员变量说明

◆ connack_cb

int(* connack_cb) (cm_mqtt_client_t *client, int session, cm_mqtt_conn_state_e conn_res)

connack

◆ publish_cb

int(* publish_cb) (cm_mqtt_client_t *client, unsigned short msgid, char *topic, int total_len, int payload_len, char *payload)

s->c publish

◆ puback_cb

int(* puback_cb) (cm_mqtt_client_t *client, unsigned short msgid, char dup)

puback

◆ pubrec_cb

int(* pubrec_cb) (cm_mqtt_client_t *client, unsigned short msgid, char dup)

pubrec

◆ pubrel_cb

int(* pubrel_cb) (cm_mqtt_client_t *client, unsigned short msgid, char dup)

pubrel

◆ pubcomp_cb

int(* pubcomp_cb) (cm_mqtt_client_t *client, unsigned short msgid, char dup)

pubcomp

◆ suback_cb

int(* suback_cb) (cm_mqtt_client_t *client, unsigned short msgid, int count, int qos[])

s->c suback

◆ unsuback_cb

int(* unsuback_cb) (cm_mqtt_client_t *client, unsigned short msgid)

s->c unsuback

◆ pingresp_cb

int(* pingresp_cb) (cm_mqtt_client_t *client, int ret)

s->c pinrsp

◆ timeout_cb

int(* timeout_cb) (cm_mqtt_client_t *client, unsigned short msgid)

发送超时

该结构体的文档由以下文件生成:
  • cm_mqtt.h


ML305A_ML307A_OpenCPU_API: ntp

类型定义 | 枚举 | 函数
ntp

类型定义

typedef void(* cm_ntp_event_cb_t) (cm_ntp_event_e event, void *event_param, void *cb_param)

枚举

enum cm_ntp_event_e { CM_NTP_EVENT_SYNC_FAIL , CM_NTP_EVENT_SYNC_OK , CM_NTP_EVENT_SETTIME_FAIL }
enum cm_ntp_cfg_type_e {
CM_NTP_CFG_SERVER = 1 , CM_NTP_CFG_PORT , CM_NTP_CFG_TIMEOUT , CM_NTP_CFG_DNS ,
CM_NTP_CFG_SET_RTC , CM_NTP_CFG_CB , CM_NTP_CFG_CB_PARAM
}

函数

int32_t | cm_ntp_set_cfg (cm_ntp_cfg_type_e type, void *value)
NTP服务设置参数 更多...
int32_t | cm_ntp_sync (void)
执行NTP时间同步 更多...

详细描述

类型定义说明

◆ cm_ntp_event_cb_t

typedef void(* cm_ntp_event_cb_t) (cm_ntp_event_e event, void *event_param, void *cb_param)

NTP事件回调函数

枚举类型说明

◆ cm_ntp_event_e

enum cm_ntp_event_e

NTP事件类型

枚举值
CM_NTP_EVENT_SYNC_FAIL | NTP时间同步失败, 参数(event_param): NULL
CM_NTP_EVENT_SYNC_OK | NTP时间同步成功, 参数(event_param): 获取到的NTP时间, ISO-8601时间格式字符串, 例如: 2021-04-21T17:10:08.868+08:00
CM_NTP_EVENT_SETTIME_FAIL | NTP时间同步成功但设置本地时间失败, 参数(event_param): 获取到的NTP时间, ISO-8601时间格式字符串, 例如: 2021-04-21T17:10:08.868+08:00

◆ cm_ntp_cfg_type_e

enum cm_ntp_cfg_type_e

NTP设置类型

枚举值
CM_NTP_CFG_SERVER | NTP服务器，支持域名、ipv4地址、ipv6地址，设置参数为字符串型（最多128字节），未设置时使用默认服务器
CM_NTP_CFG_PORT | NTP服务器端口号，端口号为uint16_t型，未设置时使用123端口
CM_NTP_CFG_TIMEOUT | NTP超时时间，未设置时为3000毫秒，支持设置范围1000~10000，单位为毫秒
CM_NTP_CFG_DNS | NTP服务器为域名时DNS解析IP地址优先级，优先级为uint32_t型，0(默认)：使用全局优先级。1：v4优先。2：v6优先
CM_NTP_CFG_SET_RTC | 是否将获取到的NTP时间设置到RTC设置，参数为bool型，0：不同步至系统时间。1（默认）：同步至系统时间
CM_NTP_CFG_CB | NTP服务回调函数设置，回调函数类型见cm_ntp_event_cb
CM_NTP_CFG_CB_PARAM | NTP服务回调函数中传递的用户参数指针

函数说明

◆ cm_ntp_set_cfg()

int32_t cm_ntp_set_cfg | ( | cm_ntp_cfg_type_e | type,
 |  | void * | value
 | ) |  |

NTP服务设置参数

参数
[in] | type | 设置参数类型
[in] | value | 设置参数数值
返回
= 0 - 成功
= -1 - 失败

NTP服务进行中不可设置

◆ cm_ntp_sync()

int32_t cm_ntp_sync ( void )

执行NTP时间同步

返回
= 0 - 成功
< 0 - 错误码

NTP模块底层依赖asocket、async_dns和eloop模块


ML305A_ML307A_OpenCPU_API: os

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
os

结构体

struct | osVersion_t
struct | osThreadAttr_t
struct | osTimerAttr_t
struct | osEventFlagsAttr_t
struct | osMutexAttr_t
struct | osSemaphoreAttr_t
struct | osMemoryPoolAttr_t
struct | osMessageQueueAttr_t

宏定义

#define | __NO_RETURN
#define | osWaitForever 0xFFFFFFFFU
#define | osFlagsWaitAny 0x00000000U
#define | osFlagsWaitAll 0x00000001U
#define | osFlagsNoClear 0x00000002U
#define | osFlagsError 0x80000000U
#define | osFlagsErrorUnknown 0xFFFFFFFFU
#define | osFlagsErrorTimeout 0xFFFFFFFEU
#define | osFlagsErrorResource 0xFFFFFFFDU
#define | osFlagsErrorParameter 0xFFFFFFFCU
#define | osFlagsErrorISR 0xFFFFFFFAU
#define | osThreadDetached 0x00000000U
#define | osThreadJoinable 0x00000001U
#define | osMutexRecursive 0x00000001U
#define | osMutexPrioInherit 0x00000002U
#define | osMutexRobust 0x00000008U

类型定义

typedef void(* | osThreadFunc_t) (void *argument)
typedef void(* | osTimerFunc_t) (void *argument)
typedef void * | osThreadId_t
typedef void * | osTimerId_t
typedef void * | osEventFlagsId_t
typedef void * | osMutexId_t
typedef void * | osSemaphoreId_t
typedef void * | osMemoryPoolId_t
typedef void * | osMessageQueueId_t
typedef uint32_t | TZ_ModuleId_t

枚举

enum osKernelState_t {
osKernelInactive = 0 , osKernelReady = 1 , osKernelRunning = 2 , osKernelLocked = 3 ,
osKernelSuspended = 4 , osKernelError = -1 , osKernelReserved = 0x7FFFFFFF
}
enum osThreadState_t {
osThreadInactive = 0 , osThreadReady = 1 , osThreadRunning = 2 , osThreadBlocked = 3 ,
osThreadTerminated = 4 , osThreadError = -1 , osThreadReserved = 0x7FFFFFFF
}
enum osPriority_t {
osPriorityIdle = 0 , osPriorityLow = 2 , osPriorityBelowNormal = 3 , osPriorityNormal = 4 ,
osPriorityAboveNormal = 5 , osPriorityHigh = 6 , osPrioritySoftRealtime = 7 , osPriorityHardRealtime = 8 ,
osPriorityISR = 32 , osPriorityError = -1 , osPriorityReserved = 0x7FFFFFFF
}
enum osTimerType_t { osTimerOnce = 0 , osTimerPeriodic = 1 }
enum osStatus_t {
osOK = 0 , osError = -1 , osErrorTimeout = -2 , osErrorResource = -3 ,
osErrorParameter = -4 , osErrorNoMemory = -5 , osErrorISR = -6 , osStatusReserved = 0x7FFFFFFF
}

函数

int32_t | osKernelLock (void)
Lock the RTOS Kernel scheduler. 更多...
int32_t | osKernelUnlock (void)
Unlock the RTOS Kernel scheduler. 更多...
uint32_t | osKernelGetTickFreq (void)
Get the RTOS kernel tick frequency. 更多...
uint32_t | osKernelGetTickCount (void)
Get the RTOS kernel tick count. 更多...
osThreadId_t | osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
Create a thread and add it to Active Threads. 更多...
const char * | osThreadGetName (osThreadId_t thread_id)
Get name of a thread. 更多...
osThreadId_t | osThreadGetId (void)
Return the thread ID of the current running thread. 更多...
osThreadState_t | osThreadGetState (osThreadId_t thread_id)
Get current thread state of a thread. 更多...
uint32_t | osThreadGetStackSize (osThreadId_t thread_id)
Get stack size of a thread. 更多...
uint32_t | osThreadGetStackSpace (osThreadId_t thread_id)
Get available stack space of a thread based on stack watermark recording during execution. 更多...
osStatus_t | osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority)
Change priority of a thread. 更多...
osPriority_t | osThreadGetPriority (osThreadId_t thread_id)
Get current priority of a thread. 更多...
osStatus_t | osThreadYield (void)
Pass control to next thread that is in state READY. 更多...
osStatus_t | osThreadSuspend (osThreadId_t thread_id)
Suspend execution of a thread. 更多...
osStatus_t | osThreadResume (osThreadId_t thread_id)
Resume execution of a thread. 更多...
osStatus_t | osThreadTerminate (osThreadId_t thread_id)
Terminate execution of a thread. 更多...
uint32_t | osThreadGetCount (void)
Get number of active threads. 更多...
osStatus_t | osDelay (uint32_t ticks)
Wait for Timeout (Time Delay). 更多...
osTimerId_t | osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
Create and Initialize a timer. 更多...
osStatus_t | osTimerStart (osTimerId_t timer_id, uint32_t ticks)
Get name of a timer. 更多...
osStatus_t | osTimerStop (osTimerId_t timer_id)
Stop a timer. 更多...
uint32_t | osTimerIsRunning (osTimerId_t timer_id)
Check if a timer is running. 更多...
osStatus_t | osTimerDelete (osTimerId_t timer_id)
Delete a timer. 更多...
osEventFlagsId_t | osEventFlagsNew (const osEventFlagsAttr_t *attr)
Create and Initialize an Event Flags object. 更多...
uint32_t | osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)
Set the specified Event Flags. 更多...
uint32_t | osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)
Clear the specified Event Flags. 更多...
osStatus_t | osEventFlagsDelete (osEventFlagsId_t ef_id)
Delete an Event Flags object. 更多...
osMutexId_t | osMutexNew (const osMutexAttr_t *attr)
Create and Initialize a Mutex object. 更多...
osStatus_t | osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout)
Acquire a Mutex or timeout if it is locked. 更多...
osStatus_t | osMutexRelease (osMutexId_t mutex_id)
Release a Mutex that was acquired by osMutexAcquire. 更多...
osStatus_t | osMutexDelete (osMutexId_t mutex_id)
Get Thread which owns a Mutex object. 更多...
osSemaphoreId_t | osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
Create and Initialize a Semaphore object. 更多...
osStatus_t | osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout)
Acquire a Semaphore token or timeout if no tokens are available. 更多...
osStatus_t | osSemaphoreRelease (osSemaphoreId_t semaphore_id)
Release a Semaphore token up to the initial maximum count. 更多...
osStatus_t | osSemaphoreDelete (osSemaphoreId_t semaphore_id)
Get current Semaphore token count. 更多...
osMessageQueueId_t | osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)
Create and Initialize a Message Queue object. 更多...
osStatus_t | osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout)
Put a Message into a Queue or timeout if Queue is full. 更多...
osStatus_t | osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
Get a Message from a Queue or timeout if Queue is empty. 更多...
osStatus_t | osMessageQueueDelete (osMessageQueueId_t mq_id)
Get maximum number of messages in a Message Queue. 更多...

详细描述

宏定义说明

◆ __NO_RETURN

#define __NO_RETURN

◆ osWaitForever

#define osWaitForever 0xFFFFFFFFU

Timeout value. Wait forever timeout value.

◆ osFlagsWaitAny

#define osFlagsWaitAny 0x00000000U

Flags options (osThreadFlagsWait and osEventFlagsWait). Wait for any flag (default).

◆ osFlagsWaitAll

#define osFlagsWaitAll 0x00000001U

Wait for all flags.

◆ osFlagsNoClear

#define osFlagsNoClear 0x00000002U

Do not clear flags which have been specified to wait for.

◆ osFlagsError

#define osFlagsError 0x80000000U

Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx). Error indicator.

◆ osFlagsErrorUnknown

#define osFlagsErrorUnknown 0xFFFFFFFFU

osError (-1).

◆ osFlagsErrorTimeout

#define osFlagsErrorTimeout 0xFFFFFFFEU

osErrorTimeout (-2).

◆ osFlagsErrorResource

#define osFlagsErrorResource 0xFFFFFFFDU

osErrorResource (-3).

◆ osFlagsErrorParameter

#define osFlagsErrorParameter 0xFFFFFFFCU

osErrorParameter (-4).

◆ osFlagsErrorISR

#define osFlagsErrorISR 0xFFFFFFFAU

osErrorISR (-6).

◆ osThreadDetached

#define osThreadDetached 0x00000000U

Thread attributes (attr_bits in osThreadAttr_t). Thread created in detached mode (default).

◆ osThreadJoinable

#define osThreadJoinable 0x00000001U

Thread created in joinable mode.

◆ osMutexRecursive

#define osMutexRecursive 0x00000001U

Mutex attributes (attr_bits in osMutexAttr_t). Recursive mutex.

◆ osMutexPrioInherit

#define osMutexPrioInherit 0x00000002U

Priority inherit protocol.

◆ osMutexRobust

#define osMutexRobust 0x00000008U

Robust mutex.

类型定义说明

◆ osThreadFunc_t

typedef void(* osThreadFunc_t) (void *argument)

Entry point of a thread.

◆ osTimerFunc_t

typedef void(* osTimerFunc_t) (void *argument)

Timer callback function.

◆ osThreadId_t

typedef void* osThreadId_t

Thread ID identifies the thread.

◆ osTimerId_t

typedef void* osTimerId_t

Timer ID identifies the timer.

◆ osEventFlagsId_t

typedef void* osEventFlagsId_t

Event Flags ID identifies the event flags.

◆ osMutexId_t

typedef void* osMutexId_t

Mutex ID identifies the mutex.

◆ osSemaphoreId_t

typedef void* osSemaphoreId_t

Semaphore ID identifies the semaphore.

◆ osMemoryPoolId_t

typedef void* osMemoryPoolId_t

Memory Pool ID identifies the memory pool.

◆ osMessageQueueId_t

typedef void* osMessageQueueId_t

Message Queue ID identifies the message queue.

◆ TZ_ModuleId_t

typedef uint32_t TZ_ModuleId_t

Data type that identifies secure software modules called by a process.

枚举类型说明

◆ osKernelState_t

enum osKernelState_t

Kernel state.

枚举值
osKernelInactive | Inactive.
osKernelReady | Ready.
osKernelRunning | Running.
osKernelLocked | Locked.
osKernelSuspended | Suspended.
osKernelError | Error.
osKernelReserved | Prevents enum down-size compiler optimization.

◆ osThreadState_t

enum osThreadState_t

Thread state.

枚举值
osThreadInactive | Inactive.
osThreadReady | Ready.
osThreadRunning | Running.
osThreadBlocked | Blocked.
osThreadTerminated | Terminated.
osThreadError | Error.
osThreadReserved | Prevents enum down-size compiler optimization.

◆ osPriority_t

enum osPriority_t

Priority values.

枚举值
osPriorityIdle | Reserved for Idle thread.
osPriorityLow | Priority: low
osPriorityBelowNormal | Priority: below normal
osPriorityNormal | Priority: normal
osPriorityAboveNormal | Priority: above normal
osPriorityHigh | Priority: high
osPrioritySoftRealtime | Priority: realtime
osPriorityHardRealtime | Priority: realtime
osPriorityISR | Reserved for ISR deferred thread,Do not use!
osPriorityError | System cannot determine priority or illegal priority.
osPriorityReserved | Prevents enum down-size compiler optimization.

◆ osTimerType_t

enum osTimerType_t

Timer type.

枚举值
osTimerOnce | One-shot timer.
osTimerPeriodic | Repeating timer.

◆ osStatus_t

enum osStatus_t

Status code values returned by CMSIS-RTOS functions.

枚举值
osOK | Operation completed successfully.
osError | Unspecified RTOS error: run-time error but no other error message fits.
osErrorTimeout | Operation not completed within the timeout period.
osErrorResource | Resource not available.
osErrorParameter | Parameter error.
osErrorNoMemory | System is out of memory: it was impossible to allocate or reserve memory for the operation.
osErrorISR | Not allowed in ISR context: the function cannot be called from interrupt service routines.
osStatusReserved | Prevents enum down-size compiler optimization.

函数说明

◆ osKernelLock()

int32_t osKernelLock ( void )

Lock the RTOS Kernel scheduler.

返回
previous lock state (1 - locked, 0 - not locked, error code if negative).

◆ osKernelUnlock()

int32_t osKernelUnlock ( void )

Unlock the RTOS Kernel scheduler.

返回
previous lock state (1 - locked, 0 - not locked, error code if negative).

◆ osKernelGetTickFreq()

uint32_t osKernelGetTickFreq ( void )

Get the RTOS kernel tick frequency.

返回
frequency of the kernel tick in hertz, i.e. kernel ticks per second.

◆ osKernelGetTickCount()

uint32_t osKernelGetTickCount ( void )

Get the RTOS kernel tick count.

返回
RTOS kernel current tick count.

◆ osThreadNew()

osThreadId_t osThreadNew | ( | osThreadFunc_t | func,
 |  | void * | argument,
 |  | const osThreadAttr_t * | attr
 | ) |  |

Create a thread and add it to Active Threads.

参数
[in] | func | thread function.
[in] | argument | pointer that is passed to the thread function as start argument.
[in] | attr | thread attributes; NULL: default values.
返回
thread ID for reference by other functions or NULL in case of error.

◆ osThreadGetName()

const char* osThreadGetName ( osThreadId_t thread_id )

Get name of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
name as null-terminated string.

◆ osThreadGetId()

osThreadId_t osThreadGetId ( void )

Return the thread ID of the current running thread.

返回
thread ID for reference by other functions or NULL in case of error.

◆ osThreadGetState()

osThreadState_t osThreadGetState ( osThreadId_t thread_id )

Get current thread state of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
current thread state of the specified thread.

◆ osThreadGetStackSize()

uint32_t osThreadGetStackSize ( osThreadId_t thread_id )

Get stack size of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
stack size in bytes.

◆ osThreadGetStackSpace()

uint32_t osThreadGetStackSpace ( osThreadId_t thread_id )

Get available stack space of a thread based on stack watermark recording during execution.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
remaining stack space in bytes.

◆ osThreadSetPriority()

osStatus_t osThreadSetPriority | ( | osThreadId_t | thread_id,
 |  | osPriority_t | priority
 | ) |  |

Change priority of a thread.

参数
[in] | thread_id | thread ID obtained by osThreadNew or osThreadGetId.
[in] | priority | new priority value for the thread function.
返回
status code that indicates the execution status of the function.

◆ osThreadGetPriority()

osPriority_t osThreadGetPriority ( osThreadId_t thread_id )

Get current priority of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
current priority value of the specified thread.

◆ osThreadYield()

osStatus_t osThreadYield ( void )

Pass control to next thread that is in state READY.

返回
status code that indicates the execution status of the function.

◆ osThreadSuspend()

osStatus_t osThreadSuspend ( osThreadId_t thread_id )

Suspend execution of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
status code that indicates the execution status of the function.

◆ osThreadResume()

osStatus_t osThreadResume ( osThreadId_t thread_id )

Resume execution of a thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
status code that indicates the execution status of the function.

◆ osThreadTerminate()

osStatus_t osThreadTerminate ( osThreadId_t thread_id )

Terminate execution of a thread.

Terminate execution of current running thread.

参数
[in] thread_id thread ID obtained by osThreadNew or osThreadGetId.
返回
status code that indicates the execution status of the function.

◆ osThreadGetCount()

uint32_t osThreadGetCount ( void )

Get number of active threads.

返回
number of active threads.

◆ osDelay()

osStatus_t osDelay ( uint32_t ticks )

Wait for Timeout (Time Delay).

参数
[in] ticks time ticks value
返回
status code that indicates the execution status of the function.

◆ osTimerNew()

osTimerId_t osTimerNew | ( | osTimerFunc_t | func,
 |  | osTimerType_t | type,
 |  | void * | argument,
 |  | const osTimerAttr_t * | attr
 | ) |  |

Create and Initialize a timer.

参数
[in] | func | function pointer to callback function.
[in] | type | osTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
[in] | argument | argument to the timer callback function.
[in] | attr | timer attributes; NULL: default values.
返回
timer ID for reference by other functions or NULL in case of error.

◆ osTimerStart()

osStatus_t osTimerStart | ( | osTimerId_t | timer_id,
 |  | uint32_t | ticks
 | ) |  |

Get name of a timer.

参数
[in] timer_id timer ID obtained by osTimerNew.
返回
name as null-terminated string.

Start or restart a timer.

参数
[in] | timer_id | timer ID obtained by osTimerNew.
[in] | ticks | time ticks value of the timer.
返回
status code that indicates the execution status of the function.

◆ osTimerStop()

osStatus_t osTimerStop ( osTimerId_t timer_id )

Stop a timer.

参数
[in] timer_id timer ID obtained by osTimerNew.
返回
status code that indicates the execution status of the function.

◆ osTimerIsRunning()

uint32_t osTimerIsRunning ( osTimerId_t timer_id )

Check if a timer is running.

参数
[in] timer_id timer ID obtained by osTimerNew.
返回
= 0 - not running
= 1 - running

◆ osTimerDelete()

osStatus_t osTimerDelete ( osTimerId_t timer_id )

Delete a timer.

参数
[in] timer_id timer ID obtained by osTimerNew.
返回
status code that indicates the execution status of the function.

◆ osEventFlagsNew()

osEventFlagsId_t osEventFlagsNew ( const osEventFlagsAttr_t * attr )

Create and Initialize an Event Flags object.

参数
[in] attr event flags attributes; NULL: default values.
返回
event flags ID for reference by other functions or NULL in case of error.

◆ osEventFlagsSet()

uint32_t osEventFlagsSet | ( | osEventFlagsId_t | ef_id,
 |  | uint32_t | flags
 | ) |  |

Set the specified Event Flags.

参数
[in] | ef_id | event flags ID obtained by osEventFlagsNew.
[in] | flags | specifies the flags that shall be set.
返回
thread flags input or error code if highest bit set.

◆ osEventFlagsWait()

uint32_t osEventFlagsWait | ( | osEventFlagsId_t | ef_id,
 |  | uint32_t | flags,
 |  | uint32_t | options,
 |  | uint32_t | timeout
 | ) |  |

Clear the specified Event Flags.

参数
[in] | ef_id | event flags ID obtained by osEventFlagsNew.
[in] | flags | specifies the flags that shall be cleared.
返回
event flags before clearing or error code if highest bit set.

Get the current Event Flags.

参数
[in] ef_id event flags ID obtained by osEventFlagsNew.
返回
current event flags.

Wait for one or more Event Flags to become signaled.

参数
[in] | ef_id | event flags ID obtained by osEventFlagsNew.
[in] | flags | specifies the flags to wait for.
[in] | options | specifies flags options (osFlagsXxxx).
[in] timeout Timeout Value
or 0 in case of no time-out.
返回
event flags before clearing or error code if highest bit set.

◆ osEventFlagsDelete()

osStatus_t osEventFlagsDelete ( osEventFlagsId_t ef_id )

Delete an Event Flags object.

参数
[in] ef_id event flags ID obtained by osEventFlagsNew.
返回
status code that indicates the execution status of the function.

◆ osMutexNew()

osMutexId_t osMutexNew ( const osMutexAttr_t * attr )

Create and Initialize a Mutex object.

参数
[in] attr mutex attributes; NULL: default values.
返回
mutex ID for reference by other functions or NULL in case of error.

◆ osMutexAcquire()

osStatus_t osMutexAcquire | ( | osMutexId_t | mutex_id,
 |  | uint32_t | timeout
 | ) |  |

Acquire a Mutex or timeout if it is locked.

参数
[in] mutex_id mutex ID obtained by osMutexNew.
[in] timeout Timeout Value
or 0 in case of no time-out.
返回
status code that indicates the execution status of the function.

◆ osMutexRelease()

osStatus_t osMutexRelease ( osMutexId_t mutex_id )

Release a Mutex that was acquired by osMutexAcquire.

参数
[in] mutex_id mutex ID obtained by osMutexNew.
返回
status code that indicates the execution status of the function.

◆ osMutexDelete()

osStatus_t osMutexDelete ( osMutexId_t mutex_id )

Get Thread which owns a Mutex object.

参数
[in] mutex_id mutex ID obtained by osMutexNew.
返回
thread ID of owner thread or NULL when mutex was not acquired.

Delete a Mutex object.

参数
[in] mutex_id mutex ID obtained by osMutexNew.
返回
status code that indicates the execution status of the function.

◆ osSemaphoreNew()

osSemaphoreId_t osSemaphoreNew | ( | uint32_t | max_count,
 |  | uint32_t | initial_count,
 |  | const osSemaphoreAttr_t * | attr
 | ) |  |

Create and Initialize a Semaphore object.

参数
[in] | max_count | maximum number of available tokens.
[in] | initial_count | initial number of available tokens.
[in] | attr | semaphore attributes; NULL: default values.
返回
semaphore ID for reference by other functions or NULL in case of error.(only binary semaphore are supported)

◆ osSemaphoreAcquire()

osStatus_t osSemaphoreAcquire | ( | osSemaphoreId_t | semaphore_id,
 |  | uint32_t | timeout
 | ) |  |

Acquire a Semaphore token or timeout if no tokens are available.

参数
[in] semaphore_id semaphore ID obtained by osSemaphoreNew.
[in] timeout Timeout Value
or 0 in case of no time-out.
返回
status code that indicates the execution status of the function.

◆ osSemaphoreRelease()

osStatus_t osSemaphoreRelease ( osSemaphoreId_t semaphore_id )

Release a Semaphore token up to the initial maximum count.

参数
[in] semaphore_id semaphore ID obtained by osSemaphoreNew.
返回
status code that indicates the execution status of the function.

◆ osSemaphoreDelete()

osStatus_t osSemaphoreDelete ( osSemaphoreId_t semaphore_id )

Get current Semaphore token count.

参数
[in] semaphore_id semaphore ID obtained by osSemaphoreNew.
返回
number of tokens available.

Delete a Semaphore object.

参数
[in] semaphore_id semaphore ID obtained by osSemaphoreNew.
返回
status code that indicates the execution status of the function.

◆ osMessageQueueNew()

osMessageQueueId_t osMessageQueueNew | ( | uint32_t | msg_count,
 |  | uint32_t | msg_size,
 |  | const osMessageQueueAttr_t * | attr
 | ) |  |

Create and Initialize a Message Queue object.

参数
[in] | msg_count | maximum number of messages in queue.
[in] | msg_size | maximum message size in bytes.
[in] | attr | message queue attributes; NULL: default values.
返回
message queue ID for reference by other functions or NULL in case of error.

◆ osMessageQueuePut()

osStatus_t osMessageQueuePut | ( | osMessageQueueId_t | mq_id,
 |  | const void * | msg_ptr,
 |  | uint8_t | msg_prio,
 |  | uint32_t | timeout
 | ) |  |

Put a Message into a Queue or timeout if Queue is full.

参数
[in] | mq_id | message queue ID obtained by osMessageQueueNew.
[in] | msg_ptr | pointer to buffer with message to put into a queue.
[in] | msg_prio | message priority.
[in] timeout Timeout Value
or 0 in case of no time-out.
返回
status code that indicates the execution status of the function.

◆ osMessageQueueGet()

osStatus_t osMessageQueueGet | ( | osMessageQueueId_t | mq_id,
 |  | void * | msg_ptr,
 |  | uint8_t * | msg_prio,
 |  | uint32_t | timeout
 | ) |  |

Get a Message from a Queue or timeout if Queue is empty.

参数
[in] | mq_id | message queue ID obtained by osMessageQueueNew.
[out] | msg_ptr | pointer to buffer for message to get from a queue.
[out] | msg_prio | pointer to buffer for message priority or NULL.
[in] timeout Timeout Value
or 0 in case of no time-out.
返回
status code that indicates the execution status of the function.

◆ osMessageQueueDelete()

osStatus_t osMessageQueueDelete ( osMessageQueueId_t mq_id )

Get maximum number of messages in a Message Queue.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
maximum number of messages.

Get maximum message size in a Message Queue.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
maximum message size in bytes.

Get number of queued messages in a Message Queue.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
number of queued messages.

Get number of available slots for messages in a Message Queue.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
number of available slots for messages.

Reset a Message Queue to initial empty state.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
status code that indicates the execution status of the function.

Delete a Message Queue object.

参数
[in] mq_id message queue ID obtained by osMessageQueueNew.
返回
status code that indicates the execution status of the function.


ML305A_ML307A_OpenCPU_API: osVersion_t结构体 参考

成员变量
osVersion_t结构体 参考
os

#include <cm_os.h>

成员变量

uint32_t | api
uint32_t | kernel

详细描述

Version information.

结构体成员变量说明

◆ api

uint32_t api

API version (major.minor.rev: mmnnnrrrr dec).

◆ kernel

uint32_t kernel

Kernel version (major.minor.rev: mmnnnrrrr dec).

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osThreadAttr_t结构体 参考

成员变量
osThreadAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size
void * | stack_mem
uint32_t | stack_size
osPriority_t priority
TZ_ModuleId_t tz_module
uint32_t | reserved

详细描述

Attributes structure for thread.

结构体成员变量说明

◆ name

const char* name

name of the thread.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

◆ stack_mem

void* stack_mem

memory for stack.

◆ stack_size

uint32_t stack_size

size of stack.

◆ priority

osPriority_t priority

initial thread priority (default: osPriorityNormal).

◆ tz_module

TZ_ModuleId_t tz_module

TrustZone module identifier.

◆ reserved

uint32_t reserved

reserved (must be 0).

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osTimerAttr_t结构体 参考

成员变量
osTimerAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size

详细描述

Attributes structure for timer.

结构体成员变量说明

◆ name

const char* name

name of the timer.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osEventFlagsAttr_t结构体 参考

成员变量
osEventFlagsAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size

详细描述

Attributes structure for event flags.

结构体成员变量说明

◆ name

const char* name

name of the event flags.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osMutexAttr_t结构体 参考

成员变量
osMutexAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size

详细描述

Attributes structure for mutex.

结构体成员变量说明

◆ name

const char* name

name of the mutex.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osSemaphoreAttr_t结构体 参考

成员变量
osSemaphoreAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size

详细描述

Attributes structure for semaphore.

结构体成员变量说明

◆ name

const char* name

name of the semaphore.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osMemoryPoolAttr_t结构体 参考

成员变量
osMemoryPoolAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size
void * | mp_mem
uint32_t | mp_size

详细描述

Attributes structure for memory pool.

结构体成员变量说明

◆ name

const char* name

name of the memory pool.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

◆ mp_mem

void* mp_mem

memory for data storage.

◆ mp_size

uint32_t mp_size

size of provided memory for data storage.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: osMessageQueueAttr_t结构体 参考

成员变量
osMessageQueueAttr_t结构体 参考
os

#include <cm_os.h>

成员变量

const char * | name
uint32_t | attr_bits
void * | cb_mem
uint32_t | cb_size
void * | mq_mem
uint32_t | mq_size

详细描述

Attributes structure for message queue.

结构体成员变量说明

◆ name

const char* name

name of the message queue.

◆ attr_bits

uint32_t attr_bits

attribute bits.

◆ cb_mem

void* cb_mem

memory for control block.

◆ cb_size

uint32_t cb_size

size of provided memory for control block.

◆ mq_mem

void* mq_mem

memory for data storage.

◆ mq_size

uint32_t mq_size

size of provided memory for data storage.

该结构体的文档由以下文件生成:
  • cm_os.h


ML305A_ML307A_OpenCPU_API: pm

结构体 | 类型定义 | 枚举 | 函数
pm

结构体

struct cm_pm_cfg_t

类型定义

typedef void(* | cm_pm_event_cb_t) (void)
typedef void(* | cm_pm_powerkey_cb_t) (cm_powerkey_event_e event)

枚举

enum cm_powerkey_event_e { CM_POWERKEY_EVENT_RELEASE = 0 , CM_POWERKEY_EVENT_PRESS = 1 }
enum cm_pm_power_on_reason_e {
CM_PM_UNKNOWN = 0 , CM_PM_CHARG_POW_OFF , CM_PM_RD_PRO_MODE , CM_PM_RTC_ALARM ,
CM_PM_POWER_ON , CM_PM_ERROR_RESET
}

函数

void | cm_pm_poweroff (void)
关机 更多...
int | cm_pm_get_power_on_reason (void)
获取上电原因 更多...
void | cm_pm_reboot (void)
重启 更多...
void | cm_pm_init (cm_pm_cfg_t pm_cfg)
pm初始化 更多...
void | cm_pm_work_lock (void)
睡眠模式上锁 更多...
void | cm_pm_work_unlock (void)
睡眠模式解锁 更多...
int32_t | cm_pm_powerkey_regist_callback (cm_pm_powerkey_cb_t callback)
powerkey按键回调函数注册 更多...

详细描述

类型定义说明

◆ cm_pm_event_cb_t

typedef void(* cm_pm_event_cb_t) (void)

◆ cm_pm_powerkey_cb_t

typedef void(* cm_pm_powerkey_cb_t) (cm_powerkey_event_e event)

枚举类型说明

◆ cm_powerkey_event_e

enum cm_powerkey_event_e
枚举值
CM_POWERKEY_EVENT_RELEASE | 按键被释放
CM_POWERKEY_EVENT_PRESS | 按键被按下

◆ cm_pm_power_on_reason_e

enum cm_pm_power_on_reason_e

上电原因

枚举值
CM_PM_UNKNOWN | 未知原因
CM_PM_CHARG_POW_OFF | Charging in powering off,USB等充电方式供电时产生的重启
CM_PM_RD_PRO_MODE | Rd production mode,产线工具下发导致的重启
CM_PM_RTC_ALARM | rtc Alarm，定时闹钟开机
CM_PM_POWER_ON | Normal power on,正常重启
CM_PM_ERROR_RESET | Error reset (WDT),看门狗超时导致的重启

函数说明

◆ cm_pm_poweroff()

void cm_pm_poweroff ( void )

关机

返回
空

More details

◆ cm_pm_get_power_on_reason()

int cm_pm_get_power_on_reason ( void )

获取上电原因

返回
>= 0 - 上电原因
< 0 - 失败, 返回值为错误码

More details

◆ cm_pm_reboot()

void cm_pm_reboot ( void )

重启

参数
[in] void
返回
void

More details

◆ cm_pm_init()

void cm_pm_init ( cm_pm_cfg_t pm_cfg )

pm初始化

参数
[in] pm_cfg:参数配置
返回
void

More details

◆ cm_pm_work_lock()

void cm_pm_work_lock ( void )

睡眠模式上锁

返回
空

执行后，模组将无法进入休眠状态

◆ cm_pm_work_unlock()

void cm_pm_work_unlock ( void )

睡眠模式解锁

返回
空

执行后，模组将允许进入休眠状态

◆ cm_pm_powerkey_regist_callback()

int32_t cm_pm_powerkey_regist_callback ( cm_pm_powerkey_cb_t callback )

powerkey按键回调函数注册

参数
[in] callback回调函数指针
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

如果回调函数非空，无论长短按都将调用回调函数，且不会关机，仅做按键功能，如果为空，将长按为关机功能


ML305A_ML307A_OpenCPU_API: cm_pm_cfg_t结构体 参考

成员变量
cm_pm_cfg_t结构体 参考
pm

#include <cm_pm.h>

成员变量

cm_pm_event_cb_t cb_enter
cm_pm_event_cb_t cb_exit

详细描述

配置

结构体成员变量说明

◆ cb_enter

cm_pm_event_cb_t cb_enter

进入低功耗回调函数

◆ cb_exit

cm_pm_event_cb_t cb_exit

退出低功耗回调函数

该结构体的文档由以下文件生成:
  • cm_pm.h


ML305A_ML307A_OpenCPU_API: pwm

枚举 | 函数
pwm

枚举

enum cm_pwm_dev_e {
CM_PWM_DEV_0 , CM_PWM_DEV_1 , CM_PWM_DEV_2 , CM_PWM_DEV_3 ,
CM_PWM_DEV_NUM
}
enum cm_pwm_clk_e { CM_PWM_CLK_32K = 32000 , CM_PWM_CLK_12800K = 12800000 , CM_PWM_CLK_END }

函数

int32_t | cm_pwm_set_clk (cm_pwm_dev_e dev, cm_pwm_clk_e clk)
PWM 时钟源选择 更多...
int32_t | cm_pwm_open_ns (cm_pwm_dev_e dev, uint32_t period, uint32_t period_h)
打开PWM设备 更多...
int32_t | cm_pwm_close (cm_pwm_dev_e dev)
关闭PWM设备 更多...

详细描述

枚举类型说明

◆ cm_pwm_dev_e

enum cm_pwm_dev_e

设备ID，详情参照资源综述

枚举值
CM_PWM_DEV_0 | 设备0
CM_PWM_DEV_1 | 设备1
CM_PWM_DEV_2 | 设备2
CM_PWM_DEV_3 | 设备3
CM_PWM_DEV_NUM |

◆ cm_pwm_clk_e

enum cm_pwm_clk_e

时钟源枚举

枚举值
CM_PWM_CLK_32K | 32k时钟源，支持低功耗下使用
CM_PWM_CLK_12800K | 12.8M时钟源，不支持低功耗下使用
CM_PWM_CLK_END |

函数说明

◆ cm_pwm_set_clk()

int32_t cm_pwm_set_clk | ( | cm_pwm_dev_e | dev,
 |  | cm_pwm_clk_e | clk
 | ) |  |

PWM 时钟源选择

参数
[in] | dev | PWM设备ID
[in] | clk | 时钟源
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

clk可以选择32k的时钟，也可以选择12.8M的时钟，低功耗下仅支持32k的时钟；需要在open函数之前设置

◆ cm_pwm_open_ns()

int32_t cm_pwm_open_ns | ( | cm_pwm_dev_e | dev,
 |  | uint32_t | period,
 |  | uint32_t | period_h
 | ) |  |

打开PWM设备

参数
[in] | dev | PWM设备ID
[in] | period | 周期(ns),最大为5120000
[in] | period_h | 周期高电平占用时间(ns)
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

PWM由于分频和算法设计存在一定的误差，受限于软件和硬件，因此period和period_h需根据下面备注进行设置
How to get the PV(The value of after scaled clock cycles per cycle/T):
InputClockT=13M;PWM_T=period; InputClockT * ('PV(The value of before scaled clock cycles per cycle)) = PWM_T
'PV = PWM_T / InputClockT
= PWM_T * InputClockF
PV = 'PV /(prescale + 1) -1
How to get the prescale:
Because the internal clock period counter is 10-bit, to avoid overun. We can use the prescale.
prescale real value = ('PV - 1(if > 1024, then need prescale)) / 1024
How to get the Duty cycle:
Duty cycle = (PV(the cycles per T) + 1) * ratio(Duty time/PWM_T)

◆ cm_pwm_close()

int32_t cm_pwm_close ( cm_pwm_dev_e dev )

关闭PWM设备

参数
[in] dev PWM设备ID
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details


ML305A_ML307A_OpenCPU_API: QR

结构体 | 宏定义 | 类型定义 | 枚举 | 枚举值 | 函数 | 变量
QR

结构体

struct cm_qr_param_t

宏定义

#define CM_QR_DATA_LEN_MAX 512

类型定义

typedef int(* cm_qr_cb) (void *param, const char *data)

枚举

enum cm_qr_fmt_e { CM_QR_FMT_UYVY , CM_QR_FMT_Y800 , CM_QR_FMT_OTHER }
enum cm_qr_retult_e {
CM_QR_RET_SUCCESS , CM_QR_RET_NOT_INIT , CM_QR_RET_CREATE_FAILED , CM_QR_RET_MEMORY_ERR ,
CM_QR_RET_FMT_ERR , CM_QR_RET_CONVERT_ERR , CM_QR_RET_SCAN_ERR , CM_QR_RET_NO_DECODE_DATA
}

函数

int | cm_qr_convert_init (int width, int height)
解码缓存初始化. 更多...
void | cm_qr_convert_destroy (void)
解码缓存回收. 更多...
int32_t | cm_qr_scan (cm_qr_param_t *param, char *data, int *datalen)
二维码解码. 更多...

变量

void * | data
int | width
int | height
int | format
void * | usrdata
cm_qr_cb callback

详细描述

宏定义说明

◆ CM_QR_DATA_LEN_MAX

#define CM_QR_DATA_LEN_MAX 512

解析结果数据最大长度

类型定义说明

◆ cm_qr_cb

typedef int(* cm_qr_cb) (void *param, const char *data)
参数
[in] | param | 传入的用户参数
[in] | data | 二维码解析结果

枚举类型说明

◆ cm_qr_fmt_e

enum cm_qr_fmt_e
枚举值
CM_QR_FMT_UYVY | UYVY格式图像
CM_QR_FMT_Y800 | 灰阶图像
CM_QR_FMT_OTHER | 无效格式

◆ cm_qr_retult_e

enum cm_qr_retult_e
枚举值
CM_QR_RET_SUCCESS | 解码成功
CM_QR_RET_NOT_INIT | 未初始化
CM_QR_RET_CREATE_FAILED | 解码器创建失败
CM_QR_RET_MEMORY_ERR | RAM剩余最大块空间不够
CM_QR_RET_FMT_ERR | 传入的图像格式错误
CM_QR_RET_CONVERT_ERR | 图像灰阶转换错误
CM_QR_RET_SCAN_ERR | 灰阶图像扫描错误
CM_QR_RET_NO_DECODE_DATA | 解码后 无有效数据

函数说明

◆ cm_qr_convert_init()

int cm_qr_convert_init | ( | int | width,
 |  | int | height
 | ) |  |

解码缓存初始化.

参数
[in] | width | 图像宽度
[in] | height | 图像高度
返回
函数执行结果 非0为失败，0为成功

需在解码前调用

◆ cm_qr_convert_destroy()

void cm_qr_convert_destroy ( void )

解码缓存回收.

返回

为避免内存碎片，请尽量减少使用频率

◆ cm_qr_scan()

int32_t cm_qr_scan | ( | cm_qr_param_t * | param,
 |  | char * | data,
 |  | int * | datalen
 | ) |  |

二维码解码.

参数
[in] | param | 待解析图像的参数信息
[out] | data | 二维码解析结果
[out] | datalen | 解析结果数据的长度
返回
= 0 - 成功

0 - 失败, 返回值为错误码，详见cm_qr_retult_e

解码前需保证当前ram的最大块超过480*640字节作为临时调用空间 如果是在线程中调用解码接口，请至少预留4KB的栈空间。

变量说明

◆ data

void* data

图像数据

◆ width

int width

图像宽度

◆ height

int height

图像高度

◆ format

int format

图像原始格式，需转码为灰阶图像(Y800)

◆ usrdata

void* usrdata

扫描线程回调的参数

◆ callback

cm_qr_cb callback

扫描线程回调


ML305A_ML307A_OpenCPU_API: cm_qr_param_t结构体 参考

成员变量
cm_qr_param_t结构体 参考
QR

#include <cm_qr.h>

成员变量

void * | data
int | width
int | height
int | format
void * | usrdata
cm_qr_cb callback
该结构体的文档由以下文件生成:
  • cm_qr.h


ML305A_ML307A_OpenCPU_API: rtc

函数
rtc

函数

int32_t | cm_rtc_set_current_time (uint64_t second)
设置系统时间（秒） 更多...
uint64_t | cm_rtc_get_current_time (void)
获取系统时间（秒） 更多...
int32_t | cm_rtc_set_timezone (int32_t timezone)
设置时区 更多...
int32_t | cm_rtc_get_timezone (void)
获取时区 更多...

详细描述

函数说明

◆ cm_rtc_set_current_time()

int32_t cm_rtc_set_current_time ( uint64_t second )

设置系统时间（秒）

参数
[in] second 时间戳(单位：秒)
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

UTC时间

◆ cm_rtc_get_current_time()

uint64_t cm_rtc_get_current_time ( void )

获取系统时间（秒）

返回
时间戳（单位：秒）

UTC时间

◆ cm_rtc_set_timezone()

int32_t cm_rtc_set_timezone ( int32_t timezone )

设置时区

参数
[in] timezone 时区
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

timezone设置范围为-12~12，-12为西十二区，0为世界时间，12为东十二区

◆ cm_rtc_get_timezone()

int32_t cm_rtc_get_timezone ( void )

获取时区

返回
时区

timezone范围为-12~12，-12为西十二区，0为世界时间，12为东十二区


ML305A_ML307A_OpenCPU_API: SDCARD

结构体 | 宏定义 | 函数
SDCARD

结构体

struct cm_sd_system_info_t

宏定义

#define | CM_SD_SEEK_SET (0)
#define | CM_SD_SEEK_CUR (1)
#define | CM_SD_SEEK_END (2)
#define | CM_SD_MAX_PATH (256)

函数

int32_t | cm_sd_get_flag (void)
获取SD标志位 更多...
int32_t | cm_sd_set_flag (int32_t flag)
设置SD标志位 更多...
bool | cm_sd_is_formatted (char *vol)
查询（SD卡）文件系统是否格式化 更多...
int32_t | cm_sd_format (char *vol)
格式化（SD卡）文件系统 更多...
int32_t | cm_sd_fopen (const char *filename, const char *mode)
打开一个文件 更多...
int32_t | cm_sd_fclose (int32_t fd)
关闭一个文件 更多...
int32_t | cm_sd_fread (int32_t fd, void *buf, uint32_t size)
读取文件内容 更多...
int32_t | cm_sd_fwrite (int32_t fd, const void *buf, uint32_t size)
写入文件内容 更多...
int32_t | cm_sd_fseek (int32_t fd, int32_t offset, int32_t base)
文件指针定位 更多...
int32_t | cm_sd_fdelete (const char *file_name)
删除文件 更多...
int32_t | cm_sd_fmove (const char *src, const char *dest)
更改文件名 更多...
int32_t | cm_sd_exist (const char *file_name)
检查文件是否存在 更多...
int32_t | cm_sd_filesize (const char *file_name)
获取文件大小 更多...
int32_t | cm_sd_mkdir (char *path)
创建文件夹 更多...
int32_t | cm_sd_rmdir (char *path)
删除文件夹 更多...
int32_t | cm_sd_set_currentdir (char *path)
设置当前文件夹路径 更多...
int32_t | cm_sd_get_currentdir (char *path, uint32_t max_len)
获取当前文件夹路径 更多...
int32_t | cm_sd_getinfo (char *vol, cm_sd_system_info_t *info)
获取文件系统信息 更多...

详细描述

宏定义说明

◆ CM_SD_SEEK_SET

#define CM_SD_SEEK_SET (0)

SEEK_SET

◆ CM_SD_SEEK_CUR

#define CM_SD_SEEK_CUR (1)

SEEK_CUR

◆ CM_SD_SEEK_END

#define CM_SD_SEEK_END (2)

SEEK_END

◆ CM_SD_MAX_PATH

#define CM_SD_MAX_PATH (256)

函数说明

◆ cm_sd_get_flag()

int32_t cm_sd_get_flag ( void )

获取SD标志位

返回
SD标志位 0:用户禁止使用SD功能 1:允许使用SD功能

默认允许使用SD功能

◆ cm_sd_set_flag()

int32_t cm_sd_set_flag ( int32_t flag )

设置SD标志位

参数
[in] flag 标志 0：禁止使用SD功能；1：允许使用SD功能
返回
= 0 - 成功
= -1 - 失败

设置成功后重启生效（未重启前仍为设置前的值）

◆ cm_sd_is_formatted()

bool cm_sd_is_formatted ( char * vol )

查询（SD卡）文件系统是否格式化

参数
[in] vol 逻辑驱动器号指针
返回
TRUE - SD卡已格式化
FALSE - SD卡未格式化

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_format()

int32_t cm_sd_format ( char * vol )

格式化（SD卡）文件系统

参数
[in] vol 逻辑驱动器号指针
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能
因软件驱动特性，cm_sd_format()接口应在执行SD文件操作前调用。若需要获取SD文件系统的关键数据后格式化SD卡，应在进行完SD文件系统操作并重启模组后格式化SD卡。

◆ cm_sd_fopen()

int32_t cm_sd_fopen | ( | const char * | filename,
 |  | const char * | mode
 | ) |  |

打开一个文件

参数
[in] | filename | 文件名称
[in] | mode | 参数（r w c a +）
返回
>= 0 - 文件描述符
< 0 - 失败, 返回值为错误码

r: read
w: write
c: create
a: append and write
+: read and write
SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fclose()

int32_t cm_sd_fclose ( int32_t fd )

关闭一个文件

参数
[in] fd 文件描述符
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fread()

int32_t cm_sd_fread | ( | int32_t | fd,
 |  | void * | buf,
 |  | uint32_t | size
 | ) |  |

读取文件内容

参数
[in] | fd | 文件描述符
[out] | buf | 存储数据的缓冲区指针
[in] | size | 要读取的数据长度
返回
>= 0 - 实际的读取长度
< 0 - 读取失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fwrite()

int32_t cm_sd_fwrite | ( | int32_t | fd,
 |  | const void * | buf,
 |  | uint32_t | size
 | ) |  |

写入文件内容

参数
[in] | fd | 文件描述符
[in] | buf | 存储数据的缓冲区指针
[in] | size | 要写入的数据长度
返回
>= 0 - 实际的写入长度
< 0 - 写入失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fseek()

int32_t cm_sd_fseek | ( | int32_t | fd,
 |  | int32_t | offset,
 |  | int32_t | base
 | ) |  |

文件指针定位

参数
[in] | fd | 文件描述符
[in] | offset | 指针偏移量
[in] | base | 偏移起始点，CM_SD_SEEK_SET：文件开头 CM_SD_SEEK_CUR：当前位置 CM_SD_SEEK_END：文件末尾
返回
= 0 - 成功
< 0 - 失败

offset不支持为负数
SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fdelete()

int32_t cm_sd_fdelete ( const char * file_name )

删除文件

参数
[in] file_name 文件路径
返回
>= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_fmove()

int32_t cm_sd_fmove | ( | const char * | src,
 |  | const char * | dest
 | ) |  |

更改文件名

参数
[in] | src | 原文件名
[in] | dest | 新文件名
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_exist()

int32_t cm_sd_exist ( const char * file_name )

检查文件是否存在

参数
[in] file_name 文件名称
返回
= 1 - 存在
= 0 - 不存在

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_filesize()

int32_t cm_sd_filesize ( const char * file_name )

获取文件大小

参数
[in] file_name 文件路径
返回
>= 0 - 文件长度
< 0 - 操作失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_mkdir()

int32_t cm_sd_mkdir ( char * path )

创建文件夹

参数
[in] path 文件夹路径
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_rmdir()

int32_t cm_sd_rmdir ( char * path )

删除文件夹

参数
[in] path 文件夹路径
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_set_currentdir()

int32_t cm_sd_set_currentdir ( char * path )

设置当前文件夹路径

参数
[in] path 文件夹路径
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_get_currentdir()

int32_t cm_sd_get_currentdir | ( | char * | path,
 |  | uint32_t | max_len
 | ) |  |

获取当前文件夹路径

参数
[out] | path | 用于保存文件夹路径的buffer
[in] | max_len | 用于保存文件夹路径的buffer的长度
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。

◆ cm_sd_getinfo()

int32_t cm_sd_getinfo | ( | char * | vol,
 |  | cm_sd_system_info_t * | info
 | ) |  |

获取文件系统信息

参数
[in] | vol | 逻辑驱动器号指针
[out] | info | 文件系统信息
返回
= 0 - 成功
< 0 - 失败

SD卡功能与ML307A uart0和ML302A uart1互斥，不可同时使用
仅ML307A-DSLN/ML307A-GSLN/ML302A-DSLM/ML302A-GSLM模组支持SD功能。


ML305A_ML307A_OpenCPU_API: cm_sd_system_info_t结构体 参考

成员变量
cm_sd_system_info_t结构体 参考
SDCARD

#include <cm_sd.h>

成员变量

long long | free_size
long long | total_size

结构体成员变量说明

◆ free_size

long long free_size

当前可用文件系统大小

◆ total_size

long long total_size

文件系统总大小

该结构体的文档由以下文件生成:
  • cm_sd.h


ML305A_ML307A_OpenCPU_API: sim

宏定义 | 函数
sim

宏定义

#define CM_IMSI_LEN 16

函数

int32_t | cm_sim_get_imsi (char *imsi)
获取设备IMSI 更多...
int32_t | cm_sim_get_iccid (char *iccid)
获取设备ICCID 更多...

详细描述

宏定义说明

◆ CM_IMSI_LEN

#define CM_IMSI_LEN 16

IMSI存储长度

函数说明

◆ cm_sim_get_imsi()

int32_t cm_sim_get_imsi ( char * imsi )

获取设备IMSI

参数
[out] imsi 存储IMSI，长度16字节，申请内存后传入
返回

= 0 - 成功
< 0 - 失败, 返回值为错误码.

More details

◆ cm_sim_get_iccid()

int32_t cm_sim_get_iccid ( char * iccid )

获取设备ICCID

参数
[out] iccid 存储ICCID，长度21字节，申请内存后传入
返回

= 0 - 成功
< 0 - 失败, 返回值为错误码.

More details


ML305A_ML307A_OpenCPU_API: spi

结构体 | 宏定义 | 枚举 | 函数
spi

结构体

struct cm_spi_cfg_t

宏定义

#define | CM_SPI_CLK_812_5KHZ (812500U)
#define | CM_SPI_CLK_1_625MHZ (1625000U)
#define | CM_SPI_CLK_3_25MHZ (3250000U)
#define | CM_SPI_CLK_6_5MHZ (6500000U)
#define | CM_SPI_CLK_13MHZ (13000000U)
#define | CM_SPI_CLK_26MHZ (26000000U)
#define | CM_SPI_CLK_52MHZ (52000000U)

枚举

enum | cm_spi_dev_e { CM_SPI_DEV_0 , CM_SPI_DEV_1 , CM_SPI_DEV_NUM }
enum | cm_spi_mode_e { CM_SPI_MODE_SLAVE , CM_SPI_MODE_MASTER }
enum | cm_spi_work_mode_e { CM_SPI_WOKR_MODE_0 , CM_SPI_WOKR_MODE_1 , CM_SPI_WOKR_MODE_2 , CM_SPI_WOKR_MODE_3 }
enum | cm_spi_data_width_e { CM_SPI_DATA_WIDTH_8BIT , CM_SPI_DATA_WIDTH_16BIT , CM_SPI_DATA_WIDTH_32BIT }
enum | cm_spi_nss_e { CM_SPI_NSS_SOFT , CM_SPI_NSS_HARD }

函数

int32_t | cm_spi_open (cm_spi_dev_e dev, cm_spi_cfg_t *cfg)
spi开启指定通道 更多...
int32_t | cm_spi_close (cm_spi_dev_e dev)
spi关闭，去初始化 更多...
int32_t | cm_spi_write (cm_spi_dev_e dev, const void *data, uint32_t len)
spi写数据 更多...
int32_t | cm_spi_read (cm_spi_dev_e dev, void *data, int32_t len)
SPI读数据 更多...
int32_t | cm_spi_write_then_read (cm_spi_dev_e dev, const void *w_data, uint32_t w_len, void *r_data, uint32_t r_len)
SPI写数据后读出数据 更多...

详细描述

宏定义说明

◆ CM_SPI_CLK_812_5KHZ

#define CM_SPI_CLK_812_5KHZ (812500U)

时钟频率

◆ CM_SPI_CLK_1_625MHZ

#define CM_SPI_CLK_1_625MHZ (1625000U)

◆ CM_SPI_CLK_3_25MHZ

#define CM_SPI_CLK_3_25MHZ (3250000U)

◆ CM_SPI_CLK_6_5MHZ

#define CM_SPI_CLK_6_5MHZ (6500000U)

◆ CM_SPI_CLK_13MHZ

#define CM_SPI_CLK_13MHZ (13000000U)

◆ CM_SPI_CLK_26MHZ

#define CM_SPI_CLK_26MHZ (26000000U)

◆ CM_SPI_CLK_52MHZ

#define CM_SPI_CLK_52MHZ (52000000U)

枚举类型说明

◆ cm_spi_dev_e

enum cm_spi_dev_e

设备ID

枚举值
CM_SPI_DEV_0 | 设备1
CM_SPI_DEV_1 | 设备2
CM_SPI_DEV_NUM |

◆ cm_spi_mode_e

enum cm_spi_mode_e

SPI主从模式

枚举值
CM_SPI_MODE_SLAVE | SPI外设从机模式，暂不支持
CM_SPI_MODE_MASTER | SPI外设主机模式

◆ cm_spi_work_mode_e

enum cm_spi_work_mode_e

模式

枚举值
CM_SPI_WOKR_MODE_0 | CPOL = 0,CPHA = 0
CM_SPI_WOKR_MODE_1 | CPOL = 0,CPHA = 1
CM_SPI_WOKR_MODE_2 | CPOL = 1,CPHA = 0，暂不支持
CM_SPI_WOKR_MODE_3 | CPOL = 1,CPHA = 1，暂不支持

◆ cm_spi_data_width_e

enum cm_spi_data_width_e

SPI传输数据宽度

枚举值
CM_SPI_DATA_WIDTH_8BIT | SPI外设传输数据宽度8位
CM_SPI_DATA_WIDTH_16BIT | SPI外设传输数据宽度16位，暂不支持
CM_SPI_DATA_WIDTH_32BIT | SPI外设传输数据宽度32位，暂不支持

◆ cm_spi_nss_e

enum cm_spi_nss_e

SPI的NSS管理模式

枚举值
CM_SPI_NSS_SOFT | SPI外设软件控制NSS，暂不支持
CM_SPI_NSS_HARD | SPI外设硬件控制NSS

函数说明

◆ cm_spi_open()

int32_t cm_spi_open | ( | cm_spi_dev_e | dev,
 |  | cm_spi_cfg_t * | cfg
 | ) |  |

spi开启指定通道

参数
[in] | dev | spi设备
[in] | config | spi配置
返回

= 0 - 成功.
< 0 - 失败, 返回值为错误码.

特别注意：1、ML305A系列暂不支持多路SPI同时使用； 2、暂不支持SPI模式2和模式3.

◆ cm_spi_close()

int32_t cm_spi_close ( cm_spi_dev_e dev )

spi关闭，去初始化

参数
[in] dev spi设备
返回

= 0 - 成功.
< 0 - 失败, 返回值为错误码.

More details

◆ cm_spi_write()

int32_t cm_spi_write | ( | cm_spi_dev_e | dev,
 |  | const void * | data,
 |  | uint32_t | len
 | ) |  |

spi写数据

参数
[in] | dev | spi设备
[in] | data | 待写数据
[in] | len | 待写数据长度
返回

= 实际写入长度 - 成功
< 0 - 失败, 返回值为错误码.

More details

◆ cm_spi_read()

int32_t cm_spi_read | ( | cm_spi_dev_e | dev,
 |  | void * | data,
 |  | int32_t | len
 | ) |  |

SPI读数据

参数
[in] | dev | SPI设备ID
[out] | data | 待读数据缓存
[in] | len | 长度
返回
= 实际读出长度 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_spi_write_then_read()

int32_t cm_spi_write_then_read | ( | cm_spi_dev_e | dev,
 |  | const void * | w_data,
 |  | uint32_t | w_len,
 |  | void * | r_data,
 |  | uint32_t | r_len
 | ) |  |

SPI写数据后读出数据

参数
[in] | dev | SPI设备ID
[in] | w_data | 待写数据
[in] | w_len | 写入长度
[out] | r_data | 待读缓存
[in] | r_len | 读取长度
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details


ML305A_ML307A_OpenCPU_API: cm_spi_cfg_t结构体 参考

成员变量
cm_spi_cfg_t结构体 参考
spi

#include <cm_spi.h>

成员变量

cm_spi_mode_e mode
cm_spi_work_mode_e work_mode
cm_spi_data_width_e data_width
cm_spi_nss_e nss
int clk

详细描述

配置

结构体成员变量说明

◆ mode

cm_spi_mode_e mode

SPI主从模式

◆ work_mode

cm_spi_work_mode_e work_mode

模式

◆ data_width

cm_spi_data_width_e data_width

SPI传输数据宽度

◆ nss

cm_spi_nss_e nss

SPI的NSS管理模式

◆ clk

int clk

时钟频率

该结构体的文档由以下文件生成:
  • cm_spi.h


ML305A_ML307A_OpenCPU_API: SSL

类型定义 | 枚举 | 函数
SSL

类型定义

typedef struct cm_ssl_ctx cm_ssl_ctx_t

枚举

enum cm_ssl_param_type_e {
CM_SSL_PARAM_VERIFY , CM_SSL_PARAM_NEGOTIME , CM_SSL_PARAM_CA_CERT , CM_SSL_PARAM_CLI_CERT ,
CM_SSL_PARAM_CLI_KEY , CM_SSL_PARAM_CA_CERT_DELETE , CM_SSL_PARAM_CLI_CERT_DELETE , CM_SSL_PARAM_CLI_KEY_DELETE
}

函数

int32_t | cm_ssl_setopt (int32_t ssl_id, cm_ssl_param_type_e type, void *value)
配置SSL参数 更多...
int | cm_ssl_conn (void **cm_ssl_ctx_p, int ssl_id, int socket, int timeout)
SSL连接 更多...
void | cm_ssl_close (void **cm_ssl_ctx_p)
SSL关闭 更多...
int | cm_ssl_write (cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len)
SSL写 更多...
int | cm_ssl_read (cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len)
SSL读 更多...
int | cm_ssl_check_pending (cm_ssl_ctx_t *cm_ssl_ctx)
缓存区是否有未读数据 更多...
int | cm_ssl_get_bytes_avail (cm_ssl_ctx_t *cm_ssl_ctx)
缓存区可读数据长度 更多...

详细描述

类型定义说明

◆ cm_ssl_ctx_t

typedef struct cm_ssl_ctx cm_ssl_ctx_t

枚举类型说明

◆ cm_ssl_param_type_e

enum cm_ssl_param_type_e

SSL配置类型

枚举值
CM_SSL_PARAM_VERIFY | 设置验证方式, 参数(value): 类型uint8_t, 值为验证方式类型，0无身份验证，1单向验证， 2双向验证.
CM_SSL_PARAM_NEGOTIME | 设置握手超时时间, 参数(value): 类型uint16_t, 值为超时时间 单位：s
CM_SSL_PARAM_CA_CERT | 设置CA证书, 参数(value): 类型char*, 值为CA证书字符串指针.
CM_SSL_PARAM_CLI_CERT | 设置客户端证书, 参数(value): 类型char*, 值为客户端证书字符串指针.
CM_SSL_PARAM_CLI_KEY | 设置客户端密钥, 参数(value): 类型char*, 值为客户端密钥.
CM_SSL_PARAM_CA_CERT_DELETE | 删除CA证书, 参数(value): 无意义.
CM_SSL_PARAM_CLI_CERT_DELETE | 删除客户端证书, 参数(value): 无意义.
CM_SSL_PARAM_CLI_KEY_DELETE | 删除客户端密钥, 参数(value): 无意义.

函数说明

◆ cm_ssl_setopt()

int32_t cm_ssl_setopt | ( | int32_t | ssl_id,
 |  | cm_ssl_param_type_e | type,
 |  | void * | value
 | ) |  |

配置SSL参数

参数
[in] | ssl_id | ssl通道号，范围为0-5
[in] | type | SSL配置项类型
[in] | value | SSL配置项参数
返回
= 0 - 成功
= -1 - 参数错误

设置SSL配置参数，本接口配置证书时会将证书写入文件系统，故使用时需确保文件系统有足够空间

◆ cm_ssl_conn()

int cm_ssl_conn | ( | void ** | cm_ssl_ctx_p,
 |  | int | ssl_id,
 |  | int | socket,
 |  | int | timeout
 | ) |  |

SSL连接

参数
[out] | cm_ssl_ctx_p | ssl上下文
[in] | ssl_id | ssl通道号，范围为0-5
[in] | socket | socket描述符
[in] | timeout | 读取超时时间，单位ms
返回
= 0 - 成功
!= 0 - 失败

◆ cm_ssl_close()

void cm_ssl_close ( void ** cm_ssl_ctx_p )

SSL关闭

参数
[in] cm_ssl_ctx_p ssl上下文

◆ cm_ssl_write()

int cm_ssl_write | ( | cm_ssl_ctx_t * | cm_ssl_ctx,
 |  | void * | data,
 |  | int | data_len
 | ) |  |

SSL写

参数
[in] | cm_ssl_ctx | ssl上下文
[in] | data | 待写数据
[in] | data_len | 数据长度
返回
>= 0 - 发送长度
< 0 - 错误码

◆ cm_ssl_read()

int cm_ssl_read | ( | cm_ssl_ctx_t * | cm_ssl_ctx,
 |  | void * | data,
 |  | int | data_len
 | ) |  |

SSL读

参数
[in] | cm_ssl_ctx | ssl上下文
[in] | data | 读数据缓存区
[in] | data_len | 缓存区长度
返回
>= 0 - 读取长度
< 0 - 错误码

◆ cm_ssl_check_pending()

int cm_ssl_check_pending ( cm_ssl_ctx_t * cm_ssl_ctx )

缓存区是否有未读数据

参数
[in] cm_ssl_ctx ssl上下文
返回
= 0 - 缓存中无未读数据
= 1 - 缓存中有数据未读

◆ cm_ssl_get_bytes_avail()

int cm_ssl_get_bytes_avail ( cm_ssl_ctx_t * cm_ssl_ctx )

缓存区可读数据长度

参数
[in] cm_ssl_ctx ssl上下文
返回
缓存区可读数据长度

使用本函数获取可读数据长度之前，需要先用cm_ssl_read()进行一次空读取，具体参考使用示例;


ML305A_ML307A_OpenCPU_API: sys

宏定义 | 函数
sys

宏定义

#define | CM_IMEI_LEN 16
#define | CM_SN_LEN 65
#define | CM_VER_LEN 65

函数

int32_t | cm_sys_get_imei (char *imei)
获取模组IMEI 更多...
int32_t | cm_sys_get_sn (char *sn)
获取模组SN 更多...
int32_t | cm_sys_get_cm_ver (char *ver_buff, uint32_t len)
获取SDK版本号 更多...
void | cm_log_printf (uint8_t log_level, const char *fmt,...)
打印log信息 更多...

详细描述

宏定义说明

◆ CM_IMEI_LEN

#define CM_IMEI_LEN 16

IMEI存储长度

◆ CM_SN_LEN

#define CM_SN_LEN 65

SN存储长度

◆ CM_VER_LEN

#define CM_VER_LEN 65

版本号存储长度

函数说明

◆ cm_sys_get_imei()

int32_t cm_sys_get_imei ( char * imei )

获取模组IMEI

参数
[out] imei IMEI，长度16字节
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_sys_get_sn()

int32_t cm_sys_get_sn ( char * sn )

获取模组SN

参数
[out] sn SN，长度32字节
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

More details

◆ cm_sys_get_cm_ver()

int32_t cm_sys_get_cm_ver | ( | char * | ver_buff,
 |  | uint32_t | len
 | ) |  |

获取SDK版本号

参数
[in] | ver_buff | 存储版本号的内存指针
[in] | len | 传入的内存长度，单位字节
返回
>= 0 - 获取到的版本号长度，单位字节
< 0 - 失败, 返回值为错误码

◆ cm_log_printf()

void cm_log_printf | ( | uint8_t | log_level,
 |  | const char * | fmt,
 |  |  | ...
 | ) |  |

打印log信息

参数
[in] | log_level | log等级,暂不支持，传入任意值即可
[in] | fmt | 格式化字符串
[in] ... 格式化字符串参数
返回
空

本接口内部会申请一段180字节长度的buff用于组包log（不可传入超过180字节的数据。超过180字节时，接口会检查到数据错误，不会执行log打印）
log通过DEBUG串口（DBG_RX DBG_TX）输出。本平台的DEBUG口为串口，频繁使用串口打印可能会影响系统功能
因为底层默认配置，此接口最多支持打印128字节（含OpenCPU标识“[ cmlog ][OPENCPU]:”）的log，故用户只能用此接口打印不超过108字节的log


ML305A_ML307A_OpenCPU_API: uart

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
uart

结构体

struct | cm_uart_cfg_t
struct | cm_uart_event_t

宏定义

#define | CM_UART_BAUDRATE_300 (300U)
#define | CM_UART_BAUDRATE_600 (600U)
#define | CM_UART_BAUDRATE_1200 (1200U)
#define | CM_UART_BAUDRATE_2400 (2400U)
#define | CM_UART_BAUDRATE_4800 (4800U)
#define | CM_UART_BAUDRATE_9600 (9600U)
#define | CM_UART_BAUDRATE_14400 (14400U)
#define | CM_UART_BAUDRATE_19200 (19200U)
#define | CM_UART_BAUDRATE_28800 (28800U)
#define | CM_UART_BAUDRATE_38400 (38400U)
#define | CM_UART_BAUDRATE_57600 (57600U)
#define | CM_UART_BAUDRATE_76800 (76800U)
#define | CM_UART_BAUDRATE_115200 (115200U)
#define | CM_UART_BAUDRATE_230400 (230400U)
#define | CM_UART_BAUDRATE_460800 (460800U)
#define | CM_UART_BAUDRATE_921600 (921600U)
#define | CM_UART_BAUDRATE_256000 (256000U)
#define | CM_UART_BAUDRATE_2000000 (2000000U)

类型定义

typedef void(* cm_uart_event_cb_t) (void *param, uint32_t evt)

枚举

enum | cm_uart_dev_e { CM_UART_DEV_0 , CM_UART_DEV_1 , CM_UART_DEV_2 , CM_UART_DEV_NUM }
enum | cm_uart_byte_size_e { CM_UART_BYTE_SIZE_8 = 8 , CM_UART_BYTE_SIZE_7 = 7 , CM_UART_BYTE_SIZE_6 = 6 , CM_UART_BYTE_SIZE_5 = 5 }
enum cm_uart_parity_e {
CM_UART_PARITY_NONE , CM_UART_PARITY_ODD , CM_UART_PARITY_EVEN , CM_UART_PARITY_MARK ,
CM_UART_PARITY_SPACE
}
enum | cm_uart_stop_bit_e { CM_UART_STOP_BIT_ONE , CM_UART_STOP_BIT_ONE_HALF , CM_UART_STOP_BIT_TWO }
enum | cm_uart_flow_ctrl_e { CM_UART_FLOW_CTRL_NONE , CM_UART_FLOW_CTRL_HW }
enum | cm_uart_ret_e { CM_UART_RET_OK = 0 , CM_UART_RET_INVALID_PARAM = -1 }
enum | cm_uart_event_type_e { CM_UART_EVENT_TYPE_RX_ARRIVED = (1 << 0) , CM_UART_EVENT_TYPE_RX_OVERFLOW = (1 << 1) , CM_UART_EVENT_TYPE_TX_COMPLETE = (1 << 2) }

函数

int32_t | cm_uart_open (cm_uart_dev_e dev, cm_uart_cfg_t *cfg)
打开串口 更多...
int32_t | cm_uart_register_event (cm_uart_dev_e dev, void *event)
注册串口事件 更多...
int32_t | cm_uart_close (cm_uart_dev_e dev)
关闭串口 更多...
int32_t | cm_uart_write (cm_uart_dev_e dev, const void *data, int32_t len, int32_t timeout)
串口写数据 更多...
int32_t | cm_uart_read (cm_uart_dev_e dev, void *data, int32_t len, int32_t timeout)
串口读数据 更多...

详细描述

宏定义说明

◆ CM_UART_BAUDRATE_300

#define CM_UART_BAUDRATE_300 (300U)

标准波特率

◆ CM_UART_BAUDRATE_600

#define CM_UART_BAUDRATE_600 (600U)

◆ CM_UART_BAUDRATE_1200

#define CM_UART_BAUDRATE_1200 (1200U)

◆ CM_UART_BAUDRATE_2400

#define CM_UART_BAUDRATE_2400 (2400U)

◆ CM_UART_BAUDRATE_4800

#define CM_UART_BAUDRATE_4800 (4800U)

◆ CM_UART_BAUDRATE_9600

#define CM_UART_BAUDRATE_9600 (9600U)

◆ CM_UART_BAUDRATE_14400

#define CM_UART_BAUDRATE_14400 (14400U)

◆ CM_UART_BAUDRATE_19200

#define CM_UART_BAUDRATE_19200 (19200U)

◆ CM_UART_BAUDRATE_28800

#define CM_UART_BAUDRATE_28800 (28800U)

◆ CM_UART_BAUDRATE_38400

#define CM_UART_BAUDRATE_38400 (38400U)

◆ CM_UART_BAUDRATE_57600

#define CM_UART_BAUDRATE_57600 (57600U)

◆ CM_UART_BAUDRATE_76800

#define CM_UART_BAUDRATE_76800 (76800U)

◆ CM_UART_BAUDRATE_115200

#define CM_UART_BAUDRATE_115200 (115200U)

◆ CM_UART_BAUDRATE_230400

#define CM_UART_BAUDRATE_230400 (230400U)

◆ CM_UART_BAUDRATE_460800

#define CM_UART_BAUDRATE_460800 (460800U)

◆ CM_UART_BAUDRATE_921600

#define CM_UART_BAUDRATE_921600 (921600U)

◆ CM_UART_BAUDRATE_256000

#define CM_UART_BAUDRATE_256000 (256000U)

特殊波特率

◆ CM_UART_BAUDRATE_2000000

#define CM_UART_BAUDRATE_2000000 (2000000U)

类型定义说明

◆ cm_uart_event_cb_t

typedef void(* cm_uart_event_cb_t) (void *param, uint32_t evt)

枚举类型说明

◆ cm_uart_dev_e

enum cm_uart_dev_e

设备ID ，详情参照资源综述

枚举值
CM_UART_DEV_0 | 设备0
CM_UART_DEV_1 | 设备1
CM_UART_DEV_2 | 设备2
CM_UART_DEV_NUM |

◆ cm_uart_byte_size_e

enum cm_uart_byte_size_e

数据位

枚举值
CM_UART_BYTE_SIZE_8
CM_UART_BYTE_SIZE_7
CM_UART_BYTE_SIZE_6
CM_UART_BYTE_SIZE_5

◆ cm_uart_parity_e

enum cm_uart_parity_e

奇偶校验

枚举值
CM_UART_PARITY_NONE |
CM_UART_PARITY_ODD |
CM_UART_PARITY_EVEN |
CM_UART_PARITY_MARK | 不支持
CM_UART_PARITY_SPACE | 不支持

◆ cm_uart_stop_bit_e

enum cm_uart_stop_bit_e

停止位

枚举值
CM_UART_STOP_BIT_ONE
CM_UART_STOP_BIT_ONE_HALF
CM_UART_STOP_BIT_TWO

◆ cm_uart_flow_ctrl_e

enum cm_uart_flow_ctrl_e

流控制

枚举值
CM_UART_FLOW_CTRL_NONE |
CM_UART_FLOW_CTRL_HW | 当前不支持流控

◆ cm_uart_ret_e

enum cm_uart_ret_e

结果码

枚举值
CM_UART_RET_OK
CM_UART_RET_INVALID_PARAM

◆ cm_uart_event_type_e

enum cm_uart_event_type_e

事件类型

枚举值
CM_UART_EVENT_TYPE_RX_ARRIVED | 接收到新的数据
CM_UART_EVENT_TYPE_RX_OVERFLOW | 接收FIFO缓存溢出
CM_UART_EVENT_TYPE_TX_COMPLETE | 不支持发送完成事件

函数说明

◆ cm_uart_open()

int32_t cm_uart_open | ( | cm_uart_dev_e | dev,
 |  | cm_uart_cfg_t * | cfg
 | ) |  |

打开串口

参数
[in] | dev | 串口设备ID
[in] | cfg | 串口配置
返回

= 0 - 成功
< 0 - 失败, 返回值为错误码

open之前必须先对引脚复用功能进行设置。
串口支持的波特率及模式见cm_uart_cfg_t结构体注释说明，请详细查看波特率宏定义处的注意事项

◆ cm_uart_register_event()

int32_t cm_uart_register_event | ( | cm_uart_dev_e | dev,
 |  | void * | event
 | ) |  |

注册串口事件

参数
[in] | dev | 串口设备ID
[in] | event | 串口事件
返回

= 0 - 成功
< 0 - 失败, 返回值为错误码

事件包括串口数据可读/溢出等。需在open之前注册。
内置4K缓存区保存未读出的数据，若注册了溢出事件，缓存区满后将上报溢出，缓存区溢出状态下将丢弃新接收的数据。
回调函数中不可输出LOG、串口打印、执行复杂任务或消耗过多资源。

◆ cm_uart_close()

int32_t cm_uart_close ( cm_uart_dev_e dev )

关闭串口

参数
[in] dev 串口设备ID
返回
= 0 - 成功
< 0 - 失败, 返回值为错误码

◆ cm_uart_write()

int32_t cm_uart_write | ( | cm_uart_dev_e | dev,
 |  | const void * | data,
 |  | int32_t | len,
 |  | int32_t | timeout
 | ) |  |

串口写数据

参数
[in] | dev | 串口设备ID
[in] | data | 待写入数据
[in] | len | 长度
[in] | timeout | 超时时间(ms)(无效参数)
返回
= 实际写入长度 - 成功
< 0 - 失败, 返回值为错误码

◆ cm_uart_read()

int32_t cm_uart_read | ( | cm_uart_dev_e | dev,
 |  | void * | data,
 |  | int32_t | len,
 |  | int32_t | timeout
 | ) |  |

串口读数据

参数
[in] | dev | 串口设备ID
[out] | data | 待读数据
[in] | len | 长度
[in] | timeout | 超时时间(ms)(无效参数)
返回
= 实际读出长度 - 成功
< 0 - 失败, 返回值为错误码


ML305A_ML307A_OpenCPU_API: cm_uart_cfg_t结构体 参考

成员变量
cm_uart_cfg_t结构体 参考
uart

#include <cm_uart.h>

成员变量

cm_uart_byte_size_e byte_size
cm_uart_parity_e parity
cm_uart_stop_bit_e stop_bit
cm_uart_flow_ctrl_e flow_ctrl
int | baudrate
int | is_lpuart

详细描述

配置

结构体成员变量说明

◆ byte_size

cm_uart_byte_size_e byte_size

数据位，枚举

◆ parity

cm_uart_parity_e parity

校验位，枚举

◆ stop_bit

cm_uart_stop_bit_e stop_bit

停止位，枚举

◆ flow_ctrl

cm_uart_flow_ctrl_e flow_ctrl

流控制，枚举

◆ baudrate

int baudrate

波特率，支持的波特率见本文件中标准波特率宏定义和特殊波特率宏定义

◆ is_lpuart

int is_lpuart

1:低功耗串口(仅支持115200以内的标准波特率(不支持76800))；0:普通串口

该结构体的文档由以下文件生成:
  • cm_uart.h


ML305A_ML307A_OpenCPU_API: cm_uart_event_t结构体 参考

成员变量
cm_uart_event_t结构体 参考
uart

#include <cm_uart.h>

成员变量

uint32_t | event_type
void * | event_param
void * | event_entry

详细描述

事件

结构体成员变量说明

◆ event_type

uint32_t event_type

事件类型，数据可读等

◆ event_param

void* event_param

事件参数

◆ event_entry

void* event_entry

事件执行入口

该结构体的文档由以下文件生成:
  • cm_uart.h


ML305A_ML307A_OpenCPU_API: USB

宏定义 | 类型定义 | 函数
USB

宏定义

#define | CM_USB_EVT_INSERT 1
#define | CM_USB_EVT_REMOVE 0

类型定义

typedef void(* | cm_usb2com_recv_cb) (void *data, int32_t len)
typedef void(* | cm_usb2com_status_cb) (int32_t evt)

函数

void | cm_usb2com_register_recv_cb (cm_usb2com_recv_cb recv_cb)
注册USB2COM接收回调函数 更多...
int32_t | cm_usb2com_send_data (void *data, int32_t len)
USB2COM发送数据 更多...
void | cm_usb2com_register_status_cb (cm_usb2com_status_cb status_cb)
注册USB2COM插拔事件回调函数 更多...

详细描述

宏定义说明

◆ CM_USB_EVT_INSERT

#define CM_USB_EVT_INSERT 1

◆ CM_USB_EVT_REMOVE

#define CM_USB_EVT_REMOVE 0

类型定义说明

◆ cm_usb2com_recv_cb

typedef void(* cm_usb2com_recv_cb) (void *data, int32_t len)

定义USB接收回调

◆ cm_usb2com_status_cb

typedef void(* cm_usb2com_status_cb) (int32_t evt)

定义USB插拔事件回调

函数说明

◆ cm_usb2com_register_recv_cb()

void cm_usb2com_register_recv_cb ( cm_usb2com_recv_cb recv_cb )

注册USB2COM接收回调函数

参数
[in] recv_cb 接收回调函数
返回
None

禁止跨多线程使用

◆ cm_usb2com_send_data()

int32_t cm_usb2com_send_data | ( | void * | data,
 |  | int32_t | len
 | ) |  |

USB2COM发送数据

参数
[in] | data | 待发送数据
[in] | len | 数据长度
返回
成功返回0，失败返回负值

禁止跨多线程使用

◆ cm_usb2com_register_status_cb()

void cm_usb2com_register_status_cb ( cm_usb2com_status_cb status_cb )

注册USB2COM插拔事件回调函数

参数
[in] status_cb 插拔事件回调函数
返回
None

禁止跨多线程使用


ML305A_ML307A_OpenCPU_API: virt_at

类型定义 | 函数
virt_at

类型定义

typedef void(* | cm_at_urc_callback) (char *urc)
typedef void(* | cm_virt_at_cb) (void *param)

函数

int32_t | cm_virt_at_init (cm_virt_at_cb cb)
初始化AT虚拟通道 更多...
int32_t | cm_virt_at_send (uint8_t *data, int32_t len)
通过AT虚拟通道发送数据 更多...
int32_t | cm_virt_at_get (unsigned char *data, int len)
通过AT虚拟通道接收数据 更多...
void | cm_virt_at_deinit (void)
AT虚拟通道去初始化 更多...
void | cm_virt_at_urc_reg (cm_at_urc_callback cb)
初始化消息主动上报通道 更多...
int | cm_virt_at_sms_send (char *atCmgs, char *msgData, int simId)
发送短信 更多...
int | cm_virt_at_msg_memory (char *smsNum, char *msgData, int simId)
本地短信存储 更多...

详细描述

类型定义说明

◆ cm_at_urc_callback

typedef void(* cm_at_urc_callback) (char *urc)

来电短信等消息主动上报调函数类型

◆ cm_virt_at_cb

typedef void(* cm_virt_at_cb) (void *param)

虚拟AT通道回调函数类型

函数说明

◆ cm_virt_at_init()

int32_t cm_virt_at_init ( cm_virt_at_cb cb )

初始化AT虚拟通道

参数
[in] cb AT虚拟通道消息回调函数
返回
= 0 - 成功
< 0 - 失败

More details

◆ cm_virt_at_send()

int32_t cm_virt_at_send | ( | uint8_t * | data,
 |  | int32_t | len
 | ) |  |

通过AT虚拟通道发送数据

参数
[in] | data | 数据缓冲区指针
[in] | len | 要发送的数据长度
返回
>= 0 - 实际发送的长度
< 0 - 失败

暂不支持发送短信

◆ cm_virt_at_get()

int32_t cm_virt_at_get | ( | unsigned char * | data,
 |  | int | len
 | ) |  |

通过AT虚拟通道接收数据

参数
[in] | data | 数据缓冲区指针
[in] | len | 数据缓冲区长度
返回
>= 0 - 实际接收的长度
< 0 - 失败

More details

◆ cm_virt_at_deinit()

void cm_virt_at_deinit ( void )

AT虚拟通道去初始化

返回
空

More details

◆ cm_virt_at_urc_reg()

void cm_virt_at_urc_reg ( cm_at_urc_callback cb )

初始化消息主动上报通道

参数
[in] cb消息主动上报回调函数
返回
空

More details

◆ cm_virt_at_sms_send()

int cm_virt_at_sms_send | ( | char * | atCmgs,
 |  | char * | msgData,
 |  | int | simId
 | ) |  |

发送短信

参数
[in] | atCmgs | AT命令AT+CMGS=后的参数
[in] | msgData | 需要发送的短信信息
[in] | simId | 选择需要发送短信的SIM卡
返回
= 0 - 成功
< 0 - 失败

More details

◆ cm_virt_at_msg_memory()

int cm_virt_at_msg_memory | ( | char * | smsNum,
 |  | char * | msgData,
 |  | int | simId
 | ) |  |

本地短信存储

参数
[in] | smsNum | 接收短信的电话号码
[in] | msgData | 需要发送的短信信息
[in] | simId | 选择需要发送短信的SIM卡
返回
= 0 - 成功
< 0 - 失败

More details


ML305A_ML307A_OpenCPU_API: Wifiscan

结构体 | 宏定义 | 类型定义 | 枚举 | 函数
Wifiscan

结构体

struct | cm_wifi_scan_cell_info_t
struct | cm_wifi_scan_info_t

宏定义

#define | MAX_BSSID_NUM_TOTAL 30
#define | SIZE_MAC_ADDRESS 6

类型定义

typedef void(* cm_wifiscan_callback_t) (cm_wifi_scan_info_t *param, void *user_param)
扫描回调函数 更多...

枚举

enum | cm_wifi_scan_priority_e { CM_WIFI_SCAN_LTE_HIGH =0 , CM_WIFI_SCAN_WIFI_HIGH }
enum | cm_wifi_scan_cfg_type_e { CM_WIFI_SCAN_CFG_ROUND , CM_WIFI_SCAN_CFG_MAX_COUNT , CM_WIFI_SCAN_CFG_TIMEOUT , CM_WIFI_SCAN_CFG_PRIORITY }

函数

int32_t | cm_wifiscan_cfg (cm_wifi_scan_cfg_type_e type, void *value)
设置扫描参数 更多...
int32_t | cm_wifiscan_start (cm_wifiscan_callback_t cb, void *user_param)
开始扫描 更多...
int32_t | cm_wifiscan_stop (void)
停止扫描 更多...
int32_t | cm_wifiscan_query (cm_wifi_scan_info_t **param)
查询最近一次扫描结果 更多...

详细描述

宏定义说明

◆ MAX_BSSID_NUM_TOTAL

#define MAX_BSSID_NUM_TOTAL 30

扫描信息单元最大数量，请勿修改

◆ SIZE_MAC_ADDRESS

#define SIZE_MAC_ADDRESS 6

MAC地址缓存区长度，请勿修改

类型定义说明

◆ cm_wifiscan_callback_t

typedef void(* cm_wifiscan_callback_t) (cm_wifi_scan_info_t *param, void *user_param)

扫描回调函数

参数
[in] | param | 扫描结果
[in] | user_param | 用户参数

调用cm_wifiscan_start时传入

枚举类型说明

◆ cm_wifi_scan_priority_e

enum cm_wifi_scan_priority_e

优先级

枚举值
CM_WIFI_SCAN_LTE_HIGH | 优先级设置，LTE优先
CM_WIFI_SCAN_WIFI_HIGH | 优先级设置，WIFI优先

◆ cm_wifi_scan_cfg_type_e

enum cm_wifi_scan_cfg_type_e

参数配置类型

枚举值
CM_WIFI_SCAN_CFG_ROUND | 扫描轮次，范围：1~3，默认值3 （该配置项暂不生效）
CM_WIFI_SCAN_CFG_MAX_COUNT | 最大扫描数量，范围：4~10，默认值5（该配置项暂不生效）
CM_WIFI_SCAN_CFG_TIMEOUT | 扫描超时时间，单位：s，范围：10~60，默认值25 （该配置项暂不生效）
CM_WIFI_SCAN_CFG_PRIORITY | LTE、WIFI优先级，支持范围参见cm_wifi_scan_priority_e枚举量，默认值CM_WIFI_SCAN_LTE_HIGH （该配置项暂不生效）

函数说明

◆ cm_wifiscan_cfg()

int32_t cm_wifiscan_cfg | ( | cm_wifi_scan_cfg_type_e | type,
 |  | void * | value
 | ) |  |

设置扫描参数

参数
[in] | type | 设置参数类型
[in] | value | 设置参数数值
返回
= 0 - 成功
= -1 - 失败

◆ cm_wifiscan_start()

int32_t cm_wifiscan_start | ( | cm_wifiscan_callback_t | cb,
 |  | void * | user_param
 | ) |  |

开始扫描

参数
[in] | cb | 回调函数
[in] | user_param | 用户参数
返回
= 0 - 成功
= -1 - 失败

开启wifiscan功能，开启后结果将通过回调函数异步上报。
切换CFUN过程中禁止扫描WiFi。

◆ cm_wifiscan_stop()

int32_t cm_wifiscan_stop ( void )

停止扫描

返回
= 0 - 成功
= -1 - 失败

用于超时时间未到或结果未完全返回时，可中断wifiscan功能。(该接口未生效)

◆ cm_wifiscan_query()

int32_t cm_wifiscan_query ( cm_wifi_scan_info_t ** param )

查询最近一次扫描结果

参数
[out] param 扫描结果
返回
= 0 - 成功
= -1 - 失败


ML305A_ML307A_OpenCPU_API: cm_wifi_scan_cell_info_t结构体 参考

成员变量
cm_wifi_scan_cell_info_t结构体 参考
Wifiscan

#include <cm_wifiscan.h>

成员变量

uint8_t | bssid [SIZE_MAC_ADDRESS]
uint8_t | padding [2]
int32_t | rssi
uint32_t | channel_number

详细描述

扫描到的单元数据

结构体成员变量说明

◆ bssid

uint8_t bssid[SIZE_MAC_ADDRESS]

Basic Service SetIDentifier，一般是AP MAC地址

◆ padding

uint8_t padding[2]

预留，未使用

◆ rssi

int32_t rssi

开发中，暂不支持

◆ channel_number

uint32_t channel_number

通道号

该结构体的文档由以下文件生成:
  • cm_wifiscan.h


ML305A_ML307A_OpenCPU_API: cm_wifi_scan_info_t结构体 参考

成员变量
cm_wifi_scan_info_t结构体 参考
Wifiscan

#include <cm_wifiscan.h>

成员变量

uint8_t bssid_number
cm_wifi_scan_cell_info_t channel_cell_list [MAX_BSSID_NUM_TOTAL]

详细描述

扫描到的全部数据

结构体成员变量说明

◆ bssid_number

uint8_t bssid_number

扫描到的单元数量

◆ channel_cell_list

cm_wifi_scan_cell_info_t channel_cell_list[MAX_BSSID_NUM_TOTAL]

单元数据

该结构体的文档由以下文件生成:
  • cm_wifiscan.h


ML305A_ML307A_OpenCPU_API: 结构体

结构体
这里列出了所有结构体，并附带简要说明:
C cm_agnss_location_t |
C cm_async_dns_ip_addr |
C cm_audio_record_data_t |
C cm_audio_sample_param_t |
C cm_cam_regval_tab | I2c寄存器地址及写入值
C cm_cam_sensor_aec_t | Camera 曝光参数
C cm_cam_sensor_ata_t | Camera ata模式参数
C cm_cam_sensor_data_t | Camera驱动结构体
C cm_cam_sensor_global | 预留参数相关结构体，暂无使用
C cm_cam_sensor_i2c_attr | I2c参数
C cm_cam_sensor_module | 预留参数结构体
C cm_cam_sensor_regs | I2c寄存器操作表
C cm_cam_sensor_resolution | Camera参数设置及初始化
C cm_cam_sensor_spec_ops | Camera操作函数
C cm_camera_capture_cfg_t | Camera拍照接口配置参数
C cm_camera_preview_cfg_t | Camera预览接口配置参数
C cm_cell_info_t |
C cm_fota_extendible_info_t |
C cm_fota_info_fixed_t |
C cm_fota_info_t |
C cm_fota_reboot_time |
C cm_fs_system_info_t |
C cm_ftp_config_t |
C cm_ftp_file_data_t |
C cm_gnss_location_info_t |
C cm_gpio_cfg_t |
C cm_heap_stats_t |
C cm_httpclient_callback_rsp_content_param_t |
C cm_httpclient_callback_rsp_header_param_t |
C cm_httpclient_cfg_t |
C cm_httpclient_sync_param_t |
C cm_httpclient_sync_response_t |
C cm_i2c_cfg_t | I2C 配置
C cm_isp_tuning_data | ISP 寄存器操作表
C cm_isp_tuning_tab | ISP 寄存器地址组及写入值
C cm_keypad_cfg_t |
C cm_lbs_amap_location_attr_t |
C cm_lbs_location_rsp_t |
C cm_lbs_mantu_location_attr_t |
C cm_lbs_oneospos_attr_t |
C cm_local_tts_cfg_t |
C cm_local_tts_synth_data_t |
C cm_mqtt_client_cb_t |
C cm_mqtt_connect_options_t |
C cm_mqtt_topic_t |
C cm_pm_cfg_t |
C cm_qr_param_t |
C cm_radio_info_t |
C cm_sd_system_info_t |
C cm_spi_cfg_t |
C cm_thread_runtime_t |
C cm_tts_cfg_t |
C cm_uart_cfg_t |
C cm_uart_event_t |
C cm_wifi_scan_cell_info_t |
C cm_wifi_scan_info_t |
C osEventFlagsAttr_t |
C osMemoryPoolAttr_t |
C osMessageQueueAttr_t |
C osMutexAttr_t |
C osSemaphoreAttr_t |
C osThreadAttr_t |
C osTimerAttr_t |
C osVersion_t |


ML305A_ML307A_OpenCPU_API: 结构体索引

结构体索引
C | O
C
cm_agnss_location_t
cm_async_dns_ip_addr
cm_audio_record_data_t
cm_audio_sample_param_t
cm_cam_regval_tab
cm_cam_sensor_aec_t
cm_cam_sensor_ata_t
cm_cam_sensor_data_t
cm_cam_sensor_global
cm_cam_sensor_i2c_attr
cm_cam_sensor_module
cm_cam_sensor_regs
cm_cam_sensor_resolution
cm_cam_sensor_spec_ops
cm_camera_capture_cfg_t
cm_camera_preview_cfg_t
cm_cell_info_t
cm_fota_extendible_info_t
cm_fota_info_fixed_t
cm_fota_info_t
cm_fota_reboot_time
cm_fs_system_info_t
cm_ftp_config_t
cm_ftp_file_data_t
cm_gnss_location_info_t
cm_gpio_cfg_t
cm_heap_stats_t
cm_httpclient_callback_rsp_content_param_t
cm_httpclient_callback_rsp_header_param_t
cm_httpclient_cfg_t
cm_httpclient_sync_param_t
cm_httpclient_sync_response_t
cm_i2c_cfg_t
cm_isp_tuning_data
cm_isp_tuning_tab
cm_keypad_cfg_t
cm_lbs_amap_location_attr_t
cm_lbs_location_rsp_t
cm_lbs_mantu_location_attr_t
cm_lbs_oneospos_attr_t
cm_local_tts_cfg_t
cm_local_tts_synth_data_t
cm_mqtt_client_cb_t
cm_mqtt_connect_options_t
cm_mqtt_topic_t
cm_pm_cfg_t
cm_qr_param_t
cm_radio_info_t
cm_sd_system_info_t
cm_spi_cfg_t
cm_thread_runtime_t
cm_tts_cfg_t
cm_uart_cfg_t
cm_uart_event_t
cm_wifi_scan_cell_info_t
cm_wifi_scan_info_t
O
osEventFlagsAttr_t
osMemoryPoolAttr_t
osMessageQueueAttr_t
osMutexAttr_t
osSemaphoreAttr_t
osThreadAttr_t
osTimerAttr_t
osVersion_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- a -

  • adcode : cm_lbs_location_rsp_t
  • addr : cm_cam_sensor_i2c_attr
  • addr_type : cm_i2c_cfg_t
  • aec_en : cm_cam_sensor_aec_t
  • allocated : cm_heap_stats_t
  • allocated_peak : cm_heap_stats_t
  • allocated_times : cm_heap_stats_t
  • altitude : cm_gnss_location_info_t
  • apeture_size : cm_cam_sensor_module
  • api : osVersion_t
  • api_key : cm_lbs_amap_location_attr_t
  • apiKey : cm_tts_cfg_t
  • appid : cm_lbs_mantu_location_attr_t
  • ata_open : cm_cam_sensor_spec_ops
  • attr_bits : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- b -

  • banding : cm_cam_sensor_aec_t
  • banding_tab : cm_cam_sensor_data_t
  • bandwidth : cm_cell_info_t
  • baudrate : cm_uart_cfg_t
  • bssid : cm_wifi_scan_cell_info_t
  • bssid_number : cm_wifi_scan_info_t
  • byte_size : cm_uart_cfg_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- c -

  • callback : cm_qr_param_t
  • cb_enter : cm_pm_cfg_t
  • cb_exit : cm_pm_cfg_t
  • cb_mem : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • cb_size : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • channel : cm_tts_cfg_t
  • channel_cell_list : cm_wifi_scan_info_t
  • channel_number : cm_wifi_scan_cell_info_t
  • cid : cm_cell_info_t , cm_ftp_config_t , cm_httpclient_cfg_t
  • city : cm_lbs_location_rsp_t
  • citycode : cm_lbs_location_rsp_t
  • clean_session : cm_mqtt_connect_options_t
  • clientid : cm_mqtt_connect_options_t
  • clk : cm_i2c_cfg_t , cm_spi_cfg_t
  • cm_col : cm_keypad_cfg_t
  • cm_col_len : cm_keypad_cfg_t
  • cm_row : cm_keypad_cfg_t
  • cm_row_len : cm_keypad_cfg_t
  • cog : cm_gnss_location_info_t
  • conn_flags : cm_mqtt_connect_options_t
  • conn_timeout : cm_httpclient_cfg_t
  • connack_cb : cm_mqtt_client_cb_t
  • constant_timeout : cm_fota_reboot_time
  • content : cm_httpclient_sync_param_t
  • content_length : cm_httpclient_sync_param_t
  • country : cm_lbs_location_rsp_t
  • cur_i2c_index : cm_cam_sensor_data_t
  • cur_res_index : cm_cam_sensor_data_t
  • current_len : cm_httpclient_callback_rsp_content_param_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- d -

  • data : cm_audio_record_data_t , cm_local_tts_synth_data_t , cm_qr_param_t
  • data_type : cm_ftp_config_t
  • data_width : cm_spi_cfg_t
  • digit : cm_local_tts_cfg_t
  • digital_key : cm_lbs_amap_location_attr_t
  • digital_sign_enable : cm_lbs_amap_location_attr_t
  • direction : cm_gpio_cfg_t
  • dns_priority : cm_httpclient_cfg_t
  • dtype : cm_gnss_location_info_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- e -

  • earfcn : cm_cell_info_t
  • earfcn_offset : cm_cell_info_t
  • effect : cm_local_tts_cfg_t
  • encode : cm_local_tts_cfg_t , cm_tts_cfg_t
  • enqueueCamRecordBuffer : cm_camera_preview_cfg_t
  • event_entry : cm_uart_event_t
  • event_param : cm_uart_event_t
  • event_type : cm_uart_event_t
  • exp_high : cm_cam_sensor_aec_t
  • exp_low : cm_cam_sensor_aec_t
  • expo_reg : cm_cam_sensor_data_t
  • extend_info : cm_fota_info_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- f -

  • failure : cm_fota_extendible_info_t
  • fifth_timeout : cm_fota_reboot_time
  • file_attr : cm_ftp_file_data_t
  • file_modify_time : cm_ftp_file_data_t
  • file_name : cm_camera_capture_cfg_t , cm_ftp_file_data_t
  • file_permision : cm_ftp_file_data_t
  • file_size : cm_ftp_file_data_t
  • first_timeout : cm_fota_reboot_time
  • fix : cm_gnss_location_info_t
  • fixed_info : cm_fota_info_t
  • flow_ctrl : cm_uart_cfg_t
  • flushCamRecordBuffers : cm_camera_preview_cfg_t
  • format : cm_qr_param_t
  • fota_mode : cm_fota_info_fixed_t
  • fourth_timeout : cm_fota_reboot_time
  • free : cm_heap_stats_t
  • free_size : cm_fs_system_info_t , cm_sd_system_info_t
  • free_times : cm_heap_stats_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- g -

  • gain : cm_cam_sensor_aec_t
  • gain_reg : cm_cam_sensor_data_t
  • get_dphy_desc : cm_cam_sensor_spec_ops
  • get_pixel_rate : cm_cam_sensor_spec_ops
  • global_setting : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- h -

  • handle : cm_thread_runtime_t
  • hdop : cm_gnss_location_info_t
  • height : cm_cam_sensor_resolution , cm_qr_param_t
  • hflip : cm_cam_sensor_data_t
  • hostname : cm_mqtt_connect_options_t
  • hostport : cm_mqtt_connect_options_t
  • hts : cm_cam_sensor_resolution


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- i -

  • i2c_attr : cm_cam_sensor_data_t
  • id : cm_cam_sensor_data_t , cm_cam_sensor_module
  • interface_type : cm_cam_sensor_data_t
  • is_lpuart : cm_uart_cfg_t
  • isSetTimeout : cm_fota_extendible_info_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- k -

  • keepalive : cm_mqtt_connect_options_t
  • kernel : osVersion_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- l -

  • lane_num : cm_cam_sensor_data_t
  • last_cellid : cm_radio_info_t
  • last_earfcn : cm_radio_info_t
  • last_ecl : cm_radio_info_t
  • last_pci : cm_radio_info_t
  • last_snr : cm_radio_info_t
  • last_tick : cm_thread_runtime_t
  • latitude : cm_agnss_location_t , cm_gnss_location_info_t , cm_lbs_location_rsp_t
  • len : cm_audio_record_data_t , cm_local_tts_synth_data_t
  • location_describe : cm_lbs_location_rsp_t
  • longitude : cm_agnss_location_t , cm_gnss_location_info_t , cm_lbs_location_rsp_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- m -

  • mask : cm_cam_regval_tab
  • max_continuity_free : cm_heap_stats_t
  • max_fps : cm_cam_sensor_aec_t , cm_cam_sensor_resolution
  • mbus_code : cm_cam_sensor_resolution
  • mcc : cm_cell_info_t
  • method : cm_httpclient_sync_param_t
  • min_fps : cm_cam_sensor_aec_t , cm_cam_sensor_resolution
  • min_vts : cm_cam_sensor_resolution
  • mnc : cm_cell_info_t
  • mode : cm_agnss_location_t , cm_gpio_cfg_t , cm_i2c_cfg_t , cm_spi_cfg_t
  • module : cm_cam_sensor_data_t
  • mp_mem : osMemoryPoolAttr_t
  • mp_size : osMemoryPoolAttr_t
  • mq_mem : osMessageQueueAttr_t
  • mq_size : osMessageQueueAttr_t
  • msg_id : cm_mqtt_topic_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- n -

  • name : cm_cam_sensor_data_t , cm_cam_sensor_module , osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • nearbts_enable : cm_lbs_amap_location_attr_t , cm_lbs_oneospos_attr_t
  • nsat : cm_gnss_location_info_t
  • nss : cm_spi_cfg_t
  • num : cm_cam_sensor_regs , cm_isp_tuning_data
  • num_channels : cm_audio_sample_param_t
  • num_global : cm_cam_sensor_data_t
  • num_i2c_attr : cm_cam_sensor_data_t
  • num_module : cm_cam_sensor_data_t
  • num_res : cm_cam_sensor_data_t
  • num_tuning_tab : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- o -

  • on : cm_cam_sensor_ata_t
  • ops : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- p -

  • padding : cm_wifi_scan_cell_info_t
  • parity : cm_uart_cfg_t
  • passwd : cm_fota_info_fixed_t , cm_ftp_config_t
  • password : cm_lbs_mantu_location_attr_t , cm_mqtt_connect_options_t
  • path : cm_httpclient_sync_param_t
  • pci : cm_cell_info_t
  • pid : cm_lbs_oneospos_attr_t
  • pingresp_cb : cm_mqtt_client_cb_t
  • pitch : cm_tts_cfg_t
  • platform : cm_lbs_location_rsp_t
  • poi : cm_lbs_location_rsp_t
  • port : cm_ftp_config_t
  • position : cm_cam_sensor_data_t
  • primary_cell : cm_cell_info_t
  • priority : osThreadAttr_t
  • prop : cm_cam_sensor_resolution
  • province : cm_lbs_location_rsp_t
  • puback_cb : cm_mqtt_client_cb_t
  • pubcomp_cb : cm_mqtt_client_cb_t
  • publish_cb : cm_mqtt_client_cb_t
  • pubrec_cb : cm_mqtt_client_cb_t
  • pubrel_cb : cm_mqtt_client_cb_t
  • pull : cm_gpio_cfg_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- q -

  • qos : cm_mqtt_topic_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- r -

  • radius : cm_lbs_location_rsp_t
  • rat : cm_radio_info_t
  • rate : cm_audio_sample_param_t
  • rdn : cm_tts_cfg_t
  • read_crc_value : cm_cam_sensor_ata_t
  • recordFormat : cm_camera_capture_cfg_t , cm_camera_preview_cfg_t
  • reg : cm_cam_regval_tab , cm_isp_tuning_tab
  • reg_len : cm_cam_sensor_i2c_attr
  • regs : cm_cam_sensor_global , cm_cam_sensor_resolution
  • res : cm_cam_sensor_data_t
  • reserved : cm_fota_info_fixed_t , osThreadAttr_t
  • reset_delay : cm_cam_sensor_data_t
  • response_code : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • response_content : cm_httpclient_callback_rsp_content_param_t , cm_httpclient_sync_response_t
  • response_content_len : cm_httpclient_sync_response_t
  • response_header : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • response_header_len : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • rsp_timeout : cm_httpclient_cfg_t
  • rsptimeout : cm_ftp_config_t
  • rsrp : cm_cell_info_t , cm_radio_info_t
  • rsrq : cm_cell_info_t , cm_radio_info_t
  • rssi : cm_cell_info_t , cm_radio_info_t , cm_wifi_scan_cell_info_t
  • rx_time : cm_radio_info_t
  • rxlev : cm_radio_info_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- s -

  • s_power : cm_cam_sensor_spec_ops
  • sample_format : cm_audio_sample_param_t
  • scheduled_cnt : cm_thread_runtime_t
  • second_timeout : cm_fota_reboot_time
  • secretKey : cm_tts_cfg_t
  • sensor_out_format : cm_cam_sensor_global , cm_cam_sensor_resolution
  • sensor_out_yuv : cm_cam_sensor_aec_t
  • set_banding : cm_cam_sensor_spec_ops
  • set_brightness : cm_cam_sensor_spec_ops
  • set_contrast : cm_cam_sensor_spec_ops
  • set_effect : cm_cam_sensor_spec_ops
  • set_saturation : cm_cam_sensor_spec_ops
  • set_wb : cm_cam_sensor_spec_ops
  • show_fields_enable : cm_lbs_amap_location_attr_t
  • sin6_addr : cm_async_dns_ip_addr
  • sin_addr : cm_async_dns_ip_addr
  • sixth_timeout : cm_fota_reboot_time
  • snr : cm_cell_info_t
  • speed : cm_local_tts_cfg_t , cm_tts_cfg_t
  • spi_crc : cm_cam_sensor_data_t
  • spi_sdr : cm_cam_sensor_data_t
  • spkm : cm_gnss_location_info_t
  • spkn : cm_gnss_location_info_t
  • ssl_enable : cm_httpclient_cfg_t
  • ssl_id : cm_ftp_config_t , cm_httpclient_cfg_t
  • ssl_mode : cm_ftp_config_t
  • stack_mem : osThreadAttr_t
  • stack_size : osThreadAttr_t
  • stage : cm_fota_info_fixed_t
  • state : cm_lbs_location_rsp_t , cm_mqtt_topic_t
  • stop_bit : cm_uart_cfg_t
  • streamoff : cm_cam_sensor_data_t
  • streamon : cm_cam_sensor_data_t
  • suback_cb : cm_mqtt_client_cb_t
  • sum_len : cm_httpclient_callback_rsp_content_param_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- t -

  • tab : cm_cam_sensor_regs , cm_isp_tuning_data
  • tac : cm_cell_info_t
  • third_timeout : cm_fota_reboot_time
  • tick_cnt : cm_thread_runtime_t
  • time_out : cm_lbs_amap_location_attr_t , cm_lbs_mantu_location_attr_t , cm_lbs_oneospos_attr_t
  • timeout : cm_fota_extendible_info_t
  • timeout_cb : cm_mqtt_client_cb_t
  • tone : cm_local_tts_cfg_t
  • topic : cm_mqtt_topic_t
  • topic_len : cm_mqtt_topic_t
  • total_len : cm_httpclient_callback_rsp_content_param_t
  • total_size : cm_fs_system_info_t , cm_heap_stats_t , cm_sd_system_info_t
  • trans_mode : cm_ftp_config_t
  • transid : cm_lbs_mantu_location_attr_t
  • tuning_tab : cm_cam_sensor_data_t
  • tx_power : cm_radio_info_t
  • tx_time : cm_radio_info_t
  • type : cm_async_dns_ip_addr
  • tz_module : osThreadAttr_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- u -

  • u_addr : cm_async_dns_ip_addr
  • unsuback_cb : cm_mqtt_client_cb_t
  • update_aec : cm_cam_sensor_spec_ops
  • update_otp : cm_cam_sensor_spec_ops
  • url : cm_fota_info_fixed_t , cm_ftp_config_t , cm_tts_cfg_t
  • user : cm_audio_record_data_t , cm_local_tts_synth_data_t
  • username : cm_fota_info_fixed_t , cm_ftp_config_t , cm_mqtt_connect_options_t
  • usrdata : cm_qr_param_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- v -

  • val : cm_cam_regval_tab , cm_isp_tuning_tab
  • val_len : cm_cam_sensor_i2c_attr
  • vflip : cm_cam_sensor_data_t
  • voice : cm_tts_cfg_t
  • volume : cm_local_tts_cfg_t , cm_tts_cfg_t
  • vts_reg : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量

这里列出了所有结构体和联合体的成员变量，并附带结构体或联合的详细说明:

- w -

  • width : cm_cam_sensor_resolution , cm_qr_param_t
  • will_flag : cm_mqtt_connect_options_t
  • will_message : cm_mqtt_connect_options_t
  • will_message_len : cm_mqtt_connect_options_t
  • will_qos : cm_mqtt_connect_options_t
  • will_retain : cm_mqtt_connect_options_t
  • will_topic : cm_mqtt_connect_options_t
  • work_mode : cm_spi_cfg_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- a -

  • adcode : cm_lbs_location_rsp_t
  • addr : cm_cam_sensor_i2c_attr
  • addr_type : cm_i2c_cfg_t
  • aec_en : cm_cam_sensor_aec_t
  • allocated : cm_heap_stats_t
  • allocated_peak : cm_heap_stats_t
  • allocated_times : cm_heap_stats_t
  • altitude : cm_gnss_location_info_t
  • apeture_size : cm_cam_sensor_module
  • api : osVersion_t
  • api_key : cm_lbs_amap_location_attr_t
  • apiKey : cm_tts_cfg_t
  • appid : cm_lbs_mantu_location_attr_t
  • ata_open : cm_cam_sensor_spec_ops
  • attr_bits : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- b -

  • banding : cm_cam_sensor_aec_t
  • banding_tab : cm_cam_sensor_data_t
  • bandwidth : cm_cell_info_t
  • baudrate : cm_uart_cfg_t
  • bssid : cm_wifi_scan_cell_info_t
  • bssid_number : cm_wifi_scan_info_t
  • byte_size : cm_uart_cfg_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- c -

  • callback : cm_qr_param_t
  • cb_enter : cm_pm_cfg_t
  • cb_exit : cm_pm_cfg_t
  • cb_mem : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • cb_size : osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • channel : cm_tts_cfg_t
  • channel_cell_list : cm_wifi_scan_info_t
  • channel_number : cm_wifi_scan_cell_info_t
  • cid : cm_cell_info_t , cm_ftp_config_t , cm_httpclient_cfg_t
  • city : cm_lbs_location_rsp_t
  • citycode : cm_lbs_location_rsp_t
  • clean_session : cm_mqtt_connect_options_t
  • clientid : cm_mqtt_connect_options_t
  • clk : cm_i2c_cfg_t , cm_spi_cfg_t
  • cm_col : cm_keypad_cfg_t
  • cm_col_len : cm_keypad_cfg_t
  • cm_row : cm_keypad_cfg_t
  • cm_row_len : cm_keypad_cfg_t
  • cog : cm_gnss_location_info_t
  • conn_flags : cm_mqtt_connect_options_t
  • conn_timeout : cm_httpclient_cfg_t
  • connack_cb : cm_mqtt_client_cb_t
  • constant_timeout : cm_fota_reboot_time
  • content : cm_httpclient_sync_param_t
  • content_length : cm_httpclient_sync_param_t
  • country : cm_lbs_location_rsp_t
  • cur_i2c_index : cm_cam_sensor_data_t
  • cur_res_index : cm_cam_sensor_data_t
  • current_len : cm_httpclient_callback_rsp_content_param_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- d -

  • data : cm_audio_record_data_t , cm_local_tts_synth_data_t , cm_qr_param_t
  • data_type : cm_ftp_config_t
  • data_width : cm_spi_cfg_t
  • digit : cm_local_tts_cfg_t
  • digital_key : cm_lbs_amap_location_attr_t
  • digital_sign_enable : cm_lbs_amap_location_attr_t
  • direction : cm_gpio_cfg_t
  • dns_priority : cm_httpclient_cfg_t
  • dtype : cm_gnss_location_info_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- e -

  • earfcn : cm_cell_info_t
  • earfcn_offset : cm_cell_info_t
  • effect : cm_local_tts_cfg_t
  • encode : cm_local_tts_cfg_t , cm_tts_cfg_t
  • enqueueCamRecordBuffer : cm_camera_preview_cfg_t
  • event_entry : cm_uart_event_t
  • event_param : cm_uart_event_t
  • event_type : cm_uart_event_t
  • exp_high : cm_cam_sensor_aec_t
  • exp_low : cm_cam_sensor_aec_t
  • expo_reg : cm_cam_sensor_data_t
  • extend_info : cm_fota_info_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- f -

  • failure : cm_fota_extendible_info_t
  • fifth_timeout : cm_fota_reboot_time
  • file_attr : cm_ftp_file_data_t
  • file_modify_time : cm_ftp_file_data_t
  • file_name : cm_camera_capture_cfg_t , cm_ftp_file_data_t
  • file_permision : cm_ftp_file_data_t
  • file_size : cm_ftp_file_data_t
  • first_timeout : cm_fota_reboot_time
  • fix : cm_gnss_location_info_t
  • fixed_info : cm_fota_info_t
  • flow_ctrl : cm_uart_cfg_t
  • flushCamRecordBuffers : cm_camera_preview_cfg_t
  • format : cm_qr_param_t
  • fota_mode : cm_fota_info_fixed_t
  • fourth_timeout : cm_fota_reboot_time
  • free : cm_heap_stats_t
  • free_size : cm_fs_system_info_t , cm_sd_system_info_t
  • free_times : cm_heap_stats_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- g -

  • gain : cm_cam_sensor_aec_t
  • gain_reg : cm_cam_sensor_data_t
  • get_dphy_desc : cm_cam_sensor_spec_ops
  • get_pixel_rate : cm_cam_sensor_spec_ops
  • global_setting : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- h -

  • handle : cm_thread_runtime_t
  • hdop : cm_gnss_location_info_t
  • height : cm_cam_sensor_resolution , cm_qr_param_t
  • hflip : cm_cam_sensor_data_t
  • hostname : cm_mqtt_connect_options_t
  • hostport : cm_mqtt_connect_options_t
  • hts : cm_cam_sensor_resolution


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- i -

  • i2c_attr : cm_cam_sensor_data_t
  • id : cm_cam_sensor_data_t , cm_cam_sensor_module
  • interface_type : cm_cam_sensor_data_t
  • is_lpuart : cm_uart_cfg_t
  • isSetTimeout : cm_fota_extendible_info_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- k -

  • keepalive : cm_mqtt_connect_options_t
  • kernel : osVersion_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- l -

  • lane_num : cm_cam_sensor_data_t
  • last_cellid : cm_radio_info_t
  • last_earfcn : cm_radio_info_t
  • last_ecl : cm_radio_info_t
  • last_pci : cm_radio_info_t
  • last_snr : cm_radio_info_t
  • last_tick : cm_thread_runtime_t
  • latitude : cm_agnss_location_t , cm_gnss_location_info_t , cm_lbs_location_rsp_t
  • len : cm_audio_record_data_t , cm_local_tts_synth_data_t
  • location_describe : cm_lbs_location_rsp_t
  • longitude : cm_agnss_location_t , cm_gnss_location_info_t , cm_lbs_location_rsp_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- m -

  • mask : cm_cam_regval_tab
  • max_continuity_free : cm_heap_stats_t
  • max_fps : cm_cam_sensor_aec_t , cm_cam_sensor_resolution
  • mbus_code : cm_cam_sensor_resolution
  • mcc : cm_cell_info_t
  • method : cm_httpclient_sync_param_t
  • min_fps : cm_cam_sensor_aec_t , cm_cam_sensor_resolution
  • min_vts : cm_cam_sensor_resolution
  • mnc : cm_cell_info_t
  • mode : cm_agnss_location_t , cm_gpio_cfg_t , cm_i2c_cfg_t , cm_spi_cfg_t
  • module : cm_cam_sensor_data_t
  • mp_mem : osMemoryPoolAttr_t
  • mp_size : osMemoryPoolAttr_t
  • mq_mem : osMessageQueueAttr_t
  • mq_size : osMessageQueueAttr_t
  • msg_id : cm_mqtt_topic_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- n -

  • name : cm_cam_sensor_data_t , cm_cam_sensor_module , osEventFlagsAttr_t , osMemoryPoolAttr_t , osMessageQueueAttr_t , osMutexAttr_t , osSemaphoreAttr_t , osThreadAttr_t , osTimerAttr_t
  • nearbts_enable : cm_lbs_amap_location_attr_t , cm_lbs_oneospos_attr_t
  • nsat : cm_gnss_location_info_t
  • nss : cm_spi_cfg_t
  • num : cm_cam_sensor_regs , cm_isp_tuning_data
  • num_channels : cm_audio_sample_param_t
  • num_global : cm_cam_sensor_data_t
  • num_i2c_attr : cm_cam_sensor_data_t
  • num_module : cm_cam_sensor_data_t
  • num_res : cm_cam_sensor_data_t
  • num_tuning_tab : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- o -

  • on : cm_cam_sensor_ata_t
  • ops : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- p -

  • padding : cm_wifi_scan_cell_info_t
  • parity : cm_uart_cfg_t
  • passwd : cm_fota_info_fixed_t , cm_ftp_config_t
  • password : cm_lbs_mantu_location_attr_t , cm_mqtt_connect_options_t
  • path : cm_httpclient_sync_param_t
  • pci : cm_cell_info_t
  • pid : cm_lbs_oneospos_attr_t
  • pingresp_cb : cm_mqtt_client_cb_t
  • pitch : cm_tts_cfg_t
  • platform : cm_lbs_location_rsp_t
  • poi : cm_lbs_location_rsp_t
  • port : cm_ftp_config_t
  • position : cm_cam_sensor_data_t
  • primary_cell : cm_cell_info_t
  • priority : osThreadAttr_t
  • prop : cm_cam_sensor_resolution
  • province : cm_lbs_location_rsp_t
  • puback_cb : cm_mqtt_client_cb_t
  • pubcomp_cb : cm_mqtt_client_cb_t
  • publish_cb : cm_mqtt_client_cb_t
  • pubrec_cb : cm_mqtt_client_cb_t
  • pubrel_cb : cm_mqtt_client_cb_t
  • pull : cm_gpio_cfg_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- q -

  • qos : cm_mqtt_topic_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- r -

  • radius : cm_lbs_location_rsp_t
  • rat : cm_radio_info_t
  • rate : cm_audio_sample_param_t
  • rdn : cm_tts_cfg_t
  • read_crc_value : cm_cam_sensor_ata_t
  • recordFormat : cm_camera_capture_cfg_t , cm_camera_preview_cfg_t
  • reg : cm_cam_regval_tab , cm_isp_tuning_tab
  • reg_len : cm_cam_sensor_i2c_attr
  • regs : cm_cam_sensor_global , cm_cam_sensor_resolution
  • res : cm_cam_sensor_data_t
  • reserved : cm_fota_info_fixed_t , osThreadAttr_t
  • reset_delay : cm_cam_sensor_data_t
  • response_code : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • response_content : cm_httpclient_callback_rsp_content_param_t , cm_httpclient_sync_response_t
  • response_content_len : cm_httpclient_sync_response_t
  • response_header : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • response_header_len : cm_httpclient_callback_rsp_header_param_t , cm_httpclient_sync_response_t
  • rsp_timeout : cm_httpclient_cfg_t
  • rsptimeout : cm_ftp_config_t
  • rsrp : cm_cell_info_t , cm_radio_info_t
  • rsrq : cm_cell_info_t , cm_radio_info_t
  • rssi : cm_cell_info_t , cm_radio_info_t , cm_wifi_scan_cell_info_t
  • rx_time : cm_radio_info_t
  • rxlev : cm_radio_info_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- s -

  • s_power : cm_cam_sensor_spec_ops
  • sample_format : cm_audio_sample_param_t
  • scheduled_cnt : cm_thread_runtime_t
  • second_timeout : cm_fota_reboot_time
  • secretKey : cm_tts_cfg_t
  • sensor_out_format : cm_cam_sensor_global , cm_cam_sensor_resolution
  • sensor_out_yuv : cm_cam_sensor_aec_t
  • set_banding : cm_cam_sensor_spec_ops
  • set_brightness : cm_cam_sensor_spec_ops
  • set_contrast : cm_cam_sensor_spec_ops
  • set_effect : cm_cam_sensor_spec_ops
  • set_saturation : cm_cam_sensor_spec_ops
  • set_wb : cm_cam_sensor_spec_ops
  • show_fields_enable : cm_lbs_amap_location_attr_t
  • sin6_addr : cm_async_dns_ip_addr
  • sin_addr : cm_async_dns_ip_addr
  • sixth_timeout : cm_fota_reboot_time
  • snr : cm_cell_info_t
  • speed : cm_local_tts_cfg_t , cm_tts_cfg_t
  • spi_crc : cm_cam_sensor_data_t
  • spi_sdr : cm_cam_sensor_data_t
  • spkm : cm_gnss_location_info_t
  • spkn : cm_gnss_location_info_t
  • ssl_enable : cm_httpclient_cfg_t
  • ssl_id : cm_ftp_config_t , cm_httpclient_cfg_t
  • ssl_mode : cm_ftp_config_t
  • stack_mem : osThreadAttr_t
  • stack_size : osThreadAttr_t
  • stage : cm_fota_info_fixed_t
  • state : cm_lbs_location_rsp_t , cm_mqtt_topic_t
  • stop_bit : cm_uart_cfg_t
  • streamoff : cm_cam_sensor_data_t
  • streamon : cm_cam_sensor_data_t
  • suback_cb : cm_mqtt_client_cb_t
  • sum_len : cm_httpclient_callback_rsp_content_param_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- t -

  • tab : cm_cam_sensor_regs , cm_isp_tuning_data
  • tac : cm_cell_info_t
  • third_timeout : cm_fota_reboot_time
  • tick_cnt : cm_thread_runtime_t
  • time_out : cm_lbs_amap_location_attr_t , cm_lbs_mantu_location_attr_t , cm_lbs_oneospos_attr_t
  • timeout : cm_fota_extendible_info_t
  • timeout_cb : cm_mqtt_client_cb_t
  • tone : cm_local_tts_cfg_t
  • topic : cm_mqtt_topic_t
  • topic_len : cm_mqtt_topic_t
  • total_len : cm_httpclient_callback_rsp_content_param_t
  • total_size : cm_fs_system_info_t , cm_heap_stats_t , cm_sd_system_info_t
  • trans_mode : cm_ftp_config_t
  • transid : cm_lbs_mantu_location_attr_t
  • tuning_tab : cm_cam_sensor_data_t
  • tx_power : cm_radio_info_t
  • tx_time : cm_radio_info_t
  • type : cm_async_dns_ip_addr
  • tz_module : osThreadAttr_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- u -

  • u_addr : cm_async_dns_ip_addr
  • unsuback_cb : cm_mqtt_client_cb_t
  • update_aec : cm_cam_sensor_spec_ops
  • update_otp : cm_cam_sensor_spec_ops
  • url : cm_fota_info_fixed_t , cm_ftp_config_t , cm_tts_cfg_t
  • user : cm_audio_record_data_t , cm_local_tts_synth_data_t
  • username : cm_fota_info_fixed_t , cm_ftp_config_t , cm_mqtt_connect_options_t
  • usrdata : cm_qr_param_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- v -

  • val : cm_cam_regval_tab , cm_isp_tuning_tab
  • val_len : cm_cam_sensor_i2c_attr
  • vflip : cm_cam_sensor_data_t
  • voice : cm_tts_cfg_t
  • volume : cm_local_tts_cfg_t , cm_tts_cfg_t
  • vts_reg : cm_cam_sensor_data_t


ML305A_ML307A_OpenCPU_API: 成员变量 - 变量

- w -

  • width : cm_cam_sensor_resolution , cm_qr_param_t
  • will_flag : cm_mqtt_connect_options_t
  • will_message : cm_mqtt_connect_options_t
  • will_message_len : cm_mqtt_connect_options_t
  • will_qos : cm_mqtt_connect_options_t
  • will_retain : cm_mqtt_connect_options_t
  • will_topic : cm_mqtt_connect_options_t
  • work_mode : cm_spi_cfg_t


ML305A_ML307A_OpenCPU_API: cm_adc.h 源文件

  • cmiot
cm_adc.h
1
13 #ifndef __CM_ADC_H__
14 #define __CM_ADC_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27
28 /****************************************************************************
29 * Public Types
30 ****************************************************************************/
31
35 typedef enum
36 {
37 CM_ADC_0 = 1,
38 CM_ADC_1,
39 CM_ADC_2,
40 CM_ADC_3,
41 } cm_adc_dev_e;
42
43
44
45 /****************************************************************************
46 * Public Data
47 ****************************************************************************/
48
49
50 /****************************************************************************
51 * Public Function Prototypes
52 ****************************************************************************/
53
54 #ifdef __cplusplus
55 #define EXTERN extern "C"
56 extern "C"
57 {
58 #else
59 #define EXTERN extern
60 #endif
61
62
75 int32_t cm_adc_read(cm_adc_dev_e dev, int32_t *voltage);
76
77 #undef EXTERN
78 #ifdef __cplusplus
79 }
80 #endif
81
82 #endif /* __CM_ADC_H__ */
83
84
cm_adc_read
int32_t cm_adc_read(cm_adc_dev_e dev, int32_t *voltage)
读取ADC电压
cm_adc_dev_e
cm_adc_dev_e
ADC 通道
Definition: cm_adc.h:36
CM_ADC_1
@ CM_ADC_1
Definition: cm_adc.h:38
CM_ADC_0
@ CM_ADC_0
Definition: cm_adc.h:37
CM_ADC_3
@ CM_ADC_3
Definition: cm_adc.h:40
CM_ADC_2
@ CM_ADC_2
Definition: cm_adc.h:39


ML305A_ML307A_OpenCPU_API: cm_asocket.h 源文件

  • cmiot
cm_asocket.h
1
13 #ifndef __CM_ASOCKET_H__
14 #define __CM_ASOCKET_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 // 包含平台特定的socket头文件
22 #include "lwip/sockets.h" // lwip socket
23 #include "cm_eloop.h"
24
25 /****************************************************************************
26 * Pre-processor Definitions
27 ****************************************************************************/
28
29 /****************************************************************************
30 * Public Types
31 ****************************************************************************/
32
34 typedef enum
35 {
36 CM_ASOCKET_EV_NONE = 0,
37 // responses
38 CM_ASOCKET_EV_CONNECT_OK,
39 CM_ASOCKET_EV_CONNECT_FAIL,
40 // indications
41 CM_ASOCKET_EV_RECV_IND,
42 CM_ASOCKET_EV_SEND_IND,
43 CM_ASOCKET_EV_ACCEPT_IND,
44 CM_ASOCKET_EV_ERROR_IND,
45 CM_ASOCKET_EV_SEQ_IND
46 } cm_asocket_event_e;
47
54 typedef void (*cm_asocket_event_cb)(int sock, cm_asocket_event_e event, void *cb_param);
55
56 /****************************************************************************
57 * Public Data
58 ****************************************************************************/
59
60 /****************************************************************************
61 * Public Function Prototypes
62 ****************************************************************************/
63
64 #ifdef __cplusplus
65 #define EXTERN extern "C"
66 extern "C" {
67 #else
68 #define EXTERN extern
69 #endif
70
79 cm_eloop_handle_t cm_asocket_eloop(void);
80
96 int cm_asocket_open(int domain, int type, int protocol,
97 cm_asocket_event_cb event_cb, void *cb_param);
98
112 int cm_asocket_connect(int sock, const struct sockaddr *addr, socklen_t addr_len);
113
125 int cm_asocket_close(int sock);
126
128 #define cm_asocket_bind bind
129 #define cm_asocket_shutdown shutdown
130 #define cm_asocket_getpeername getpeername
131 #define cm_asocket_getsockname getsockname
132 #define cm_asocket_setsockopt setsockopt
133 #define cm_asocket_getsockopt getsockopt
134 #define cm_asocket_recv recv
135 #define cm_asocket_recvmsg recvmsg
136 #define cm_asocket_recvfrom recvfrom
137 #define cm_asocket_send send
138 #define cm_asocket_sendmsg sendmsg
139 #define cm_asocket_sendto sendto
140 #define cm_asocket_ioctl ioctlsocket
141
142 #undef EXTERN
143 #ifdef __cplusplus
144 }
145 #endif
146
147 #endif /* __CM_ASOCKET_H__ */
148
cm_asocket_open
int cm_asocket_open(int domain, int type, int protocol, cm_asocket_event_cb event_cb, void *cb_param)
开启异步socket
cm_asocket_connect
int cm_asocket_connect(int sock, const struct sockaddr *addr, socklen_t addr_len)
异步socket connect操作
cm_asocket_close
int cm_asocket_close(int sock)
关闭异步socket
cm_asocket_event_cb
void(* cm_asocket_event_cb)(int sock, cm_asocket_event_e event, void *cb_param)
Definition: cm_asocket.h:54
cm_asocket_eloop
cm_eloop_handle_t cm_asocket_eloop(void)
获取异步socket模块运行的Event Loop
cm_asocket_event_e
cm_asocket_event_e
Definition: cm_asocket.h:35
CM_ASOCKET_EV_NONE
@ CM_ASOCKET_EV_NONE
Definition: cm_asocket.h:36
CM_ASOCKET_EV_ERROR_IND
@ CM_ASOCKET_EV_ERROR_IND
Definition: cm_asocket.h:44
CM_ASOCKET_EV_CONNECT_FAIL
@ CM_ASOCKET_EV_CONNECT_FAIL
Definition: cm_asocket.h:39
CM_ASOCKET_EV_RECV_IND
@ CM_ASOCKET_EV_RECV_IND
Definition: cm_asocket.h:41
CM_ASOCKET_EV_SEND_IND
@ CM_ASOCKET_EV_SEND_IND
Definition: cm_asocket.h:42
CM_ASOCKET_EV_CONNECT_OK
@ CM_ASOCKET_EV_CONNECT_OK
Definition: cm_asocket.h:38
CM_ASOCKET_EV_SEQ_IND
@ CM_ASOCKET_EV_SEQ_IND
Definition: cm_asocket.h:45
CM_ASOCKET_EV_ACCEPT_IND
@ CM_ASOCKET_EV_ACCEPT_IND
Definition: cm_asocket.h:43
cm_eloop_handle_t
struct cm_eloop_t * cm_eloop_handle_t
Definition: cm_eloop.h:35


ML305A_ML307A_OpenCPU_API: cm_async_dns.h 源文件

  • cmiot
cm_async_dns.h
1
13 #ifndef __CM_ASYNC_DNS_H__
14 #define __CM_ASYNC_DNS_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 // 包含平台特定的socket头文件
22 #include "lwip/sockets.h" // lwip socket
23 #include "cm_eloop.h"
24
25 /****************************************************************************
26 * Pre-processor Definitions
27 ****************************************************************************/
28
29 /****************************************************************************
30 * Public Types
31 ****************************************************************************/
32
34 typedef enum
35 {
36 CM_ASYNC_DNS_ADDRTYPE_IPV4 = 0,
37 CM_ASYNC_DNS_ADDRTYPE_IPV6,
38 CM_ASYNC_DNS_ADDRTYPE_IPV4_IPV6,
39 CM_ASYNC_DNS_ADDRTYPE_IPV6_IPV4,
40 } cm_async_dns_addrtype_e;
41
43 typedef enum
44 {
45 CM_ASYNC_DNS_EV_NONE = 0,
46 // responses
47 CM_ASYNC_DNS_RESOLVE_OK,
48 CM_ASYNC_DNS_RESOLVE_FAIL,
49 } cm_async_dns_event_e;
50
52 typedef struct cm_async_dns_ip_addr
53 {
54 cm_async_dns_addrtype_e type;
55 union {
56 struct in_addr sin_addr;
57 struct in6_addr sin6_addr;
58 } u_addr;
59 } cm_async_dns_ip_addr_t;
60
69 typedef void (*cm_async_dns_event_cb)(int req_id, cm_async_dns_event_e event, void *cb_param,
70 const char *host_name, const cm_async_dns_ip_addr_t *ip_addr);
71
72 /****************************************************************************
73 * Public Data
74 ****************************************************************************/
75
76 /****************************************************************************
77 * Public Function Prototypes
78 ****************************************************************************/
79
80 #ifdef __cplusplus
81 #define EXTERN extern "C"
82 extern "C" {
83 #else
84 #define EXTERN extern
85 #endif
86
95 cm_eloop_handle_t cm_async_dns_eloop(void);
96
108 int32_t cm_async_dns_set_priority(uint8_t priority);
109
126 int cm_async_dns_request(const char *host_name, cm_async_dns_addrtype_e addr_type,
127 cm_async_dns_ip_addr_t *ip_addr, cm_async_dns_event_cb event_cb, void *cb_param);
128
129 #undef EXTERN
130 #ifdef __cplusplus
131 }
132 #endif
133
134 #endif /* __CM_ASYNC_DNS_H__ */
135
cm_async_dns_event_cb
void(* cm_async_dns_event_cb)(int req_id, cm_async_dns_event_e event, void *cb_param, const char *host_name, const cm_async_dns_ip_addr_t *ip_addr)
Definition: cm_async_dns.h:69
cm_async_dns_event_e
cm_async_dns_event_e
Definition: cm_async_dns.h:44
cm_async_dns_addrtype_e
cm_async_dns_addrtype_e
Definition: cm_async_dns.h:35
cm_async_dns_eloop
cm_eloop_handle_t cm_async_dns_eloop(void)
获取异步dns模块运行的Event Loop
cm_async_dns_ip_addr_t
struct cm_async_dns_ip_addr cm_async_dns_ip_addr_t
cm_async_dns_set_priority
int32_t cm_async_dns_set_priority(uint8_t priority)
设置DNS解析全局优先级
cm_async_dns_request
int cm_async_dns_request(const char *host_name, cm_async_dns_addrtype_e addr_type, cm_async_dns_ip_addr_t *ip_addr, cm_async_dns_event_cb event_cb, void *cb_param)
请求执行异步DNS解析
CM_ASYNC_DNS_EV_NONE
@ CM_ASYNC_DNS_EV_NONE
Definition: cm_async_dns.h:45
CM_ASYNC_DNS_RESOLVE_FAIL
@ CM_ASYNC_DNS_RESOLVE_FAIL
Definition: cm_async_dns.h:48
CM_ASYNC_DNS_RESOLVE_OK
@ CM_ASYNC_DNS_RESOLVE_OK
Definition: cm_async_dns.h:47
CM_ASYNC_DNS_ADDRTYPE_IPV6
@ CM_ASYNC_DNS_ADDRTYPE_IPV6
Definition: cm_async_dns.h:37
CM_ASYNC_DNS_ADDRTYPE_IPV4_IPV6
@ CM_ASYNC_DNS_ADDRTYPE_IPV4_IPV6
Definition: cm_async_dns.h:38
CM_ASYNC_DNS_ADDRTYPE_IPV6_IPV4
@ CM_ASYNC_DNS_ADDRTYPE_IPV6_IPV4
Definition: cm_async_dns.h:39
CM_ASYNC_DNS_ADDRTYPE_IPV4
@ CM_ASYNC_DNS_ADDRTYPE_IPV4
Definition: cm_async_dns.h:36
cm_eloop_handle_t
struct cm_eloop_t * cm_eloop_handle_t
Definition: cm_eloop.h:35
cm_async_dns_ip_addr
Definition: cm_async_dns.h:53
cm_async_dns_ip_addr::sin_addr
struct in_addr sin_addr
Definition: cm_async_dns.h:56
cm_async_dns_ip_addr::type
cm_async_dns_addrtype_e type
Definition: cm_async_dns.h:54
cm_async_dns_ip_addr::u_addr
union cm_async_dns_ip_addr::@0 u_addr
cm_async_dns_ip_addr::sin6_addr
struct in6_addr sin6_addr
Definition: cm_async_dns.h:57


ML305A_ML307A_OpenCPU_API: cm_audio_common.h 源文件

  • cmiot
cm_audio_common.h
1
13 #ifndef __OPENCPU_AUDIO_COMMON_H__
14 #define __OPENCPU_AUDIO_COMMON_H__
15 /****************************************************************************
16 * Included Files
17 ****************************************************************************/
18
19 #include <stdint.h>
20
21 /****************************************************************************
22 * Pre-processor Definitions
23 ****************************************************************************/
24
25 /****************************************************************************
26 * Public Types
27 ****************************************************************************/
28
30 typedef enum
31 {
32 CM_AUDIO_PLAY_FORMAT_PCM = 1,
33 CM_AUDIO_PLAY_FORMAT_WAV,
34 CM_AUDIO_PLAY_FORMAT_MP3 = 3,
35 CM_AUDIO_PLAY_FORMAT_AMRNB,
36 #if 0
37 CM_AUDIO_PLAY_FORMAT_AMRWB,
38 CM_AUDIO_PLAY_FORMAT_FR,
39 CM_AUDIO_PLAY_FORMAT_HR,
40 CM_AUDIO_PLAY_FORMAT_EFR,
41 CM_AUDIO_PLAY_FORMAT_AAC,
42 CM_AUDIO_PLAY_FORMAT_MID,
43 CM_AUDIO_PLAY_FORMAT_QTY,
44 #endif
45 } cm_audio_play_format_e;
46
48 typedef enum
49 {
50 CM_AUDIO_RECORD_FORMAT_PCM = 1,
51 #if 0
52 CM_AUDIO_RECORD_FORMAT_WAVPCM,
53 CM_AUDIO_RECORD_FORMAT_MP3,
54 #endif
55 CM_AUDIO_RECORD_FORMAT_AMRNB_475 = 4,
56 CM_AUDIO_RECORD_FORMAT_AMRNB_515,
57 CM_AUDIO_RECORD_FORMAT_AMRNB_590,
58 CM_AUDIO_RECORD_FORMAT_AMRNB_670,
59 CM_AUDIO_RECORD_FORMAT_AMRNB_740,
60 CM_AUDIO_RECORD_FORMAT_AMRNB_795,
61 CM_AUDIO_RECORD_FORMAT_AMRNB_1020,
62 CM_AUDIO_RECORD_FORMAT_AMRNB_1220,
63 #if 0
64 CM_AUDIO_RECORD_FORMAT_AMRWB_660,
65 CM_AUDIO_RECORD_FORMAT_AMRWB_885,
66 CM_AUDIO_RECORD_FORMAT_AMRWB_1265,
67 CM_AUDIO_RECORD_FORMAT_AMRWB_1425,
68 CM_AUDIO_RECORD_FORMAT_AMRWB_1585,
69 CM_AUDIO_RECORD_FORMAT_AMRWB_1825,
70 CM_AUDIO_RECORD_FORMAT_AMRWB_1985,
71 CM_AUDIO_RECORD_FORMAT_AMRWB_2305,
72 CM_AUDIO_RECORD_FORMAT_AMRWB_2385,
73 #endif
74 } cm_audio_record_format_e;
75
77 typedef enum
78 {
79 CM_AUDIO_SAMPLE_FORMAT_8BIT = 1,
80 CM_AUDIO_SAMPLE_FORMAT_16BIT,
81 CM_AUDIO_SAMPLE_FORMAT_24BIT,
82 CM_AUDIO_SAMPLE_FORMAT_32BIT,
83 } cm_audio_sample_format_e;
84
86 typedef enum
87 {
88 CM_AUDIO_SAMPLE_RATE_8000HZ = 8000,
89 #if 0
90 CM_AUDIO_SAMPLE_RATE_9600HZ = 9600,
91 #endif
92 CM_AUDIO_SAMPLE_RATE_11025HZ = 11025,
93 CM_AUDIO_SAMPLE_RATE_12000HZ = 12000,
94 CM_AUDIO_SAMPLE_RATE_16000HZ = 16000,
95 CM_AUDIO_SAMPLE_RATE_22050HZ = 22050,
96 CM_AUDIO_SAMPLE_RATE_24000HZ = 24000,
97 CM_AUDIO_SAMPLE_RATE_32000HZ = 32000,
98 CM_AUDIO_SAMPLE_RATE_44100HZ = 44100,
99 CM_AUDIO_SAMPLE_RATE_48000HZ = 48000,
100 CM_AUDIO_SAMPLE_RATE_96000HZ = 96000,
101 #if 0
102 CM_AUDIO_SAMPLE_RATE_128000HZ = 128000,
103 #endif
104 } cm_audio_sample_rate_e;
105
107 typedef enum
108 {
109 CM_AUDIO_SOUND_MONO = 1,
110 CM_AUDIO_SOUND_STEREO = 2,
111 } cm_audio_sound_channel_e;
112
114 typedef struct
115 {
116 cm_audio_sample_format_e sample_format;
117 cm_audio_sample_rate_e rate;
118 cm_audio_sound_channel_e num_channels;
119 } cm_audio_sample_param_t;
120
121 #undef EXTERN
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif
cm_audio_record_format_e
cm_audio_record_format_e
Definition: cm_audio_common.h:49
cm_audio_play_format_e
cm_audio_play_format_e
Definition: cm_audio_common.h:31
cm_audio_sample_format_e
cm_audio_sample_format_e
Definition: cm_audio_common.h:78
cm_audio_sample_rate_e
cm_audio_sample_rate_e
Definition: cm_audio_common.h:87
cm_audio_sound_channel_e
cm_audio_sound_channel_e
Definition: cm_audio_common.h:108
CM_AUDIO_RECORD_FORMAT_AMRNB_475
@ CM_AUDIO_RECORD_FORMAT_AMRNB_475
Definition: cm_audio_common.h:55
CM_AUDIO_RECORD_FORMAT_AMRNB_515
@ CM_AUDIO_RECORD_FORMAT_AMRNB_515
Definition: cm_audio_common.h:56
CM_AUDIO_RECORD_FORMAT_AMRNB_1220
@ CM_AUDIO_RECORD_FORMAT_AMRNB_1220
Definition: cm_audio_common.h:62
CM_AUDIO_RECORD_FORMAT_AMRNB_795
@ CM_AUDIO_RECORD_FORMAT_AMRNB_795
Definition: cm_audio_common.h:60
CM_AUDIO_RECORD_FORMAT_AMRNB_590
@ CM_AUDIO_RECORD_FORMAT_AMRNB_590
Definition: cm_audio_common.h:57
CM_AUDIO_RECORD_FORMAT_PCM
@ CM_AUDIO_RECORD_FORMAT_PCM
Definition: cm_audio_common.h:50
CM_AUDIO_RECORD_FORMAT_AMRNB_670
@ CM_AUDIO_RECORD_FORMAT_AMRNB_670
Definition: cm_audio_common.h:58
CM_AUDIO_RECORD_FORMAT_AMRNB_1020
@ CM_AUDIO_RECORD_FORMAT_AMRNB_1020
Definition: cm_audio_common.h:61
CM_AUDIO_RECORD_FORMAT_AMRNB_740
@ CM_AUDIO_RECORD_FORMAT_AMRNB_740
Definition: cm_audio_common.h:59
CM_AUDIO_PLAY_FORMAT_WAV
@ CM_AUDIO_PLAY_FORMAT_WAV
Definition: cm_audio_common.h:33
CM_AUDIO_PLAY_FORMAT_PCM
@ CM_AUDIO_PLAY_FORMAT_PCM
Definition: cm_audio_common.h:32
CM_AUDIO_PLAY_FORMAT_MP3
@ CM_AUDIO_PLAY_FORMAT_MP3
Definition: cm_audio_common.h:34
CM_AUDIO_PLAY_FORMAT_AMRNB
@ CM_AUDIO_PLAY_FORMAT_AMRNB
Definition: cm_audio_common.h:35
CM_AUDIO_SAMPLE_FORMAT_8BIT
@ CM_AUDIO_SAMPLE_FORMAT_8BIT
Definition: cm_audio_common.h:79
CM_AUDIO_SAMPLE_FORMAT_16BIT
@ CM_AUDIO_SAMPLE_FORMAT_16BIT
Definition: cm_audio_common.h:80
CM_AUDIO_SAMPLE_FORMAT_32BIT
@ CM_AUDIO_SAMPLE_FORMAT_32BIT
Definition: cm_audio_common.h:82
CM_AUDIO_SAMPLE_FORMAT_24BIT
@ CM_AUDIO_SAMPLE_FORMAT_24BIT
Definition: cm_audio_common.h:81
CM_AUDIO_SAMPLE_RATE_96000HZ
@ CM_AUDIO_SAMPLE_RATE_96000HZ
Definition: cm_audio_common.h:100
CM_AUDIO_SAMPLE_RATE_11025HZ
@ CM_AUDIO_SAMPLE_RATE_11025HZ
Definition: cm_audio_common.h:92
CM_AUDIO_SAMPLE_RATE_32000HZ
@ CM_AUDIO_SAMPLE_RATE_32000HZ
Definition: cm_audio_common.h:97
CM_AUDIO_SAMPLE_RATE_48000HZ
@ CM_AUDIO_SAMPLE_RATE_48000HZ
Definition: cm_audio_common.h:99
CM_AUDIO_SAMPLE_RATE_8000HZ
@ CM_AUDIO_SAMPLE_RATE_8000HZ
Definition: cm_audio_common.h:88
CM_AUDIO_SAMPLE_RATE_12000HZ
@ CM_AUDIO_SAMPLE_RATE_12000HZ
Definition: cm_audio_common.h:93
CM_AUDIO_SAMPLE_RATE_22050HZ
@ CM_AUDIO_SAMPLE_RATE_22050HZ
Definition: cm_audio_common.h:95
CM_AUDIO_SAMPLE_RATE_16000HZ
@ CM_AUDIO_SAMPLE_RATE_16000HZ
Definition: cm_audio_common.h:94
CM_AUDIO_SAMPLE_RATE_44100HZ
@ CM_AUDIO_SAMPLE_RATE_44100HZ
Definition: cm_audio_common.h:98
CM_AUDIO_SAMPLE_RATE_24000HZ
@ CM_AUDIO_SAMPLE_RATE_24000HZ
Definition: cm_audio_common.h:96
CM_AUDIO_SOUND_STEREO
@ CM_AUDIO_SOUND_STEREO
Definition: cm_audio_common.h:110
CM_AUDIO_SOUND_MONO
@ CM_AUDIO_SOUND_MONO
Definition: cm_audio_common.h:109
cm_audio_sample_param_t
Definition: cm_audio_common.h:115
cm_audio_sample_param_t::sample_format
cm_audio_sample_format_e sample_format
Definition: cm_audio_common.h:116
cm_audio_sample_param_t::rate
cm_audio_sample_rate_e rate
Definition: cm_audio_common.h:117
cm_audio_sample_param_t::num_channels
cm_audio_sound_channel_e num_channels
Definition: cm_audio_common.h:118


ML305A_ML307A_OpenCPU_API: cm_audio_player.h 源文件

  • cmiot
cm_audio_player.h
1
13 #ifndef __OPENCPU_AUDIO_PLAYER_H__
14 #define __OPENCPU_AUDIO_PLAYER_H__
15
16
17 /****************************************************************************
18 * Included Files
19 ****************************************************************************/
20
21 #include "cm_audio_common.h"
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27
28 /****************************************************************************
29 * Public Types
30 ****************************************************************************/
31
33 typedef enum
34 {
35 CM_AUDIO_PLAY_CHANNEL_RECEIVER = 1,
36 CM_AUDIO_PLAY_CHANNEL_HEADSET,
37 CM_AUDIO_PLAY_CHANNEL_SPEAKER,
38 #if 0
39 CM_AUDIO_PLAY_CHANNEL_REMOTE,
40 #endif
41 } cm_audio_play_channel_e;
42
44 typedef enum
45 {
46 CM_AUDIO_PLAY_EVENT_FINISHED = 1,
47 #if 0
48 CM_AUDIO_PLAY_EVENT_INTERRUPT,
49 #endif
50 } cm_audio_play_event_e;
51
53 typedef enum
54 {
55 CM_AUDIO_PLAY_CFG_CHANNEL = 1,
56 CM_AUDIO_PLAY_CFG_VOLUME,
57 } cm_audio_play_cfg_type_e;
58
59
60 /****************************************************************************
61 * Public Data
62 ****************************************************************************/
63
64
65 /****************************************************************************
66 * Public Function Prototypes
67 ****************************************************************************/
68
69 #ifdef __cplusplus
70 #define EXTERN extern "C"
71 extern "C"
72 {
73 #else
74 #define EXTERN extern
75 #endif
76
86 typedef void (*cm_audio_play_callback_t)(cm_audio_play_event_e event, void *param);
87
88
102 int32_t cm_audio_play_set_cfg(cm_audio_play_cfg_type_e type, void *value);
103
117 int32_t cm_audio_play_get_cfg(cm_audio_play_cfg_type_e type, void *value);
118
136 int32_t cm_audio_play_file(const char *path, cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_play_callback_t cb, void *cb_param);
137
148 int32_t cm_audio_player_pause(void);
149
159 int32_t cm_audio_player_resume(void);
160
171 int32_t cm_audio_player_stop(void);
172
186 int32_t cm_audio_player_stream_open(cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param);
187
203 int32_t cm_audio_player_stream_push(uint8_t *data, uint32_t size);
204
210 void cm_audio_player_stream_close(void);
211
212 #undef EXTERN
213 #ifdef __cplusplus
214 }
215 #endif
216
217 #endif
218
cm_audio_play_format_e
cm_audio_play_format_e
Definition: cm_audio_common.h:31
cm_audio_play_channel_e
cm_audio_play_channel_e
Definition: cm_audio_player.h:34
cm_audio_play_file
int32_t cm_audio_play_file(const char *path, cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_play_callback_t cb, void *cb_param)
从文件系统播放音频文件
cm_audio_play_get_cfg
int32_t cm_audio_play_get_cfg(cm_audio_play_cfg_type_e type, void *value)
读取播放参数
cm_audio_play_cfg_type_e
cm_audio_play_cfg_type_e
Definition: cm_audio_player.h:54
cm_audio_play_set_cfg
int32_t cm_audio_play_set_cfg(cm_audio_play_cfg_type_e type, void *value)
设置播放参数
cm_audio_player_stream_open
int32_t cm_audio_player_stream_open(cm_audio_play_format_e format, cm_audio_sample_param_t *sample_param)
从管道/消息队列中播放音频（开启）
cm_audio_player_resume
int32_t cm_audio_player_resume(void)
继续播放
cm_audio_player_stream_push
int32_t cm_audio_player_stream_push(uint8_t *data, uint32_t size)
往管道/消息队列中发送要播放的音频数据
cm_audio_play_callback_t
void(* cm_audio_play_callback_t)(cm_audio_play_event_e event, void *param)
播放回调函数
Definition: cm_audio_player.h:86
cm_audio_player_pause
int32_t cm_audio_player_pause(void)
暂停播放
cm_audio_player_stream_close
void cm_audio_player_stream_close(void)
从管道/消息队列中播放音频（关闭）
cm_audio_player_stop
int32_t cm_audio_player_stop(void)
停止播放
cm_audio_play_event_e
cm_audio_play_event_e
Definition: cm_audio_player.h:45
CM_AUDIO_PLAY_CHANNEL_SPEAKER
@ CM_AUDIO_PLAY_CHANNEL_SPEAKER
Definition: cm_audio_player.h:37
CM_AUDIO_PLAY_CHANNEL_HEADSET
@ CM_AUDIO_PLAY_CHANNEL_HEADSET
Definition: cm_audio_player.h:36
CM_AUDIO_PLAY_CHANNEL_RECEIVER
@ CM_AUDIO_PLAY_CHANNEL_RECEIVER
Definition: cm_audio_player.h:35
CM_AUDIO_PLAY_CFG_VOLUME
@ CM_AUDIO_PLAY_CFG_VOLUME
Definition: cm_audio_player.h:56
CM_AUDIO_PLAY_CFG_CHANNEL
@ CM_AUDIO_PLAY_CFG_CHANNEL
Definition: cm_audio_player.h:55
CM_AUDIO_PLAY_EVENT_FINISHED
@ CM_AUDIO_PLAY_EVENT_FINISHED
Definition: cm_audio_player.h:46
cm_audio_sample_param_t
Definition: cm_audio_common.h:115


ML305A_ML307A_OpenCPU_API: cm_audio_recorder.h 源文件

  • cmiot
cm_audio_recorder.h
1
13 #ifndef __OPENCPU_AUDIO_RECORDER_H__
14 #define __OPENCPU_AUDIO_RECORDER_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 #include "cm_audio_common.h"
22
23
24 /****************************************************************************
25 * Pre-processor Definitions
26 ****************************************************************************/
27
28
29 /****************************************************************************
30 * Public Types
31 ****************************************************************************/
32
34 typedef enum
35 {
36 CM_AUDIO_RECORD_CHANNEL_MAIN = 1,
37 CM_AUDIO_RECORD_CHANNEL_HP,
38 #if 0
39 CM_AUDIO_RECORD_CHANNEL_REMOTE,
40 #endif
41 } cm_audio_record_channel_e;
42
44 typedef enum
45 {
46 CM_AUDIO_RECORD_EVENT_DATA = 1,
47 #if 0
48 CM_AUDIO_RECORD_EVENT_FINISHED,
49 CM_AUDIO_RECORD_EVENT_INTERRUPT,
50 #endif
51 } cm_audio_record_event_e;
52
54 typedef enum
55 {
56 CM_AUDIO_RECORD_CFG_CHANNEL = 1,
57 CM_AUDIO_RECORD_CFG_GAIN,
58 } cm_audio_record_cfg_type_e;
59
60 /*
61 * 录音数据结构体
62 */
63 typedef struct
64 {
65 uint8_t *data;
66 uint32_t len;
67 void *user;
68 } cm_audio_record_data_t;
69
70 /****************************************************************************
71 * Public Data
72 ****************************************************************************/
73
74
75 /****************************************************************************
76 * Public Function Prototypes
77 ****************************************************************************/
78
79 #ifdef __cplusplus
80 #define EXTERN extern "C"
81 extern "C"
82 {
83 #else
84 #define EXTERN extern
85 #endif
86
96 typedef void (*cm_audio_record_callback_t)(cm_audio_record_event_e event, void *param);
97
117 int32_t cm_audio_record_set_cfg(cm_audio_record_cfg_type_e type, void *value);
118
138 int32_t cm_audio_record_get_cfg(cm_audio_record_cfg_type_e type, void *value);
139
156 int32_t cm_audio_recorder_start(cm_audio_record_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_record_callback_t cb, void *cb_param);
157
163 void cm_audio_recorder_stop(void);
164
165 #undef EXTERN
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif
171
cm_audio_record_format_e
cm_audio_record_format_e
Definition: cm_audio_common.h:49
cm_audio_recorder_start
int32_t cm_audio_recorder_start(cm_audio_record_format_e format, cm_audio_sample_param_t *sample_param, cm_audio_record_callback_t cb, void *cb_param)
开始录音
cm_audio_record_callback_t
void(* cm_audio_record_callback_t)(cm_audio_record_event_e event, void *param)
录音回调函数
Definition: cm_audio_recorder.h:96
cm_audio_record_cfg_type_e
cm_audio_record_cfg_type_e
Definition: cm_audio_recorder.h:55
cm_audio_record_channel_e
cm_audio_record_channel_e
Definition: cm_audio_recorder.h:35
cm_audio_record_event_e
cm_audio_record_event_e
Definition: cm_audio_recorder.h:45
cm_audio_record_get_cfg
int32_t cm_audio_record_get_cfg(cm_audio_record_cfg_type_e type, void *value)
读取录音参数
cm_audio_recorder_stop
void cm_audio_recorder_stop(void)
结束录音
cm_audio_record_set_cfg
int32_t cm_audio_record_set_cfg(cm_audio_record_cfg_type_e type, void *value)
设置录音参数
CM_AUDIO_RECORD_CFG_CHANNEL
@ CM_AUDIO_RECORD_CFG_CHANNEL
Definition: cm_audio_recorder.h:56
CM_AUDIO_RECORD_CFG_GAIN
@ CM_AUDIO_RECORD_CFG_GAIN
Definition: cm_audio_recorder.h:57
CM_AUDIO_RECORD_CHANNEL_HP
@ CM_AUDIO_RECORD_CHANNEL_HP
Definition: cm_audio_recorder.h:37
CM_AUDIO_RECORD_CHANNEL_MAIN
@ CM_AUDIO_RECORD_CHANNEL_MAIN
Definition: cm_audio_recorder.h:36
CM_AUDIO_RECORD_EVENT_DATA
@ CM_AUDIO_RECORD_EVENT_DATA
Definition: cm_audio_recorder.h:46
cm_audio_record_data_t
Definition: cm_audio_recorder.h:64
cm_audio_record_data_t::user
void * user
Definition: cm_audio_recorder.h:67
cm_audio_record_data_t::len
uint32_t len
Definition: cm_audio_recorder.h:66
cm_audio_record_data_t::data
uint8_t * data
Definition: cm_audio_recorder.h:65
cm_audio_sample_param_t
Definition: cm_audio_common.h:115


ML305A_ML307A_OpenCPU_API: cm_camera.h 源文件

  • cmiot
cm_camera.h
1
13 #ifndef __CM_CAMERA_H__
14 #define __CM_CAMERA_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27 /****************************************************************************
28 * Public Types
29 ****************************************************************************/
30
34 typedef enum
35 {
36 CAM_OUT_FMT_YUV422_YUYV = 0,
37 CAM_OUT_FMT_YUV422_YVYU,
38 CAM_OUT_FMT_YUV422_UYVY,
39 CAM_OUT_FMT_YUV422_VYUY,
40 CAM_OUT_FMT_YUV420_NV12 = 6,
41 CAM_OUT_FMT_RAW8 = 10,
42 }cm_camera_out_fmt_e;
43
47 typedef struct {
48 cm_camera_out_fmt_e recordFormat;
49 void (*enqueueCamRecordBuffer)(void *pBuf, uint32_t len);
50 void (*flushCamRecordBuffers)(void);
51 }cm_camera_preview_cfg_t;
52
56 typedef struct {
57 cm_camera_out_fmt_e recordFormat;
58 uint8_t *file_name;
59 }cm_camera_capture_cfg_t;
60
61 /****************************************************************************
62 * Public Data
63 ****************************************************************************/
64
65
66 /****************************************************************************
67 * Public Function Prototypes
68 ****************************************************************************/
69
70 #ifdef __cplusplus
71 #define EXTERN extern "C"
72 extern "C"
73 {
74 #else
75 #define EXTERN extern
76 #endif
77
88 int32_t cm_camera_get_info(uint32_t *width, uint32_t *height);
89
97 int32_t cm_camera_open(void);
98
106 int32_t cm_camera_close(void);
107
118 int32_t cm_camera_preview_start(cm_camera_preview_cfg_t *cfg);
119
127 int32_t cm_camera_preview_stop(void);
128
138 int32_t cm_camera_capture_take(cm_camera_capture_cfg_t *cfg);
139
140 #undef EXTERN
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif /* __CM_CAMERA_H__ */
146
147
cm_camera_get_info
int32_t cm_camera_get_info(uint32_t *width, uint32_t *height)
获取底层驱动输出大小
cm_camera_out_fmt_e
cm_camera_out_fmt_e
camera数据输出类型
Definition: cm_camera.h:35
cm_camera_open
int32_t cm_camera_open(void)
打开相机
cm_camera_close
int32_t cm_camera_close(void)
关闭相机
cm_camera_preview_stop
int32_t cm_camera_preview_stop(void)
关闭预览
cm_camera_capture_take
int32_t cm_camera_capture_take(cm_camera_capture_cfg_t *cfg)
拍照
cm_camera_preview_start
int32_t cm_camera_preview_start(cm_camera_preview_cfg_t *cfg)
开始预览
CAM_OUT_FMT_YUV420_NV12
@ CAM_OUT_FMT_YUV420_NV12
Definition: cm_camera.h:40
CAM_OUT_FMT_RAW8
@ CAM_OUT_FMT_RAW8
Definition: cm_camera.h:41
CAM_OUT_FMT_YUV422_YVYU
@ CAM_OUT_FMT_YUV422_YVYU
Definition: cm_camera.h:37
CAM_OUT_FMT_YUV422_UYVY
@ CAM_OUT_FMT_YUV422_UYVY
Definition: cm_camera.h:38
CAM_OUT_FMT_YUV422_VYUY
@ CAM_OUT_FMT_YUV422_VYUY
Definition: cm_camera.h:39
CAM_OUT_FMT_YUV422_YUYV
@ CAM_OUT_FMT_YUV422_YUYV
Definition: cm_camera.h:36
cm_camera_capture_cfg_t
camera拍照接口配置参数
Definition: cm_camera.h:56
cm_camera_capture_cfg_t::file_name
uint8_t * file_name
Definition: cm_camera.h:58
cm_camera_capture_cfg_t::recordFormat
cm_camera_out_fmt_e recordFormat
Definition: cm_camera.h:57
cm_camera_preview_cfg_t
camera预览接口配置参数
Definition: cm_camera.h:47
cm_camera_preview_cfg_t::recordFormat
cm_camera_out_fmt_e recordFormat
Definition: cm_camera.h:48


ML305A_ML307A_OpenCPU_API: cm_camera_sensor.h 源文件

  • cmiot
cm_camera_sensor.h
1
13 #ifndef __CM_CAMERA_SENSOR_H__
14 #define __CM_CAMERA_SENSOR_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26 /* raw8 */
27 #define MEDIA_BUS_FMT_SBGGR8_1X8 0x3001
28 #define MEDIA_BUS_FMT_SGBRG8_1X8 0x3013
29 #define MEDIA_BUS_FMT_SGRBG8_1X8 0x3002
30 #define MEDIA_BUS_FMT_SRGGB8_1X8 0x3014
31 /* raw10 */
32 #define MEDIA_BUS_FMT_SBGGR10_1X10 0x3007
33 #define MEDIA_BUS_FMT_SGBRG10_1X10 0x300e
34 #define MEDIA_BUS_FMT_SGRBG10_1X10 0x300a
35 #define MEDIA_BUS_FMT_SRGGB10_1X10 0x300f
36 /* yuv422 */
37 #define MEDIA_BUS_FMT_UYVY8_2X8 0x2006
38 #define MEDIA_BUS_FMT_VYUY8_2X8 0x2007
39 #define MEDIA_BUS_FMT_YUYV8_2X8 0x2008
40 #define MEDIA_BUS_FMT_YVYU8_2X8 0x2009
41
42 /****************************************************************************
43 * Public Types
44 ****************************************************************************/
45
49 typedef struct {
50 uint32_t on;
51 int32_t read_crc_value;
52 }cm_cam_sensor_ata_t;
53
57 typedef enum{
58 CAM_BANDING_50HZ = 0,
59 CAM_BANDING_60HZ = 1,
60 CAM_BANDING_AUTO = 2,
61 } cm_cam_sensor_banding;
62
66 typedef struct {
67 uint32_t exp_high;
68 uint32_t exp_low;
69 uint32_t gain;
70 uint32_t aec_en;
71 uint32_t min_fps;
72 uint32_t max_fps;
73 cm_cam_sensor_banding banding;
74 uint32_t sensor_out_yuv;
75 } cm_cam_sensor_aec_t;
76
82 typedef struct {
83 int32_t *get_pixel_rate;
84 int32_t *get_dphy_desc;
85 int32_t *update_otp;
86 int32_t (*s_power)(int32_t onoff);
87 int32_t (*ata_open)(cm_cam_sensor_ata_t *ata);
88 int32_t (*update_aec)(cm_cam_sensor_aec_t *aec);
89 int32_t *set_effect;
90 int32_t *set_brightness;
91 int32_t *set_contrast;
92 int32_t *set_wb;
93 int32_t *set_saturation;
94 int32_t *set_banding;
95 }cm_cam_sensor_spec_ops;
96
100 typedef enum {
101 CAM_I2C_8BIT = 0,
102 CAM_I2C_16BIT,
103 CAM_I2C_32BIT
104 }cm_cam_sensor_i2c_len;
105
109 typedef struct {
110 uint16_t reg;
111 uint16_t val;
112 uint16_t mask;
113 }cm_cam_regval_tab;
114
118 typedef struct {
119 const cm_cam_regval_tab *tab;
120 uint32_t num;
121 }cm_cam_sensor_regs;
122
126 typedef struct {
127 cm_cam_sensor_i2c_len reg_len;
128 cm_cam_sensor_i2c_len val_len;
129 uint8_t addr;
130 }cm_cam_sensor_i2c_attr;
131
135 typedef struct {
136 cm_cam_sensor_regs regs;
137 int32_t sensor_out_format;
138 }cm_cam_sensor_global;
139
143 typedef enum {
144 CAM_SENSOR_RES_BINING1,
145 CAM_SENSOR_RES_BINING2,
146 CAM_SENSOR_RES_CROPPED,
147 CAM_SENSOR_RES_MAX,
148 }cm_cam_sensor_res_prop;
149
153 typedef enum {
154 CAM_SENSOR_FMT_RAW8 = 0,
155 CAM_SENSOR_FMT_ONLY_Y,
156 CAM_SENSOR_FMT_RAW10,
157 CAM_SENSOR_FMT_RAW12,
158 CAM_SENSOR_FMT_YUV422,
159 } cm_cam_sensor_fmt;
160
164 typedef struct {
165 uint32_t sensor_out_format;
166 uint16_t mbus_code;
167 uint16_t width;
168 uint16_t height;
169 uint32_t hts;
170 uint32_t min_vts;
171 uint8_t max_fps;
172 uint8_t min_fps;
173 cm_cam_sensor_res_prop prop;
174 cm_cam_sensor_regs regs;
175 }cm_cam_sensor_resolution;
176
180 typedef struct {
181 uint32_t id;
182 char *name;/* as module id send to userspace, limit the size to 7 characters*/
183 uint32_t apeture_size;
184 }cm_cam_sensor_module;
185
189 typedef struct {
190 uint16_t reg;
191 uint16_t val;
192 }cm_isp_tuning_tab;
193
197 typedef struct {
198 cm_isp_tuning_tab *tab;
199 uint32_t num;
200 }cm_isp_tuning_data;
201
205 typedef struct {
206 char * const name;
207 cm_cam_sensor_spec_ops *ops;
208 int32_t position;
209 cm_cam_sensor_i2c_attr *i2c_attr;
210 int32_t num_i2c_attr;
211 cm_cam_sensor_regs id;
212 cm_cam_sensor_global *global_setting;
213 int32_t num_global;
214 cm_cam_sensor_resolution *res;
215 int32_t num_res;
216 cm_cam_sensor_regs streamon;
217 cm_cam_sensor_regs streamoff;
218 cm_cam_sensor_regs expo_reg;
219 cm_cam_sensor_regs vts_reg;
220 cm_cam_sensor_regs gain_reg;
221 cm_cam_sensor_regs hflip;
222 cm_cam_sensor_regs vflip;
223 cm_cam_sensor_module *module;
224 int32_t num_module;
225 cm_isp_tuning_tab *tuning_tab;
226 int32_t num_tuning_tab;
227 cm_isp_tuning_data banding_tab[2];
228 int32_t interface_type;
229 uint8_t lane_num;
230 uint8_t spi_sdr;
231 uint8_t spi_crc;
232 int32_t reset_delay;
233 int32_t cur_i2c_index;
234 int32_t cur_res_index;
235 }cm_cam_sensor_data_t;
236
237 /****************************************************************************
238 * Public Data
239 ****************************************************************************/
240
241
242 /****************************************************************************
243 * Public Function Prototypes
244 ****************************************************************************/
245
246 #ifdef __cplusplus
247 #define EXTERN extern "C"
248 extern "C"
249 {
250 #else
251 #define EXTERN extern
252 #endif
253
254
264 void cm_camera_sensor_set_mclk(int32_t enable);
265
275 void cm_camera_sensor_set_data(cm_cam_sensor_data_t *data);
276
288 int32_t cm_camera_sensor_i2c_read(const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t *val);
289
300 int32_t cm_camera_sensor_i2c_write(const cm_cam_sensor_i2c_attr *attr, cm_cam_sensor_regs regs);
301
313 int32_t cm_camera_sensor_i2c_write_single(const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t val);
314
315 #undef EXTERN
316 #ifdef __cplusplus
317 }
318 #endif
319
320 #endif /* __CM_CAMERA_SENSOR_H__ */
321
322
cm_cam_sensor_res_prop
cm_cam_sensor_res_prop
预留参数相关结构体
Definition: cm_camera_sensor.h:143
cm_camera_sensor_i2c_read
int32_t cm_camera_sensor_i2c_read(const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t *val)
i2c读取
cm_camera_sensor_i2c_write
int32_t cm_camera_sensor_i2c_write(const cm_cam_sensor_i2c_attr *attr, cm_cam_sensor_regs regs)
i2c写
cm_cam_sensor_banding
cm_cam_sensor_banding
camera 频率
Definition: cm_camera_sensor.h:57
cm_camera_sensor_i2c_write_single
int32_t cm_camera_sensor_i2c_write_single(const cm_cam_sensor_i2c_attr *attr, uint32_t reg, uint32_t val)
i2c写（单个数据）
cm_camera_sensor_set_mclk
void cm_camera_sensor_set_mclk(int32_t enable)
使能mclk
cm_cam_sensor_i2c_len
cm_cam_sensor_i2c_len
i2c寄存器支持的数据宽度
Definition: cm_camera_sensor.h:100
cm_camera_sensor_set_data
void cm_camera_sensor_set_data(cm_cam_sensor_data_t *data)
设置驱动参数
cm_cam_sensor_fmt
cm_cam_sensor_fmt
camera输出数据类型
Definition: cm_camera_sensor.h:153
CAM_SENSOR_RES_BINING2
@ CAM_SENSOR_RES_BINING2
Definition: cm_camera_sensor.h:145
CAM_SENSOR_RES_MAX
@ CAM_SENSOR_RES_MAX
Definition: cm_camera_sensor.h:147
CAM_SENSOR_RES_CROPPED
@ CAM_SENSOR_RES_CROPPED
Definition: cm_camera_sensor.h:146
CAM_SENSOR_RES_BINING1
@ CAM_SENSOR_RES_BINING1
Definition: cm_camera_sensor.h:144
CAM_BANDING_AUTO
@ CAM_BANDING_AUTO
Definition: cm_camera_sensor.h:60
CAM_BANDING_60HZ
@ CAM_BANDING_60HZ
Definition: cm_camera_sensor.h:59
CAM_BANDING_50HZ
@ CAM_BANDING_50HZ
Definition: cm_camera_sensor.h:58
CAM_I2C_16BIT
@ CAM_I2C_16BIT
Definition: cm_camera_sensor.h:102
CAM_I2C_8BIT
@ CAM_I2C_8BIT
Definition: cm_camera_sensor.h:101
CAM_I2C_32BIT
@ CAM_I2C_32BIT
Definition: cm_camera_sensor.h:103
CAM_SENSOR_FMT_RAW8
@ CAM_SENSOR_FMT_RAW8
Definition: cm_camera_sensor.h:154
CAM_SENSOR_FMT_RAW12
@ CAM_SENSOR_FMT_RAW12
Definition: cm_camera_sensor.h:157
CAM_SENSOR_FMT_RAW10
@ CAM_SENSOR_FMT_RAW10
Definition: cm_camera_sensor.h:156
CAM_SENSOR_FMT_ONLY_Y
@ CAM_SENSOR_FMT_ONLY_Y
Definition: cm_camera_sensor.h:155
CAM_SENSOR_FMT_YUV422
@ CAM_SENSOR_FMT_YUV422
Definition: cm_camera_sensor.h:158
cm_cam_regval_tab
i2c寄存器地址及写入值
Definition: cm_camera_sensor.h:109
cm_cam_regval_tab::reg
uint16_t reg
Definition: cm_camera_sensor.h:110
cm_cam_regval_tab::val
uint16_t val
Definition: cm_camera_sensor.h:111
cm_cam_regval_tab::mask
uint16_t mask
Definition: cm_camera_sensor.h:112
cm_cam_sensor_aec_t
camera 曝光参数
Definition: cm_camera_sensor.h:66
cm_cam_sensor_aec_t::max_fps
uint32_t max_fps
Definition: cm_camera_sensor.h:72
cm_cam_sensor_aec_t::exp_low
uint32_t exp_low
Definition: cm_camera_sensor.h:68
cm_cam_sensor_aec_t::min_fps
uint32_t min_fps
Definition: cm_camera_sensor.h:71
cm_cam_sensor_aec_t::exp_high
uint32_t exp_high
Definition: cm_camera_sensor.h:67
cm_cam_sensor_aec_t::gain
uint32_t gain
Definition: cm_camera_sensor.h:69
cm_cam_sensor_aec_t::sensor_out_yuv
uint32_t sensor_out_yuv
Definition: cm_camera_sensor.h:74
cm_cam_sensor_aec_t::banding
cm_cam_sensor_banding banding
Definition: cm_camera_sensor.h:73
cm_cam_sensor_aec_t::aec_en
uint32_t aec_en
Definition: cm_camera_sensor.h:70
cm_cam_sensor_ata_t
camera ata模式参数
Definition: cm_camera_sensor.h:49
cm_cam_sensor_ata_t::on
uint32_t on
Definition: cm_camera_sensor.h:50
cm_cam_sensor_ata_t::read_crc_value
int32_t read_crc_value
Definition: cm_camera_sensor.h:51
cm_cam_sensor_data_t
camera驱动结构体
Definition: cm_camera_sensor.h:205
cm_cam_sensor_data_t::ops
cm_cam_sensor_spec_ops * ops
Definition: cm_camera_sensor.h:207
cm_cam_sensor_data_t::global_setting
cm_cam_sensor_global * global_setting
Definition: cm_camera_sensor.h:212
cm_cam_sensor_data_t::i2c_attr
cm_cam_sensor_i2c_attr * i2c_attr
Definition: cm_camera_sensor.h:209
cm_cam_sensor_data_t::hflip
cm_cam_sensor_regs hflip
Definition: cm_camera_sensor.h:221
cm_cam_sensor_data_t::module
cm_cam_sensor_module * module
Definition: cm_camera_sensor.h:223
cm_cam_sensor_data_t::id
cm_cam_sensor_regs id
Definition: cm_camera_sensor.h:211
cm_cam_sensor_data_t::streamon
cm_cam_sensor_regs streamon
Definition: cm_camera_sensor.h:216
cm_cam_sensor_data_t::num_i2c_attr
int32_t num_i2c_attr
Definition: cm_camera_sensor.h:210
cm_cam_sensor_data_t::interface_type
int32_t interface_type
Definition: cm_camera_sensor.h:228
cm_cam_sensor_data_t::gain_reg
cm_cam_sensor_regs gain_reg
Definition: cm_camera_sensor.h:220
cm_cam_sensor_data_t::lane_num
uint8_t lane_num
Definition: cm_camera_sensor.h:229
cm_cam_sensor_data_t::num_global
int32_t num_global
Definition: cm_camera_sensor.h:213
cm_cam_sensor_data_t::expo_reg
cm_cam_sensor_regs expo_reg
Definition: cm_camera_sensor.h:218
cm_cam_sensor_data_t::reset_delay
int32_t reset_delay
Definition: cm_camera_sensor.h:232
cm_cam_sensor_data_t::num_res
int32_t num_res
Definition: cm_camera_sensor.h:215
cm_cam_sensor_data_t::streamoff
cm_cam_sensor_regs streamoff
Definition: cm_camera_sensor.h:217
cm_cam_sensor_data_t::position
int32_t position
Definition: cm_camera_sensor.h:208
cm_cam_sensor_data_t::vts_reg
cm_cam_sensor_regs vts_reg
Definition: cm_camera_sensor.h:219
cm_cam_sensor_data_t::spi_sdr
uint8_t spi_sdr
Definition: cm_camera_sensor.h:230
cm_cam_sensor_data_t::tuning_tab
cm_isp_tuning_tab * tuning_tab
Definition: cm_camera_sensor.h:225
cm_cam_sensor_data_t::name
char *const name
Definition: cm_camera_sensor.h:206
cm_cam_sensor_data_t::num_tuning_tab
int32_t num_tuning_tab
Definition: cm_camera_sensor.h:226
cm_cam_sensor_data_t::vflip
cm_cam_sensor_regs vflip
Definition: cm_camera_sensor.h:222
cm_cam_sensor_data_t::res
cm_cam_sensor_resolution * res
Definition: cm_camera_sensor.h:214
cm_cam_sensor_data_t::num_module
int32_t num_module
Definition: cm_camera_sensor.h:224
cm_cam_sensor_data_t::spi_crc
uint8_t spi_crc
Definition: cm_camera_sensor.h:231
cm_cam_sensor_data_t::cur_res_index
int32_t cur_res_index
Definition: cm_camera_sensor.h:234
cm_cam_sensor_data_t::cur_i2c_index
int32_t cur_i2c_index
Definition: cm_camera_sensor.h:233
cm_cam_sensor_global
预留参数相关结构体，暂无使用
Definition: cm_camera_sensor.h:135
cm_cam_sensor_global::sensor_out_format
int32_t sensor_out_format
Definition: cm_camera_sensor.h:137
cm_cam_sensor_global::regs
cm_cam_sensor_regs regs
Definition: cm_camera_sensor.h:136
cm_cam_sensor_i2c_attr
i2c参数
Definition: cm_camera_sensor.h:126
cm_cam_sensor_i2c_attr::reg_len
cm_cam_sensor_i2c_len reg_len
Definition: cm_camera_sensor.h:127
cm_cam_sensor_i2c_attr::val_len
cm_cam_sensor_i2c_len val_len
Definition: cm_camera_sensor.h:128
cm_cam_sensor_i2c_attr::addr
uint8_t addr
Definition: cm_camera_sensor.h:129
cm_cam_sensor_module
预留参数结构体
Definition: cm_camera_sensor.h:180
cm_cam_sensor_module::apeture_size
uint32_t apeture_size
Definition: cm_camera_sensor.h:183
cm_cam_sensor_module::name
char * name
Definition: cm_camera_sensor.h:182
cm_cam_sensor_module::id
uint32_t id
Definition: cm_camera_sensor.h:181
cm_cam_sensor_regs
i2c寄存器操作表
Definition: cm_camera_sensor.h:118
cm_cam_sensor_regs::num
uint32_t num
Definition: cm_camera_sensor.h:120
cm_cam_sensor_regs::tab
const cm_cam_regval_tab * tab
Definition: cm_camera_sensor.h:119
cm_cam_sensor_resolution
camera参数设置及初始化
Definition: cm_camera_sensor.h:164
cm_cam_sensor_resolution::min_fps
uint8_t min_fps
Definition: cm_camera_sensor.h:172
cm_cam_sensor_resolution::prop
cm_cam_sensor_res_prop prop
Definition: cm_camera_sensor.h:173
cm_cam_sensor_resolution::height
uint16_t height
Definition: cm_camera_sensor.h:168
cm_cam_sensor_resolution::sensor_out_format
uint32_t sensor_out_format
Definition: cm_camera_sensor.h:165
cm_cam_sensor_resolution::hts
uint32_t hts
Definition: cm_camera_sensor.h:169
cm_cam_sensor_resolution::width
uint16_t width
Definition: cm_camera_sensor.h:167
cm_cam_sensor_resolution::min_vts
uint32_t min_vts
Definition: cm_camera_sensor.h:170
cm_cam_sensor_resolution::regs
cm_cam_sensor_regs regs
Definition: cm_camera_sensor.h:174
cm_cam_sensor_resolution::max_fps
uint8_t max_fps
Definition: cm_camera_sensor.h:171
cm_cam_sensor_resolution::mbus_code
uint16_t mbus_code
Definition: cm_camera_sensor.h:166
cm_cam_sensor_spec_ops
camera操作函数
Definition: cm_camera_sensor.h:82
cm_cam_sensor_spec_ops::get_dphy_desc
int32_t * get_dphy_desc
Definition: cm_camera_sensor.h:84
cm_cam_sensor_spec_ops::update_otp
int32_t * update_otp
Definition: cm_camera_sensor.h:85
cm_cam_sensor_spec_ops::set_brightness
int32_t * set_brightness
Definition: cm_camera_sensor.h:90
cm_cam_sensor_spec_ops::set_effect
int32_t * set_effect
Definition: cm_camera_sensor.h:89
cm_cam_sensor_spec_ops::set_contrast
int32_t * set_contrast
Definition: cm_camera_sensor.h:91
cm_cam_sensor_spec_ops::set_saturation
int32_t * set_saturation
Definition: cm_camera_sensor.h:93
cm_cam_sensor_spec_ops::set_banding
int32_t * set_banding
Definition: cm_camera_sensor.h:94
cm_cam_sensor_spec_ops::set_wb
int32_t * set_wb
Definition: cm_camera_sensor.h:92
cm_cam_sensor_spec_ops::get_pixel_rate
int32_t * get_pixel_rate
Definition: cm_camera_sensor.h:83
cm_isp_tuning_data
ISP 寄存器操作表
Definition: cm_camera_sensor.h:197
cm_isp_tuning_data::tab
cm_isp_tuning_tab * tab
Definition: cm_camera_sensor.h:198
cm_isp_tuning_data::num
uint32_t num
Definition: cm_camera_sensor.h:199
cm_isp_tuning_tab
ISP 寄存器地址组及写入值
Definition: cm_camera_sensor.h:189
cm_isp_tuning_tab::reg
uint16_t reg
Definition: cm_camera_sensor.h:190
cm_isp_tuning_tab::val
uint16_t val
Definition: cm_camera_sensor.h:191


ML305A_ML307A_OpenCPU_API: cm_cpuinfo.h 源文件

  • cmiot
cm_cpuinfo.h
1
14 #ifndef __CM_CPUINFO_H__
15 #define __CM_CPUINFO_H__
16
17
18 #include <stdint.h>
19 #include "cm_os.h"
20
21
23 typedef struct{
24 osThreadId_t handle;
25 uint32_t scheduled_cnt;
26 uint32_t tick_cnt;
27 uint32_t last_tick;
28 } cm_thread_runtime_t;
29
30
41 int32_t cm_cpuinfo_record_start(uint32_t mode);
42
55 int32_t cm_cpuinfo_record_read(cm_thread_runtime_t info[], uint32_t *cnt, uint32_t *total_tick);
56
65 int32_t cm_cpuinfo_record_stop(void);
66
75 const char *cm_cpuinfo_get_cpuid(void);
76
77 #endif
cm_thread_runtime_t::tick_cnt
uint32_t tick_cnt
Definition: cm_cpuinfo.h:26
cm_thread_runtime_t::handle
osThreadId_t handle
Definition: cm_cpuinfo.h:24
cm_cpuinfo_record_start
int32_t cm_cpuinfo_record_start(uint32_t mode)
开始统计CPU运行信息
cm_cpuinfo_get_cpuid
const char * cm_cpuinfo_get_cpuid(void)
获取cpu唯一标识
cm_thread_runtime_t::last_tick
uint32_t last_tick
Definition: cm_cpuinfo.h:27
cm_thread_runtime_t::scheduled_cnt
uint32_t scheduled_cnt
Definition: cm_cpuinfo.h:25
cm_cpuinfo_record_stop
int32_t cm_cpuinfo_record_stop(void)
结束运行信息统计
cm_cpuinfo_record_read
int32_t cm_cpuinfo_record_read(cm_thread_runtime_t info[], uint32_t *cnt, uint32_t *total_tick)
读取统计信息
osThreadId_t
void * osThreadId_t
Definition: cm_os.h:144
cm_thread_runtime_t
Definition: cm_cpuinfo.h:23


ML305A_ML307A_OpenCPU_API: cm_eloop.h 源文件

  • cmiot
cm_eloop.h
1
13 #ifndef __CM_ELOOP_H__
14 #define __CM_ELOOP_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
27 #define CM_ELOOP_WAIT_FOREVER 0xFFFFFFFF
28
29 /****************************************************************************
30 * Public Types
31 ****************************************************************************/
32
34 struct cm_eloop_t;
35 typedef struct cm_eloop_t *cm_eloop_handle_t;
36
38 struct cm_eloop_event_t;
39 typedef struct cm_eloop_event_t *cm_eloop_event_handle_t;
40
46 typedef void (*cm_eloop_event_cb)(cm_eloop_event_handle_t event, void *cb_param);
47
48 /****************************************************************************
49 * Public Data
50 ****************************************************************************/
51
52 /****************************************************************************
53 * Public Function Prototypes
54 ****************************************************************************/
55
56 #ifdef __cplusplus
57 #define EXTERN extern "C"
58 extern "C" {
59 #else
60 #define EXTERN extern
61 #endif
62
71 cm_eloop_handle_t cm_eloop_default(void);
72
83 cm_eloop_handle_t cm_eloop_create(uint32_t max_num);
84
92 void cm_eloop_delete(cm_eloop_handle_t eloop);
93
109 int32_t cm_eloop_wait_event(cm_eloop_handle_t eloop, uint32_t timeout);
110
123 cm_eloop_event_handle_t cm_eloop_register_event(cm_eloop_handle_t eloop, cm_eloop_event_cb event_cb, void *cb_param);
124
132 void cm_eloop_unregister_event(cm_eloop_event_handle_t event);
133
145 int32_t cm_eloop_post_event(cm_eloop_event_handle_t event);
146
147 #undef EXTERN
148 #ifdef __cplusplus
149 }
150 #endif
151
152 #endif /* __CM_ELOOP_H__ */
153
cm_eloop_event_handle_t
struct cm_eloop_event_t * cm_eloop_event_handle_t
Definition: cm_eloop.h:39
cm_eloop_default
cm_eloop_handle_t cm_eloop_default(void)
取得系统默认Event Loop对象
cm_eloop_create
cm_eloop_handle_t cm_eloop_create(uint32_t max_num)
创建Event Loop对象
cm_eloop_unregister_event
void cm_eloop_unregister_event(cm_eloop_event_handle_t event)
从Event Loop注销事件
cm_eloop_register_event
cm_eloop_event_handle_t cm_eloop_register_event(cm_eloop_handle_t eloop, cm_eloop_event_cb event_cb, void *cb_param)
注册事件到Event Loop
cm_eloop_post_event
int32_t cm_eloop_post_event(cm_eloop_event_handle_t event)
发送事件到Event Loop
cm_eloop_handle_t
struct cm_eloop_t * cm_eloop_handle_t
Definition: cm_eloop.h:35
cm_eloop_event_cb
void(* cm_eloop_event_cb)(cm_eloop_event_handle_t event, void *cb_param)
Definition: cm_eloop.h:46
cm_eloop_wait_event
int32_t cm_eloop_wait_event(cm_eloop_handle_t eloop, uint32_t timeout)
等待Event触发或者超时时间到达
cm_eloop_delete
void cm_eloop_delete(cm_eloop_handle_t eloop)
删除Event Loop对象


ML305A_ML307A_OpenCPU_API: cm_fota.h 源文件

  • cmiot
cm_fota.h
1
13 /*----------------------------------------------------------------------------*
14 ** Dependencies *
15 **----------------------------------------------------------------------------*/
16
17 /*----------------------------------------------------------------------------*
18 ** Mcaro Definitions *
19 **----------------------------------------------------------------------------*/
20
21 #define CM_FOTA_STRING_LEN 48
22 #define CM_FOTA_LONG_STRING_LEN 256
23 #define CM_FOTA_FIXED_RESERVED_LEN (512 - 8 - CM_FOTA_LONG_STRING_LEN - 2 * CM_FOTA_STRING_LEN)
24
25 /*----------------------------------------------------------------------------*
26 ** Data Structures *
27 **----------------------------------------------------------------------------*/
31 typedef enum
32 {
33 CM_FOTA_CMIOT_ERROR_UNKNOW = 850,
34 CM_FOTA_CMIOT_ERROR_CONFIG_FILE,
35 CM_FOTA_CMIOT_ERROR_URL_TYPE,
36 CM_FOTA_CMIOT_ERROR_WRITE_CONFIG,
37 CM_FOTA_CMIOT_ERROR_UPDATE,
38 CM_FOTA_CMIOT_ERROR_DOWNLOAD,
39 CM_FOTA_CMIOT_ERROR_DOWNLOAD_MAX_RETRY,
40 CM_FOTA_CMIOT_ERROR_NO_NETWORK
41 } cm_fota_error_e;
42
43
44 typedef enum
45 {
46 CM_FOTA_ASR_PLAN_INVALID = 0,
47 CM_FOTA_ASR_PLAN_MINI_INTEGRATE,
48 CM_FOTA_ASR_PLAN_MINI,
49 CM_FOTA_ASR_PLAN_PRO
50 } cm_fota_asr_plan_e;
51
52 typedef enum
53 {
54 CM_FOTA_TYPE_INVALID = 0,
55 CM_FOTA_TYPE_FTP,
56 CM_FOTA_TYPE_HTTP_HTTPS
57 } cm_fota_url_type_e;
58
59 typedef enum
60 {
61 CM_FOTA_STAGE_NONE = 0,
62 CM_FOTA_STAGE_START,
63 CM_FOTA_STAGE_BIN1_OTA,
64 CM_FOTA_STAGE_BIN1_SUCC,
65 CM_FOTA_STAGE_ERR_ALLOW_RETRY,
66 CM_FOTA_STAGE_SUCC,
67 CM_FOTA_INTEGRATE_STAGE_START,
68 CM_FOTA_INTEGRATE_STAGE_BIN2,
69 CM_FOTA_STAGE_ERR
70 } cm_fota_stage_e;
71
79 typedef struct
80 {
81 int first_timeout;
82 int second_timeout;
83 int third_timeout;
84 int fourth_timeout;
85 int fifth_timeout;
86 int sixth_timeout;
87 int constant_timeout;
88 } cm_fota_reboot_time;
89
90 typedef struct
91 {
92 int isSetTimeout;
93 int failure;
94 cm_fota_reboot_time timeout;
95 } cm_fota_extendible_info_t;
96
97 typedef struct
98 {
99 cm_fota_stage_e stage;
100 cm_fota_url_type_e fota_mode;
101 char url[CM_FOTA_LONG_STRING_LEN];
102 char username[CM_FOTA_STRING_LEN];
103 char passwd[CM_FOTA_STRING_LEN];
104 char reserved[CM_FOTA_FIXED_RESERVED_LEN];
105 } cm_fota_info_fixed_t;
106
107 typedef struct
108 {
109 cm_fota_info_fixed_t fixed_info;
110 cm_fota_extendible_info_t extend_info;
111 } cm_fota_info_t;
112 /*----------------------------------------------------------------------------*
113 ** Function Define *
114 **----------------------------------------------------------------------------*/
115
116
124 typedef void (*cm_fota_result_callback)(cm_fota_error_e error);
125
142 int cm_fota_set_url(char *url);
143
156 int cm_fota_set_auth(const char *username, const char *passwd);
157
171 int cm_fota_set_reboot_time(cm_fota_reboot_time *time);
172
180 void cm_fota_read_config(cm_fota_info_t *cfg);
181
189 void cm_fota_set_ota_plan(cm_fota_asr_plan_e ota_plan);
190
196 cm_fota_asr_plan_e cm_fota_get_ota_plan(void);
197
206 void cm_fota_res_callback_register(cm_fota_result_callback cb);
207
219 int cm_fota_exec_upgrade(void);
cm_fota_extendible_info_t::timeout
cm_fota_reboot_time timeout
Definition: cm_fota.h:94
cm_fota_reboot_time::constant_timeout
int constant_timeout
Definition: cm_fota.h:87
cm_fota_reboot_time::fourth_timeout
int fourth_timeout
Definition: cm_fota.h:84
cm_fota_result_callback
void(* cm_fota_result_callback)(cm_fota_error_e error)
fota结果回调函数
Definition: cm_fota.h:124
cm_fota_asr_plan_e
cm_fota_asr_plan_e
Definition: cm_fota.h:45
cm_fota_exec_upgrade
int cm_fota_exec_upgrade(void)
进入mini system执行fota升级
cm_fota_extendible_info_t::failure
int failure
Definition: cm_fota.h:93
cm_fota_info_t::fixed_info
cm_fota_info_fixed_t fixed_info
Definition: cm_fota.h:109
cm_fota_extendible_info_t::isSetTimeout
int isSetTimeout
Definition: cm_fota.h:92
cm_fota_res_callback_register
void cm_fota_res_callback_register(cm_fota_result_callback cb)
SDK注册fota结果回调
cm_fota_reboot_time::second_timeout
int second_timeout
Definition: cm_fota.h:82
CM_FOTA_FIXED_RESERVED_LEN
#define CM_FOTA_FIXED_RESERVED_LEN
Definition: cm_fota.h:23
cm_fota_set_url
int cm_fota_set_url(char *url)
设置FOTA服务器url
cm_fota_stage_e
cm_fota_stage_e
Definition: cm_fota.h:60
cm_fota_url_type_e
cm_fota_url_type_e
Definition: cm_fota.h:53
cm_fota_info_fixed_t::stage
cm_fota_stage_e stage
Definition: cm_fota.h:99
cm_fota_set_auth
int cm_fota_set_auth(const char *username, const char *passwd)
设置FOTA服务器登录名和密码（仅FTP方式）
cm_fota_set_ota_plan
void cm_fota_set_ota_plan(cm_fota_asr_plan_e ota_plan)
配置FOTA OTA升级方案
cm_fota_reboot_time::fifth_timeout
int fifth_timeout
Definition: cm_fota.h:85
CM_FOTA_STRING_LEN
#define CM_FOTA_STRING_LEN
Definition: cm_fota.h:21
cm_fota_get_ota_plan
cm_fota_asr_plan_e cm_fota_get_ota_plan(void)
获取FOTA OTA升级方案
cm_fota_reboot_time::sixth_timeout
int sixth_timeout
Definition: cm_fota.h:86
CM_FOTA_LONG_STRING_LEN
#define CM_FOTA_LONG_STRING_LEN
Definition: cm_fota.h:22
cm_fota_error_e
cm_fota_error_e
Definition: cm_fota.h:32
cm_fota_read_config
void cm_fota_read_config(cm_fota_info_t *cfg)
获取FOTA服务器配置
cm_fota_set_reboot_time
int cm_fota_set_reboot_time(cm_fota_reboot_time *time)
设置FOTA失败时的下一次重启时间（重启后会继续尝试升级）
cm_fota_reboot_time::first_timeout
int first_timeout
Definition: cm_fota.h:81
cm_fota_info_t::extend_info
cm_fota_extendible_info_t extend_info
Definition: cm_fota.h:110
cm_fota_info_fixed_t::fota_mode
cm_fota_url_type_e fota_mode
Definition: cm_fota.h:100
cm_fota_reboot_time::third_timeout
int third_timeout
Definition: cm_fota.h:83
CM_FOTA_ASR_PLAN_PRO
@ CM_FOTA_ASR_PLAN_PRO
Definition: cm_fota.h:49
CM_FOTA_ASR_PLAN_MINI
@ CM_FOTA_ASR_PLAN_MINI
Definition: cm_fota.h:48
CM_FOTA_ASR_PLAN_MINI_INTEGRATE
@ CM_FOTA_ASR_PLAN_MINI_INTEGRATE
Definition: cm_fota.h:47
CM_FOTA_ASR_PLAN_INVALID
@ CM_FOTA_ASR_PLAN_INVALID
Definition: cm_fota.h:46
CM_FOTA_STAGE_BIN1_SUCC
@ CM_FOTA_STAGE_BIN1_SUCC
Definition: cm_fota.h:64
CM_FOTA_INTEGRATE_STAGE_START
@ CM_FOTA_INTEGRATE_STAGE_START
Definition: cm_fota.h:67
CM_FOTA_STAGE_NONE
@ CM_FOTA_STAGE_NONE
Definition: cm_fota.h:61
CM_FOTA_STAGE_SUCC
@ CM_FOTA_STAGE_SUCC
Definition: cm_fota.h:66
CM_FOTA_STAGE_START
@ CM_FOTA_STAGE_START
Definition: cm_fota.h:62
CM_FOTA_STAGE_ERR_ALLOW_RETRY
@ CM_FOTA_STAGE_ERR_ALLOW_RETRY
Definition: cm_fota.h:65
CM_FOTA_STAGE_ERR
@ CM_FOTA_STAGE_ERR
Definition: cm_fota.h:69
CM_FOTA_STAGE_BIN1_OTA
@ CM_FOTA_STAGE_BIN1_OTA
Definition: cm_fota.h:63
CM_FOTA_INTEGRATE_STAGE_BIN2
@ CM_FOTA_INTEGRATE_STAGE_BIN2
Definition: cm_fota.h:68
CM_FOTA_TYPE_INVALID
@ CM_FOTA_TYPE_INVALID
Definition: cm_fota.h:54
CM_FOTA_TYPE_FTP
@ CM_FOTA_TYPE_FTP
Definition: cm_fota.h:55
CM_FOTA_TYPE_HTTP_HTTPS
@ CM_FOTA_TYPE_HTTP_HTTPS
Definition: cm_fota.h:56
CM_FOTA_CMIOT_ERROR_DOWNLOAD_MAX_RETRY
@ CM_FOTA_CMIOT_ERROR_DOWNLOAD_MAX_RETRY
Definition: cm_fota.h:39
CM_FOTA_CMIOT_ERROR_UNKNOW
@ CM_FOTA_CMIOT_ERROR_UNKNOW
Definition: cm_fota.h:33
CM_FOTA_CMIOT_ERROR_NO_NETWORK
@ CM_FOTA_CMIOT_ERROR_NO_NETWORK
Definition: cm_fota.h:40
CM_FOTA_CMIOT_ERROR_WRITE_CONFIG
@ CM_FOTA_CMIOT_ERROR_WRITE_CONFIG
Definition: cm_fota.h:36
CM_FOTA_CMIOT_ERROR_CONFIG_FILE
@ CM_FOTA_CMIOT_ERROR_CONFIG_FILE
Definition: cm_fota.h:34
CM_FOTA_CMIOT_ERROR_URL_TYPE
@ CM_FOTA_CMIOT_ERROR_URL_TYPE
Definition: cm_fota.h:35
CM_FOTA_CMIOT_ERROR_DOWNLOAD
@ CM_FOTA_CMIOT_ERROR_DOWNLOAD
Definition: cm_fota.h:38
CM_FOTA_CMIOT_ERROR_UPDATE
@ CM_FOTA_CMIOT_ERROR_UPDATE
Definition: cm_fota.h:37
cm_fota_extendible_info_t
Definition: cm_fota.h:91
cm_fota_info_fixed_t
Definition: cm_fota.h:98
cm_fota_info_t
Definition: cm_fota.h:108
cm_fota_reboot_time
Definition: cm_fota.h:80


ML305A_ML307A_OpenCPU_API: cm_fs.h 源文件

  • cmiot
cm_fs.h
1
13 #ifndef __CM_FS_H__
14 #define __CM_FS_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 /* 模组使用LittleFS文件系统，请按照下文描述的文件打开方式使用。错误使用时文件系统无法保证文件功能正常 */
27 #define CM_FS_RB (0)
28 #define CM_FS_WB (1)
29 #define CM_FS_AB (2)
30 #define CM_FS_WBPLUS (3)
31 #define CM_FS_ABPLUS (4)
32 #define CM_FS_RBPLUS (5)
35 #define CM_FS_SEEK_SET (0)
36 #define CM_FS_SEEK_CUR (1)
37 #define CM_FS_SEEK_END (2)
39 /****************************************************************************
40 * Public Types
41 ****************************************************************************/
42 typedef struct
43 {
44 uint32_t free_size;
45 uint32_t total_size;
46 } cm_fs_system_info_t;
47
48 /****************************************************************************
49 * Public Data
50 ****************************************************************************/
51
52 /****************************************************************************
53 * Public Function Prototypes
54 ****************************************************************************/
55
56 #ifdef __cplusplus
57 #define EXTERN extern "C"
58 extern "C" {
59 #else
60 #define EXTERN extern
61 #endif
62
63 /****************************************************************************/
64
77 int32_t cm_fs_open(const char *filename, int32_t flag);
78
88 int32_t cm_fs_close(int32_t fd);
89
101 int32_t cm_fs_read(int32_t fd, void *buf, uint32_t size);
102
114 int32_t cm_fs_write(int32_t fd, const void *buf, uint32_t size);
115
116 #if 0
128 int32_t cm_fs_sync(int32_t fd);
129 #endif
130
144 int32_t cm_fs_seek(int32_t fd, int32_t offset, int32_t base);
145
155 int32_t cm_fs_delete(const char *file_name);
156
167 int32_t cm_fs_move(const char *src, const char *dest);
168
180 int32_t cm_fs_exist(const char *file_name);
181
193 int32_t cm_fs_filesize(const char *file_name);
194
204 int32_t cm_fs_getinfo(cm_fs_system_info_t *info);
205
206 #undef EXTERN
207 #ifdef __cplusplus
208 }
209 #endif
210
211 #endif /* __CM_FS_H__ */
212
cm_fs_filesize
int32_t cm_fs_filesize(const char *file_name)
获取文件大小
cm_fs_close
int32_t cm_fs_close(int32_t fd)
关闭一个文件
cm_fs_open
int32_t cm_fs_open(const char *filename, int32_t flag)
打开一个文件
cm_fs_delete
int32_t cm_fs_delete(const char *file_name)
删除文件
cm_fs_getinfo
int32_t cm_fs_getinfo(cm_fs_system_info_t *info)
获取文件系统信息
cm_fs_move
int32_t cm_fs_move(const char *src, const char *dest)
更改文件名
cm_fs_seek
int32_t cm_fs_seek(int32_t fd, int32_t offset, int32_t base)
文件指针定位
cm_fs_write
int32_t cm_fs_write(int32_t fd, const void *buf, uint32_t size)
写入文件内容
cm_fs_exist
int32_t cm_fs_exist(const char *file_name)
检查文件是否存在
cm_fs_read
int32_t cm_fs_read(int32_t fd, void *buf, uint32_t size)
读取文件内容
cm_fs_system_info_t
Definition: cm_fs.h:43
cm_fs_system_info_t::free_size
uint32_t free_size
Definition: cm_fs.h:44
cm_fs_system_info_t::total_size
uint32_t total_size
Definition: cm_fs.h:45


ML305A_ML307A_OpenCPU_API: cm_ftp.h 源文件

  • cmiot
cm_ftp.h
1
13 #ifndef __CM_FTP_H__
14 #define __CM_FTP_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 #include "sockets.h"
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27
28 /****************************************************************************
29 * Public Types
30 ****************************************************************************/
31
33 typedef struct
34 {
35 uint8_t *url;
36 int32_t port;
37 uint8_t *username;
38 uint8_t *passwd;
39 int32_t trans_mode;
40 int32_t data_type;
41 int32_t rsptimeout;
42 int32_t ssl_mode;
43 int32_t ssl_id;
44 int32_t cid;
45 } cm_ftp_config_t;
46
48 typedef struct
49 {
50 uint32_t file_attr;
51 uint32_t file_size;
52 uint8_t file_name[256];
53 uint8_t file_permision;
54 uint32_t file_modify_time;
55 } cm_ftp_file_data_t;
56
58 typedef enum
59 {
60 FTP_STATE_DISCONNECTED = 0,
61 FTP_STATE_CONNECTED,
62 FTP_STATE_GETTING,
63 FTP_STATE_PUTTING
64 } cm_ftp_state_e;
65
66 /****************************************************************************
67 * Public Data
68 ****************************************************************************/
69
70
71 /****************************************************************************
72 * Public Function Prototypes
73 ****************************************************************************/
74
75 #ifdef __cplusplus
76 #define EXTERN extern "C"
77 extern "C" {
78 #else
79 #define EXTERN extern
80 #endif
81
82 /****************************************************************************/
83
93 int32_t cm_ftp_open(cm_ftp_config_t *config);
94
104 int32_t cm_ftp_close(int32_t handle);
105
116 int32_t cm_ftp_create_dir(int32_t handle, const char *dir);
117
128 int32_t cm_ftp_remove_dir(int32_t handle, const char *dir);
129
140 int32_t cm_ftp_delete_file(int32_t handle, const char *file);
141
152 int32_t cm_ftp_set_current_dir(int32_t handle, const char *dir);
153
164 int32_t cm_ftp_get_current_dir(int32_t handle, char *dir);
165
177 int32_t cm_ftp_rename_file(int32_t handle, const char *old_file, const char *new_file);
178
189 int32_t cm_ftp_get_file_size(int32_t handle, const char *file);
190
202 int32_t cm_ftp_find_first(int32_t handle, const char *path, cm_ftp_file_data_t *file_data);
203
215 int32_t cm_ftp_find_next(int32_t handle, int32_t find_fd, cm_ftp_file_data_t *file_data);
216
227 int32_t cm_ftp_find_close(int32_t handle, int32_t find_fd);
228
245 int32_t cm_ftp_get_file(int32_t handle, int32_t data_type, const char *file, int32_t offset, uint8_t *data, uint32_t len);
246
260 int32_t cm_ftp_put_file(int32_t handle, int32_t mode, char *file, uint8_t *data, uint32_t len);
261
270 cm_ftp_state_e cm_ftp_get_state(int32_t handle);
271
272 #undef EXTERN
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif /* __CM_FTP_CLIENT_H__ */
278
cm_ftp_rename_file
int32_t cm_ftp_rename_file(int32_t handle, const char *old_file, const char *new_file)
重命名文件
cm_ftp_delete_file
int32_t cm_ftp_delete_file(int32_t handle, const char *file)
删除服务器上指定文件
cm_ftp_create_dir
int32_t cm_ftp_create_dir(int32_t handle, const char *dir)
在服务器上创建文件夹
cm_ftp_find_first
int32_t cm_ftp_find_first(int32_t handle, const char *path, cm_ftp_file_data_t *file_data)
FTP打开查找，并且获取文件夹下第一个文件或文件夹目录信息
cm_ftp_get_file
int32_t cm_ftp_get_file(int32_t handle, int32_t data_type, const char *file, int32_t offset, uint8_t *data, uint32_t len)
FTP从服务器获取文件
cm_ftp_put_file
int32_t cm_ftp_put_file(int32_t handle, int32_t mode, char *file, uint8_t *data, uint32_t len)
FTP向服务器推送文件
cm_ftp_state_e
cm_ftp_state_e
Definition: cm_ftp.h:59
cm_ftp_get_current_dir
int32_t cm_ftp_get_current_dir(int32_t handle, char *dir)
获取服务器上的当前工作目录
cm_ftp_get_state
cm_ftp_state_e cm_ftp_get_state(int32_t handle)
获取FTP连接状态
cm_ftp_get_file_size
int32_t cm_ftp_get_file_size(int32_t handle, const char *file)
获取文件大小
cm_ftp_find_next
int32_t cm_ftp_find_next(int32_t handle, int32_t find_fd, cm_ftp_file_data_t *file_data)
FTP获取文件夹下文件信息
cm_ftp_close
int32_t cm_ftp_close(int32_t handle)
关闭一个FTP连接
cm_ftp_remove_dir
int32_t cm_ftp_remove_dir(int32_t handle, const char *dir)
删除服务器上的文件夹
cm_ftp_set_current_dir
int32_t cm_ftp_set_current_dir(int32_t handle, const char *dir)
设置服务器上的当前工作目录
cm_ftp_find_close
int32_t cm_ftp_find_close(int32_t handle, int32_t find_fd)
关闭查找
cm_ftp_open
int32_t cm_ftp_open(cm_ftp_config_t *config)
打开一个FTP连接
FTP_STATE_PUTTING
@ FTP_STATE_PUTTING
Definition: cm_ftp.h:63
FTP_STATE_GETTING
@ FTP_STATE_GETTING
Definition: cm_ftp.h:62
FTP_STATE_DISCONNECTED
@ FTP_STATE_DISCONNECTED
Definition: cm_ftp.h:60
FTP_STATE_CONNECTED
@ FTP_STATE_CONNECTED
Definition: cm_ftp.h:61
cm_ftp_config_t
Definition: cm_ftp.h:34
cm_ftp_config_t::data_type
int32_t data_type
Definition: cm_ftp.h:40
cm_ftp_config_t::ssl_mode
int32_t ssl_mode
Definition: cm_ftp.h:42
cm_ftp_config_t::url
uint8_t * url
Definition: cm_ftp.h:35
cm_ftp_config_t::ssl_id
int32_t ssl_id
Definition: cm_ftp.h:43
cm_ftp_config_t::trans_mode
int32_t trans_mode
Definition: cm_ftp.h:39
cm_ftp_config_t::cid
int32_t cid
Definition: cm_ftp.h:44
cm_ftp_config_t::passwd
uint8_t * passwd
Definition: cm_ftp.h:38
cm_ftp_config_t::rsptimeout
int32_t rsptimeout
Definition: cm_ftp.h:41
cm_ftp_config_t::username
uint8_t * username
Definition: cm_ftp.h:37
cm_ftp_config_t::port
int32_t port
Definition: cm_ftp.h:36
cm_ftp_file_data_t
Definition: cm_ftp.h:49
cm_ftp_file_data_t::file_permision
uint8_t file_permision
Definition: cm_ftp.h:53
cm_ftp_file_data_t::file_attr
uint32_t file_attr
Definition: cm_ftp.h:50
cm_ftp_file_data_t::file_size
uint32_t file_size
Definition: cm_ftp.h:51
cm_ftp_file_data_t::file_modify_time
uint32_t file_modify_time
Definition: cm_ftp.h:54


ML305A_ML307A_OpenCPU_API: cm_gnss.h 源文件

  • cmiot
cm_gnss.h
1
18 #ifndef __CM_GNSS_H__
19 #define __CM_GNSS_H__
20
21 /****************************************************************************
22 * Included Files
23 ****************************************************************************/
24
25 #include <stdint.h>
26 #include <time.h>
27 /****************************************************************************
28 * Pre-processor Definitions
29 ****************************************************************************/
31 #define CM_GNSS_NAME_GGA (1<<0)
32 #define CM_GNSS_NAME_GSV (1<<1)
33 #define CM_GNSS_NAME_GSA (1<<2)
34 #define CM_GNSS_NAME_RMC (1<<3)
35 #define CM_GNSS_NAME_VTG (1<<4)
36 #define CM_GNSS_NAME_GLL (1<<5)
37 #define CM_GNSS_NAME_ZDA (1<<6)
38 #define CM_GNSS_NAME_DTM (1<<7) // 不支持
39 #define CM_GNSS_NAME_GNS (1<<8) // 不支持
40 #define CM_GNSS_NAME_GRS (1<<9) // 不支持
41 #define CM_GNSS_NAME_GST (1<<10)
42 #define CM_GNSS_NAME_GBS (1<<11)// 不支持
43 #define CM_GNSS_NAME_TXT (1<<12)
44
45 /****************************************************************************
46 * Public Types
47 ****************************************************************************/
48
50 typedef enum{
51 CM_AGNSS_DISABLE = 1,
52 CM_AGNSS_ENABLE,
53 } cm_agnss_enable_e;
54
56 typedef enum{
57 CM_GNSS_GPS = 1,
58 CM_GNSS_BDS,
59 CM_GNSS_GLONASS,
60 CM_GNSS_BDS_GPS,
61 CM_GNSS_GPS_GLONASS,
62 CM_GNSS_BDS_GLONASS,
63 CM_GNSS_BDS_GPS_GLONASS
64 } cm_gnss_type_e;
65
66 typedef struct{
67 float latitude;
68 float longitude;
69 uint8_t mode;
70 } cm_agnss_location_t;
71
73 typedef enum{
74 CM_GNSS_CONFIG_TYPE_NMEA_MASK = 1,
76 CM_GNSS_CONFIG_TYPE_NMEA_CYCLE,
77 CM_GNSS_CONFIG_TYPE_NMEA_PORT, /*不支持*/
78 CM_GNSS_CONFIG_TYPE_AGNSS_LOCATION,
79 CM_GNSS_CONFIG_TYPE_AGNSS_TIME, /*不支持*/
80 CM_GNSS_CONFIG_TYPE_AGNSS_URL, /*不支持*/
81 CM_GNSS_CONFIG_TYPE_AGNSS_INTERVAL, /*不支持*/
82 CM_GNSS_CONFIG_TYPE_DGNSS_URL, /*不支持*/
83 CM_GNSS_CONFIG_TYPE_DGNSS_USER, /*不支持*/
84 CM_GNSS_CONFIG_TYPE_DGNSS_PWD, /*不支持*/
85 CM_GNSS_CONFIG_TYPE_DGNSS_MOUNT, /*不支持*/
86 CM_GNSS_CONFIG_TYPE_DGNSS_INTERVAL, /*不支持*/
87 CM_GNSS_CONFIG_TYPE_SLEEP,
88 } cm_gnss_config_type_e;
89
90
91 typedef struct{
92 float latitude;
93 float longitude;
94 float hdop;
95 float altitude;
96 uint8_t fix;
97 float cog;
98 float spkm;
99 float spkn;
100 uint8_t nsat;
101 uint8_t dtype; /*不支持*/
102 } cm_gnss_location_info_t;
103
104
105 typedef enum{
106 CM_AGNSS_UPDATE_INVALID = 0,
107 CM_AGNSS_UPDATE_VALID,
108 CM_AGNSS_UPDATE_FAIL_JUDGE, /*不支持*/
109 CM_AGNSS_UPDATE_VOID, /*不支持*/
110 } cm_agnss_update_result_e;
111
123 typedef void (*cm_gnss_nmea_callback)(uint32_t type, const char *nmea, uint32_t len);
124
136 typedef void (*cm_agnss_data_callback)(cm_agnss_update_result_e mode, const char *update_time, uint32_t size);
137
147 typedef void (*cm_gnss_rawdata_rsp_callback)(const char *data, uint32_t len);
148
149 /****************************************************************************
150 * Public Data
151 ****************************************************************************/
152
153
154 /****************************************************************************
155 * Public Function Prototypes
156 ****************************************************************************/
157 #ifdef __cplusplus
158 #define EXTERN extern "C"
159 extern "C"
160 {
161 #else
162 #define EXTERN extern
163 #endif
164
177 int32_t cm_gnss_open(cm_gnss_type_e gnss_type, cm_agnss_enable_e agnss_enable);
178
186 void cm_gnss_close(void);
187
199 int32_t cm_gnss_config(cm_gnss_config_type_e config_type, void *value);
200
212 int32_t cm_gnss_set_nmea_callback(cm_gnss_nmea_callback callback, uint32_t nmea_type);
213
224 int32_t cm_gnss_reset(void);
225
240 int32_t cm_agnss_state_query(cm_agnss_update_result_e *agnss_mode, char *update_time, uint32_t update_time_len, uint32_t *data_size);
241
242
254 int32_t cm_agnss_data_start_update(cm_agnss_data_callback callback);
255
268 int32_t cm_dgnss_enable(void);
269
281 int32_t cm_dgnss_disable(void);
282
296 int32_t cm_gnss_send_raw_data(const char *raw_data, uint32_t len, cm_gnss_rawdata_rsp_callback callback);
297
308 int32_t cm_gnss_get_location_info(cm_gnss_location_info_t *info);
309
319 int32_t cm_gnss_req_nmea(void);
320
321 #undef EXTERN
322 #ifdef __cplusplus
323 }
324 #endif
325
326 #endif /* __CM_GNSS_H__ */
327
cm_gnss_req_nmea
int32_t cm_gnss_req_nmea(void)
主动请求NMEA数据
cm_agnss_state_query
int32_t cm_agnss_state_query(cm_agnss_update_result_e *agnss_mode, char *update_time, uint32_t update_time_len, uint32_t *data_size)
查询辅助定位数据是否有效
cm_gnss_set_nmea_callback
int32_t cm_gnss_set_nmea_callback(cm_gnss_nmea_callback callback, uint32_t nmea_type)
gnss 注册NMEA 消息回调函数
cm_gnss_send_raw_data
int32_t cm_gnss_send_raw_data(const char *raw_data, uint32_t len, cm_gnss_rawdata_rsp_callback callback)
向GPS芯片发送命令
cm_gnss_config
int32_t cm_gnss_config(cm_gnss_config_type_e config_type, void *value)
gnss 参数信息配置
cm_gnss_get_location_info
int32_t cm_gnss_get_location_info(cm_gnss_location_info_t *info)
获取定位信息
cm_agnss_enable_e
cm_agnss_enable_e
Definition: cm_gnss.h:50
cm_dgnss_disable
int32_t cm_dgnss_disable(void)
dgnss 功能关闭
cm_agnss_data_start_update
int32_t cm_agnss_data_start_update(cm_agnss_data_callback callback)
更新辅助定位数据
cm_dgnss_enable
int32_t cm_dgnss_enable(void)
dgnss 功能打开
cm_gnss_nmea_callback
void(* cm_gnss_nmea_callback)(uint32_t type, const char *nmea, uint32_t len)
NMEA信息回调函数
Definition: cm_gnss.h:123
cm_gnss_config_type_e
cm_gnss_config_type_e
Definition: cm_gnss.h:73
cm_gnss_open
int32_t cm_gnss_open(cm_gnss_type_e gnss_type, cm_agnss_enable_e agnss_enable)
gnss 功能打开
cm_gnss_reset
int32_t cm_gnss_reset(void)
gnss 重启
cm_gnss_rawdata_rsp_callback
void(* cm_gnss_rawdata_rsp_callback)(const char *data, uint32_t len)
发送透传信息给GPS芯片返回结果回调函数
Definition: cm_gnss.h:147
cm_agnss_data_callback
void(* cm_agnss_data_callback)(cm_agnss_update_result_e mode, const char *update_time, uint32_t size)
辅助信息更新结果回调函数
Definition: cm_gnss.h:136
cm_agnss_update_result_e
cm_agnss_update_result_e
Definition: cm_gnss.h:105
cm_gnss_type_e
cm_gnss_type_e
Definition: cm_gnss.h:56
cm_gnss_close
void cm_gnss_close(void)
gnss 功能关闭
CM_AGNSS_DISABLE
@ CM_AGNSS_DISABLE
Definition: cm_gnss.h:51
CM_AGNSS_ENABLE
@ CM_AGNSS_ENABLE
Definition: cm_gnss.h:52
CM_GNSS_CONFIG_TYPE_AGNSS_URL
@ CM_GNSS_CONFIG_TYPE_AGNSS_URL
Definition: cm_gnss.h:80
CM_GNSS_CONFIG_TYPE_AGNSS_LOCATION
@ CM_GNSS_CONFIG_TYPE_AGNSS_LOCATION
Definition: cm_gnss.h:78
CM_GNSS_CONFIG_TYPE_AGNSS_INTERVAL
@ CM_GNSS_CONFIG_TYPE_AGNSS_INTERVAL
Definition: cm_gnss.h:81
CM_GNSS_CONFIG_TYPE_NMEA_MASK
@ CM_GNSS_CONFIG_TYPE_NMEA_MASK
Definition: cm_gnss.h:74
CM_GNSS_CONFIG_TYPE_DGNSS_INTERVAL
@ CM_GNSS_CONFIG_TYPE_DGNSS_INTERVAL
Definition: cm_gnss.h:86
CM_GNSS_CONFIG_TYPE_AGNSS_TIME
@ CM_GNSS_CONFIG_TYPE_AGNSS_TIME
Definition: cm_gnss.h:79
CM_GNSS_CONFIG_TYPE_NMEA_CYCLE
@ CM_GNSS_CONFIG_TYPE_NMEA_CYCLE
Definition: cm_gnss.h:76
CM_GNSS_CONFIG_TYPE_DGNSS_URL
@ CM_GNSS_CONFIG_TYPE_DGNSS_URL
Definition: cm_gnss.h:82
CM_GNSS_CONFIG_TYPE_SLEEP
@ CM_GNSS_CONFIG_TYPE_SLEEP
Definition: cm_gnss.h:87
CM_GNSS_CONFIG_TYPE_DGNSS_USER
@ CM_GNSS_CONFIG_TYPE_DGNSS_USER
Definition: cm_gnss.h:83
CM_GNSS_CONFIG_TYPE_DGNSS_MOUNT
@ CM_GNSS_CONFIG_TYPE_DGNSS_MOUNT
Definition: cm_gnss.h:85
CM_GNSS_CONFIG_TYPE_DGNSS_PWD
@ CM_GNSS_CONFIG_TYPE_DGNSS_PWD
Definition: cm_gnss.h:84
CM_GNSS_CONFIG_TYPE_NMEA_PORT
@ CM_GNSS_CONFIG_TYPE_NMEA_PORT
Definition: cm_gnss.h:77
CM_AGNSS_UPDATE_VALID
@ CM_AGNSS_UPDATE_VALID
Definition: cm_gnss.h:107
CM_AGNSS_UPDATE_FAIL_JUDGE
@ CM_AGNSS_UPDATE_FAIL_JUDGE
Definition: cm_gnss.h:108
CM_AGNSS_UPDATE_INVALID
@ CM_AGNSS_UPDATE_INVALID
Definition: cm_gnss.h:106
CM_AGNSS_UPDATE_VOID
@ CM_AGNSS_UPDATE_VOID
Definition: cm_gnss.h:109
CM_GNSS_GLONASS
@ CM_GNSS_GLONASS
Definition: cm_gnss.h:59
CM_GNSS_GPS
@ CM_GNSS_GPS
Definition: cm_gnss.h:57
CM_GNSS_BDS_GPS
@ CM_GNSS_BDS_GPS
Definition: cm_gnss.h:60
CM_GNSS_GPS_GLONASS
@ CM_GNSS_GPS_GLONASS
Definition: cm_gnss.h:61
CM_GNSS_BDS_GPS_GLONASS
@ CM_GNSS_BDS_GPS_GLONASS
Definition: cm_gnss.h:63
CM_GNSS_BDS_GLONASS
@ CM_GNSS_BDS_GLONASS
Definition: cm_gnss.h:62
CM_GNSS_BDS
@ CM_GNSS_BDS
Definition: cm_gnss.h:58
cm_agnss_location_t
Definition: cm_gnss.h:66
cm_agnss_location_t::longitude
float longitude
Definition: cm_gnss.h:68
cm_agnss_location_t::mode
uint8_t mode
Definition: cm_gnss.h:69
cm_agnss_location_t::latitude
float latitude
Definition: cm_gnss.h:67
cm_gnss_location_info_t
Definition: cm_gnss.h:91
cm_gnss_location_info_t::longitude
float longitude
Definition: cm_gnss.h:93
cm_gnss_location_info_t::altitude
float altitude
Definition: cm_gnss.h:95
cm_gnss_location_info_t::dtype
uint8_t dtype
Definition: cm_gnss.h:101
cm_gnss_location_info_t::spkn
float spkn
Definition: cm_gnss.h:99
cm_gnss_location_info_t::cog
float cog
Definition: cm_gnss.h:97
cm_gnss_location_info_t::hdop
float hdop
Definition: cm_gnss.h:94
cm_gnss_location_info_t::spkm
float spkm
Definition: cm_gnss.h:98
cm_gnss_location_info_t::fix
uint8_t fix
Definition: cm_gnss.h:96
cm_gnss_location_info_t::latitude
float latitude
Definition: cm_gnss.h:92
cm_gnss_location_info_t::nsat
uint8_t nsat
Definition: cm_gnss.h:100


ML305A_ML307A_OpenCPU_API: cm_gpio.h 源文件

  • cmiot
cm_gpio.h
1
13 #ifndef __CM_GPIO_H__
14 #define __CM_GPIO_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 #include <stdbool.h>
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 /****************************************************************************
27 * Public Types
28 ****************************************************************************/
30 typedef enum{
31 CM_GPIO_NUM_0,
32 CM_GPIO_NUM_1,
33 CM_GPIO_NUM_2,
34 CM_GPIO_NUM_3,
35 CM_GPIO_NUM_4,
36 CM_GPIO_NUM_5,
37 CM_GPIO_NUM_6,
38 CM_GPIO_NUM_7,
39 CM_GPIO_NUM_8,
40 CM_GPIO_NUM_9,
41 CM_GPIO_NUM_10,
42 CM_GPIO_NUM_11,
43 CM_GPIO_NUM_12,
44 CM_GPIO_NUM_13,
45 CM_GPIO_NUM_14,
46 CM_GPIO_NUM_15,
47 CM_GPIO_NUM_16,
48 CM_GPIO_NUM_17,
49 CM_GPIO_NUM_18,
50 CM_GPIO_NUM_19,
51 CM_GPIO_NUM_20,
52 CM_GPIO_NUM_21,
53 CM_GPIO_NUM_22,
54 CM_GPIO_NUM_23,
55 CM_GPIO_NUM_24,
56 CM_GPIO_NUM_25,
57 CM_GPIO_NUM_26,
58 CM_GPIO_NUM_27,
59 CM_GPIO_NUM_28,
60 CM_GPIO_NUM_29,
61 CM_GPIO_NUM_30,
62 CM_GPIO_NUM_31,
63 CM_GPIO_NUM_32,
64 CM_GPIO_NUM_33,
65 CM_GPIO_NUM_34,
66 CM_GPIO_NUM_35,
67 CM_GPIO_NUM_36,
68 CM_GPIO_NUM_MAX
69 }cm_gpio_num_e;
70
71 /* *GPIO工作模式 */
72 typedef enum
73 {
74 CM_GPIO_MODE_NUM
75 } cm_gpio_mode_e;
76
78 typedef enum{
79 CM_GPIO_DIRECTION_INPUT = 0,
80 CM_GPIO_DIRECTION_OUTPUT,
81 }cm_gpio_direction_e;
82
84 typedef enum{
85 CM_GPIO_PULL_NONE,
86 CM_GPIO_PULL_DOWN,
87 CM_GPIO_PULL_UP,
88 }cm_gpio_pull_e;
89
91 typedef enum{
92 CM_GPIO_IT_EDGE_RISING,
93 CM_GPIO_IT_EDGE_FALLING,
94 CM_GPIO_IT_EDGE_BOTH,
95 CM_GPIO_IT_LEVEL_HIGH,
96 CM_GPIO_IT_LEVEL_LOW,
97 }cm_gpio_interrupt_e;
98
100 typedef enum{
101 CM_GPIO_LEVEL_LOW,
102 CM_GPIO_LEVEL_HIGH,
103 }cm_gpio_level_e;
104
106 typedef enum{
107 CM_GPIO_CMD_SET_PULL,
108 CM_GPIO_CMD_GET_PULL,
109 CM_GPIO_CMD_SET_LEVEL,
110 CM_GPIO_CMD_GET_LEVEL,
111 CM_GPIO_CMD_SET_DIRECTION,
112 CM_GPIO_CMD_GET_DIRECTION,
113 } cm_gpio_cmd_e;
114
116 typedef struct{
117 cm_gpio_mode_e mode;
118 cm_gpio_direction_e direction;
119 cm_gpio_pull_e pull;
120 } cm_gpio_cfg_t;
121
122 /****************************************************************************
123 * Public Data
124 ****************************************************************************/
125
126
127 /****************************************************************************
128 * Public Function Prototypes
129 ****************************************************************************/
130
131 /****************************************************************************
132 ***********************GPIO使用注意事项*************************************
133 * 1、GPIO引脚和SD卡控制引脚所用PIN脚存在复用关系，若用户使用此PIN脚进行
134 * GPIO功能开发，请阅知cm_sd.h中【SD卡使用注意事项】
135 * 2、GPIO引脚和SD卡控制引脚复用关系见《资源综述》
136 ***************************************************************************/
137
138 #ifdef __cplusplus
139 #define EXTERN extern "C"
140 extern "C"
141 {
142 #else
143 #define EXTERN extern
144 #endif
145
158 int32_t cm_gpio_init(cm_gpio_num_e gpio_num, cm_gpio_cfg_t *cfg);
159
171 int32_t cm_gpio_deinit(cm_gpio_num_e gpio_num);
172
185 int32_t cm_gpio_set_level(cm_gpio_num_e gpio_num, cm_gpio_level_e level);
186
199 int32_t cm_gpio_get_level(cm_gpio_num_e gpio_num, cm_gpio_level_e *level);
200
213 int32_t cm_gpio_set_pull(cm_gpio_num_e gpio_num, cm_gpio_pull_e type);
214
227 int32_t cm_gpio_get_pull(cm_gpio_num_e gpio_num, cm_gpio_pull_e *type);
228
241 int32_t cm_gpio_set_direction(cm_gpio_num_e gpio_num, cm_gpio_direction_e dir);
242
255 int32_t cm_gpio_get_direction(cm_gpio_num_e gpio_num, cm_gpio_direction_e *dir);
256
269 int32_t cm_gpio_interrupt_register(cm_gpio_num_e gpio_num, void *interrupt_cb);
270
283 int32_t cm_gpio_interrupt_enable(cm_gpio_num_e gpio_num, cm_gpio_interrupt_e intr_mode);
284
296 int32_t cm_gpio_interrupt_disable(cm_gpio_num_e gpio_num);
297
317 int32_t cm_gpio_ioctl(cm_gpio_num_e gpio_num, int32_t cmd, void *arg);
318
319 #undef EXTERN
320 #ifdef __cplusplus
321 }
322 #endif
323
324
325 #endif /* __CM_GPIO_H__ */
326
cm_gpio_ioctl
int32_t cm_gpio_ioctl(cm_gpio_num_e gpio_num, int32_t cmd, void *arg)
GPIO控制
cm_gpio_set_level
int32_t cm_gpio_set_level(cm_gpio_num_e gpio_num, cm_gpio_level_e level)
设置输出电平
cm_gpio_interrupt_disable
int32_t cm_gpio_interrupt_disable(cm_gpio_num_e gpio_num)
失能中断
cm_gpio_get_level
int32_t cm_gpio_get_level(cm_gpio_num_e gpio_num, cm_gpio_level_e *level)
读取输入电平
cm_gpio_interrupt_register
int32_t cm_gpio_interrupt_register(cm_gpio_num_e gpio_num, void *interrupt_cb)
注册中断回调函数
cm_gpio_interrupt_e
cm_gpio_interrupt_e
Definition: cm_gpio.h:91
cm_gpio_set_direction
int32_t cm_gpio_set_direction(cm_gpio_num_e gpio_num, cm_gpio_direction_e dir)
I/O方向模式配置
cm_gpio_set_pull
int32_t cm_gpio_set_pull(cm_gpio_num_e gpio_num, cm_gpio_pull_e type)
设置上/下拉
cm_gpio_pull_e
cm_gpio_pull_e
Definition: cm_gpio.h:84
cm_gpio_init
int32_t cm_gpio_init(cm_gpio_num_e gpio_num, cm_gpio_cfg_t *cfg)
初始化GPIO
cm_gpio_mode_e
cm_gpio_mode_e
Definition: cm_gpio.h:73
cm_gpio_direction_e
cm_gpio_direction_e
Definition: cm_gpio.h:78
cm_gpio_deinit
int32_t cm_gpio_deinit(cm_gpio_num_e gpio_num)
去初始化
cm_gpio_get_pull
int32_t cm_gpio_get_pull(cm_gpio_num_e gpio_num, cm_gpio_pull_e *type)
读取上/下拉
cm_gpio_interrupt_enable
int32_t cm_gpio_interrupt_enable(cm_gpio_num_e gpio_num, cm_gpio_interrupt_e intr_mode)
使能中断
cm_gpio_cmd_e
cm_gpio_cmd_e
Definition: cm_gpio.h:106
cm_gpio_get_direction
int32_t cm_gpio_get_direction(cm_gpio_num_e gpio_num, cm_gpio_direction_e *dir)
获取I/O方向模式配置
cm_gpio_num_e
cm_gpio_num_e
Definition: cm_gpio.h:30
cm_gpio_level_e
cm_gpio_level_e
Definition: cm_gpio.h:100
CM_GPIO_IT_EDGE_BOTH
@ CM_GPIO_IT_EDGE_BOTH
Definition: cm_gpio.h:94
CM_GPIO_IT_LEVEL_LOW
@ CM_GPIO_IT_LEVEL_LOW
Definition: cm_gpio.h:96
CM_GPIO_IT_EDGE_RISING
@ CM_GPIO_IT_EDGE_RISING
Definition: cm_gpio.h:92
CM_GPIO_IT_EDGE_FALLING
@ CM_GPIO_IT_EDGE_FALLING
Definition: cm_gpio.h:93
CM_GPIO_IT_LEVEL_HIGH
@ CM_GPIO_IT_LEVEL_HIGH
Definition: cm_gpio.h:95
CM_GPIO_PULL_DOWN
@ CM_GPIO_PULL_DOWN
Definition: cm_gpio.h:86
CM_GPIO_PULL_UP
@ CM_GPIO_PULL_UP
Definition: cm_gpio.h:87
CM_GPIO_PULL_NONE
@ CM_GPIO_PULL_NONE
Definition: cm_gpio.h:85
CM_GPIO_MODE_NUM
@ CM_GPIO_MODE_NUM
Definition: cm_gpio.h:74
CM_GPIO_DIRECTION_INPUT
@ CM_GPIO_DIRECTION_INPUT
Definition: cm_gpio.h:79
CM_GPIO_DIRECTION_OUTPUT
@ CM_GPIO_DIRECTION_OUTPUT
Definition: cm_gpio.h:80
CM_GPIO_CMD_SET_DIRECTION
@ CM_GPIO_CMD_SET_DIRECTION
Definition: cm_gpio.h:111
CM_GPIO_CMD_GET_DIRECTION
@ CM_GPIO_CMD_GET_DIRECTION
Definition: cm_gpio.h:112
CM_GPIO_CMD_GET_LEVEL
@ CM_GPIO_CMD_GET_LEVEL
Definition: cm_gpio.h:110
CM_GPIO_CMD_SET_PULL
@ CM_GPIO_CMD_SET_PULL
Definition: cm_gpio.h:107
CM_GPIO_CMD_GET_PULL
@ CM_GPIO_CMD_GET_PULL
Definition: cm_gpio.h:108
CM_GPIO_CMD_SET_LEVEL
@ CM_GPIO_CMD_SET_LEVEL
Definition: cm_gpio.h:109
CM_GPIO_NUM_2
@ CM_GPIO_NUM_2
Definition: cm_gpio.h:33
CM_GPIO_NUM_6
@ CM_GPIO_NUM_6
Definition: cm_gpio.h:37
CM_GPIO_NUM_35
@ CM_GPIO_NUM_35
Definition: cm_gpio.h:66
CM_GPIO_NUM_27
@ CM_GPIO_NUM_27
Definition: cm_gpio.h:58
CM_GPIO_NUM_22
@ CM_GPIO_NUM_22
Definition: cm_gpio.h:53
CM_GPIO_NUM_34
@ CM_GPIO_NUM_34
Definition: cm_gpio.h:65
CM_GPIO_NUM_26
@ CM_GPIO_NUM_26
Definition: cm_gpio.h:57
CM_GPIO_NUM_0
@ CM_GPIO_NUM_0
Definition: cm_gpio.h:31
CM_GPIO_NUM_36
@ CM_GPIO_NUM_36
Definition: cm_gpio.h:67
CM_GPIO_NUM_29
@ CM_GPIO_NUM_29
Definition: cm_gpio.h:60
CM_GPIO_NUM_33
@ CM_GPIO_NUM_33
Definition: cm_gpio.h:64
CM_GPIO_NUM_9
@ CM_GPIO_NUM_9
Definition: cm_gpio.h:40
CM_GPIO_NUM_32
@ CM_GPIO_NUM_32
Definition: cm_gpio.h:63
CM_GPIO_NUM_4
@ CM_GPIO_NUM_4
Definition: cm_gpio.h:35
CM_GPIO_NUM_MAX
@ CM_GPIO_NUM_MAX
Definition: cm_gpio.h:68
CM_GPIO_NUM_20
@ CM_GPIO_NUM_20
Definition: cm_gpio.h:51
CM_GPIO_NUM_14
@ CM_GPIO_NUM_14
Definition: cm_gpio.h:45
CM_GPIO_NUM_3
@ CM_GPIO_NUM_3
Definition: cm_gpio.h:34
CM_GPIO_NUM_12
@ CM_GPIO_NUM_12
Definition: cm_gpio.h:43
CM_GPIO_NUM_5
@ CM_GPIO_NUM_5
Definition: cm_gpio.h:36
CM_GPIO_NUM_30
@ CM_GPIO_NUM_30
Definition: cm_gpio.h:61
CM_GPIO_NUM_15
@ CM_GPIO_NUM_15
Definition: cm_gpio.h:46
CM_GPIO_NUM_13
@ CM_GPIO_NUM_13
Definition: cm_gpio.h:44
CM_GPIO_NUM_24
@ CM_GPIO_NUM_24
Definition: cm_gpio.h:55
CM_GPIO_NUM_8
@ CM_GPIO_NUM_8
Definition: cm_gpio.h:39
CM_GPIO_NUM_1
@ CM_GPIO_NUM_1
Definition: cm_gpio.h:32
CM_GPIO_NUM_25
@ CM_GPIO_NUM_25
Definition: cm_gpio.h:56
CM_GPIO_NUM_17
@ CM_GPIO_NUM_17
Definition: cm_gpio.h:48
CM_GPIO_NUM_23
@ CM_GPIO_NUM_23
Definition: cm_gpio.h:54
CM_GPIO_NUM_19
@ CM_GPIO_NUM_19
Definition: cm_gpio.h:50
CM_GPIO_NUM_16
@ CM_GPIO_NUM_16
Definition: cm_gpio.h:47
CM_GPIO_NUM_11
@ CM_GPIO_NUM_11
Definition: cm_gpio.h:42
CM_GPIO_NUM_18
@ CM_GPIO_NUM_18
Definition: cm_gpio.h:49
CM_GPIO_NUM_10
@ CM_GPIO_NUM_10
Definition: cm_gpio.h:41
CM_GPIO_NUM_31
@ CM_GPIO_NUM_31
Definition: cm_gpio.h:62
CM_GPIO_NUM_28
@ CM_GPIO_NUM_28
Definition: cm_gpio.h:59
CM_GPIO_NUM_21
@ CM_GPIO_NUM_21
Definition: cm_gpio.h:52
CM_GPIO_NUM_7
@ CM_GPIO_NUM_7
Definition: cm_gpio.h:38
CM_GPIO_LEVEL_LOW
@ CM_GPIO_LEVEL_LOW
Definition: cm_gpio.h:101
CM_GPIO_LEVEL_HIGH
@ CM_GPIO_LEVEL_HIGH
Definition: cm_gpio.h:102
cm_gpio_cfg_t
Definition: cm_gpio.h:116
cm_gpio_cfg_t::pull
cm_gpio_pull_e pull
Definition: cm_gpio.h:119
cm_gpio_cfg_t::mode
cm_gpio_mode_e mode
Definition: cm_gpio.h:117
cm_gpio_cfg_t::direction
cm_gpio_direction_e direction
Definition: cm_gpio.h:118


ML305A_ML307A_OpenCPU_API: cm_http.h 源文件

  • cmiot
cm_http.h
1
14 #ifndef __CM_HTTP_H__
15 #define __CM_HTTP_H__
16
17 #include <stdint.h>
18
19 #ifdef __cplusplus
20 extern "C"
21 {
22 #endif
23
28 #ifndef true
29 #define true (1)
30 #endif
31
32 #ifndef false
33 #define false (0)
34 #endif
35
36 #ifndef bool
37 #define bool int
38 #endif
39
40 #ifndef NULL
41 #define NULL ((void *)0)
42 #endif
43
45 #define HTTP_DEFAULT_PORT 80
46
48 #define HTTPS_DEFAULT_PORT 443
49
51 #define HTTPCLIENT_CTX_MAX_NUM 4
52
54 #define HTTPCLIENT_CONNECT_TIMEOUT_MAXTIME 180
55
57 #define HTTPCLIENT_WAITRSP_TIMEOUT_MAXTIME 60
58
60 #define HTTPCLIENT_CONNECT_TIMEOUT_DEFAULT 60
61
63 #define HTTPCLIENT_WAITRSP_TIMEOUT_DEFAULT 0
64
74 typedef enum {
75 HTTPCLIENT_REQUEST_NONE = 0,
76 HTTPCLIENT_REQUEST_GET,
77 HTTPCLIENT_REQUEST_POST,
78 HTTPCLIENT_REQUEST_PUT,
79 HTTPCLIENT_REQUEST_DELETE,
80 HTTPCLIENT_REQUEST_HEAD,
81 HTTPCLIENT_REQUEST_MAX
82 } cm_httpclient_request_type_e;
83
85 typedef enum{
86 CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND=1,
87 CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND,
88 CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND,
89 CM_HTTP_CALLBACK_EVENT_RSP_END_IND,
90 CM_HTTP_CALLBACK_EVENT_ERROR_IND,
91 }cm_httpclient_callback_event_e;
92
94 typedef enum{
95 CM_HTTP_EVENT_CODE_DNS_FAIL=1,
96 CM_HTTP_EVENT_CODE_CONNECT_FAIL,
97 CM_HTTP_EVENT_CODE_CONNECT_TIMEOUT,
98 CM_HTTP_EVENT_CODE_SSL_CONNECT_FAIL,
99 CM_HTTP_EVENT_CODE_CONNECT_BREAK,
100 CM_HTTP_EVENT_CODE_WAITRSP_TIMEOUT,
101 CM_HTTP_EVENT_CODE_DATA_PARSE_FAIL,
102 CM_HTTP_EVENT_CODE_CACHR_NOT_ENOUGH,
103 CM_HTTP_EVENT_CODE_DATA_DROP,
104 CM_HTTP_EVENT_CODE_WRITE_FILE_FAIL,
105 CM_HTTP_EVENT_CODE_UNKNOWN=255,
106 }cm_httpclient_error_event_e;
107
109 typedef enum{
110 CM_HTTP_RET_CODE_OK = 0,
111 CM_HTTP_RET_CODE_OPERATION_NOT_ALLOWED = 3,
112 CM_HTTP_RET_CODE_MALLOC_FAIL = 23,
113 CM_HTTP_RET_CODE_PARAM_ERROR = 50,
114 CM_HTTP_RET_CODE_UNKNOWN_ERROR = 650,
115 CM_HTTP_RET_CODE_NO_MORE_FREE_CLIENT = 651,
116 CM_HTTP_RET_CODE_CLIENT_NOT_CREATE = 652,
117 CM_HTTP_RET_CODE_CLIENT_IS_BUSY = 653,
118 CM_HTTP_RET_CODE_URL_PARSE_FAIL = 654,
119 CM_HTTP_RET_CODE_SSL_NOT_ENABLE = 655,
120 CM_HTTP_RET_CODE_CONNECT_FAIL = 656,
121 CM_HTTP_RET_CODE_SEND_DATA_FAIL = 657,
122 CM_HTTP_RET_CODE_OPEN_FILE_FAIL = 658,
123 } cm_httpclient_ret_code_e;
124
134 typedef void *cm_httpclient_handle_t;
135
137 /*
138 * @param [in] client_handle 客户端句柄
139 * @param [in] event 回调消息事件
140 * @param [in] param 事件相关对应响应数据
141 *
142 * CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND NULL
143 * CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND cm_httpclient_callback_rsp_header_param_t
144 * CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND cm_httpclient_callback_rsp_content_param_t
145 * CM_HTTP_CALLBACK_EVENT_RSP_END_IND NULL
146 * CM_HTTP_CALLBACK_EVENT_ERROR_IND cm_httpclient_error_event_e
147 */
148 typedef void (*cm_httpclient_event_callback_func)(cm_httpclient_handle_t client_handle, cm_httpclient_callback_event_e event, void *param);
149
151 typedef struct {
152 uint16_t response_code;
153 uint16_t response_header_len;
154 const uint8_t *response_header;
155 }cm_httpclient_callback_rsp_header_param_t;
156
158 typedef struct {
159 uint32_t total_len;
160 uint32_t sum_len;
161 uint32_t current_len;
162 const uint8_t *response_content;
163 }cm_httpclient_callback_rsp_content_param_t;
164
166 typedef struct {
167 uint8_t ssl_enable;
168 int32_t ssl_id;
169 uint8_t cid;
170 uint8_t conn_timeout;
171 uint8_t rsp_timeout;
172 uint8_t dns_priority;
173 }cm_httpclient_cfg_t;
174
176 typedef struct {
177 cm_httpclient_request_type_e method;
178 const uint8_t *path;
179 uint32_t content_length;
180 uint8_t *content;
181 }cm_httpclient_sync_param_t;
182
184 typedef struct {
185 uint32_t response_code;
186 uint32_t response_header_len;
187 uint32_t response_content_len;
188 uint8_t *response_header;
189 uint8_t *response_content;
190 }cm_httpclient_sync_response_t;
191
206 uint8_t *cm_httpclient_uri_encode(const uint8_t *src, const uint32_t len);
207
218 uint8_t *cm_httpclient_uri_encode_component(const uint8_t *src, const uint32_t len);
219
231 cm_httpclient_ret_code_e cm_httpclient_create(const uint8_t *url, cm_httpclient_event_callback_func callback, cm_httpclient_handle_t *handle);
232
242 cm_httpclient_ret_code_e cm_httpclient_delete(cm_httpclient_handle_t handle);
243
253 bool cm_httpclient_is_busy(cm_httpclient_handle_t handle);
254
265 cm_httpclient_ret_code_e cm_httpclient_set_cfg(cm_httpclient_handle_t handle, cm_httpclient_cfg_t cfg);
266
276 void cm_httpclient_terminate(cm_httpclient_handle_t handle);
277
291 cm_httpclient_ret_code_e cm_httpclient_custom_header_set(cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len);
292
302 cm_httpclient_ret_code_e cm_httpclient_custom_header_free(cm_httpclient_handle_t handle);
303
318 cm_httpclient_ret_code_e cm_httpclient_specific_header_set(cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len);
319
329 cm_httpclient_ret_code_e cm_httpclient_specific_header_free(cm_httpclient_handle_t handle);
330
345 cm_httpclient_ret_code_e cm_httpclient_request_start(cm_httpclient_handle_t handle, cm_httpclient_request_type_e method, const uint8_t *path,
346 bool chunked, uint32_t content_length);
347
360 cm_httpclient_ret_code_e cm_httpclient_request_send(cm_httpclient_handle_t handle, const uint8_t *content, uint32_t content_len);
361
371 cm_httpclient_ret_code_e cm_httpclient_request_end(cm_httpclient_handle_t handle);
372
382 int32_t cm_httpclient_get_response_code(cm_httpclient_handle_t handle);
383
396 uint32_t cm_httpclient_parse_header(const uint8_t *header, const uint8_t *key, uint8_t **value);
397
412 cm_httpclient_ret_code_e cm_httpclient_sync_request(cm_httpclient_handle_t handle, cm_httpclient_sync_param_t param,
413 cm_httpclient_sync_response_t *response);
414
424 void cm_httpclient_sync_free_data(cm_httpclient_handle_t handle);
425
426
431 #ifdef __cplusplus
432 }
433 #endif
434
435 #endif /* __CM_HTTP_H__ */
436
437
cm_httpclient_set_cfg
cm_httpclient_ret_code_e cm_httpclient_set_cfg(cm_httpclient_handle_t handle, cm_httpclient_cfg_t cfg)
客户端参数设置
cm_httpclient_get_response_code
int32_t cm_httpclient_get_response_code(cm_httpclient_handle_t handle)
获取响应结果码
cm_httpclient_uri_encode_component
uint8_t * cm_httpclient_uri_encode_component(const uint8_t *src, const uint32_t len)
uri编码(不对字母数字以及-_.!~*'()进行编码)
cm_httpclient_request_end
cm_httpclient_ret_code_e cm_httpclient_request_end(cm_httpclient_handle_t handle)
请求发送结束
cm_httpclient_specific_header_free
cm_httpclient_ret_code_e cm_httpclient_specific_header_free(cm_httpclient_handle_t handle)
释放特定报头
cm_httpclient_terminate
void cm_httpclient_terminate(cm_httpclient_handle_t handle)
终止http连接
cm_httpclient_custom_header_free
cm_httpclient_ret_code_e cm_httpclient_custom_header_free(cm_httpclient_handle_t handle)
释放通用报头
cm_httpclient_sync_request
cm_httpclient_ret_code_e cm_httpclient_sync_request(cm_httpclient_handle_t handle, cm_httpclient_sync_param_t param, cm_httpclient_sync_response_t *response)
发送请求(同步接口)
cm_httpclient_custom_header_set
cm_httpclient_ret_code_e cm_httpclient_custom_header_set(cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len)
设置通用报头
cm_httpclient_delete
cm_httpclient_ret_code_e cm_httpclient_delete(cm_httpclient_handle_t handle)
删除客户端实例
cm_httpclient_create
cm_httpclient_ret_code_e cm_httpclient_create(const uint8_t *url, cm_httpclient_event_callback_func callback, cm_httpclient_handle_t *handle)
创建客户端实例
cm_httpclient_uri_encode
uint8_t * cm_httpclient_uri_encode(const uint8_t *src, const uint32_t len)
uri编码(不对字母数字以及-_.!~*'();/?:&=+$,#进行编码)
cm_httpclient_parse_header
uint32_t cm_httpclient_parse_header(const uint8_t *header, const uint8_t *key, uint8_t **value)
解析报头
cm_httpclient_request_send
cm_httpclient_ret_code_e cm_httpclient_request_send(cm_httpclient_handle_t handle, const uint8_t *content, uint32_t content_len)
发送消息体
cm_httpclient_specific_header_set
cm_httpclient_ret_code_e cm_httpclient_specific_header_set(cm_httpclient_handle_t handle, uint8_t *header, uint16_t header_len)
设置特定报头
cm_httpclient_sync_free_data
void cm_httpclient_sync_free_data(cm_httpclient_handle_t handle)
释放响应数据(同步接口)
cm_httpclient_is_busy
bool cm_httpclient_is_busy(cm_httpclient_handle_t handle)
检测是否在执行请求
cm_httpclient_request_start
cm_httpclient_ret_code_e cm_httpclient_request_start(cm_httpclient_handle_t handle, cm_httpclient_request_type_e method, const uint8_t *path, bool chunked, uint32_t content_length)
开始发送请求
cm_httpclient_request_type_e
cm_httpclient_request_type_e
Definition: cm_http.h:74
cm_httpclient_callback_event_e
cm_httpclient_callback_event_e
Definition: cm_http.h:85
cm_httpclient_error_event_e
cm_httpclient_error_event_e
Definition: cm_http.h:94
cm_httpclient_ret_code_e
cm_httpclient_ret_code_e
Definition: cm_http.h:109
HTTPCLIENT_REQUEST_HEAD
@ HTTPCLIENT_REQUEST_HEAD
Definition: cm_http.h:80
HTTPCLIENT_REQUEST_POST
@ HTTPCLIENT_REQUEST_POST
Definition: cm_http.h:77
HTTPCLIENT_REQUEST_MAX
@ HTTPCLIENT_REQUEST_MAX
Definition: cm_http.h:81
HTTPCLIENT_REQUEST_GET
@ HTTPCLIENT_REQUEST_GET
Definition: cm_http.h:76
HTTPCLIENT_REQUEST_NONE
@ HTTPCLIENT_REQUEST_NONE
Definition: cm_http.h:75
HTTPCLIENT_REQUEST_PUT
@ HTTPCLIENT_REQUEST_PUT
Definition: cm_http.h:78
HTTPCLIENT_REQUEST_DELETE
@ HTTPCLIENT_REQUEST_DELETE
Definition: cm_http.h:79
CM_HTTP_CALLBACK_EVENT_ERROR_IND
@ CM_HTTP_CALLBACK_EVENT_ERROR_IND
Definition: cm_http.h:90
CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND
@ CM_HTTP_CALLBACK_EVENT_RSP_HEADER_IND
Definition: cm_http.h:87
CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND
@ CM_HTTP_CALLBACK_EVENT_REQ_START_SUCC_IND
Definition: cm_http.h:86
CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND
@ CM_HTTP_CALLBACK_EVENT_RSP_CONTENT_IND
Definition: cm_http.h:88
CM_HTTP_CALLBACK_EVENT_RSP_END_IND
@ CM_HTTP_CALLBACK_EVENT_RSP_END_IND
Definition: cm_http.h:89
CM_HTTP_EVENT_CODE_CONNECT_FAIL
@ CM_HTTP_EVENT_CODE_CONNECT_FAIL
Definition: cm_http.h:96
CM_HTTP_EVENT_CODE_CACHR_NOT_ENOUGH
@ CM_HTTP_EVENT_CODE_CACHR_NOT_ENOUGH
Definition: cm_http.h:102
CM_HTTP_EVENT_CODE_DATA_PARSE_FAIL
@ CM_HTTP_EVENT_CODE_DATA_PARSE_FAIL
Definition: cm_http.h:101
CM_HTTP_EVENT_CODE_DNS_FAIL
@ CM_HTTP_EVENT_CODE_DNS_FAIL
Definition: cm_http.h:95
CM_HTTP_EVENT_CODE_UNKNOWN
@ CM_HTTP_EVENT_CODE_UNKNOWN
Definition: cm_http.h:105
CM_HTTP_EVENT_CODE_WAITRSP_TIMEOUT
@ CM_HTTP_EVENT_CODE_WAITRSP_TIMEOUT
Definition: cm_http.h:100
CM_HTTP_EVENT_CODE_CONNECT_BREAK
@ CM_HTTP_EVENT_CODE_CONNECT_BREAK
Definition: cm_http.h:99
CM_HTTP_EVENT_CODE_SSL_CONNECT_FAIL
@ CM_HTTP_EVENT_CODE_SSL_CONNECT_FAIL
Definition: cm_http.h:98
CM_HTTP_EVENT_CODE_DATA_DROP
@ CM_HTTP_EVENT_CODE_DATA_DROP
Definition: cm_http.h:103
CM_HTTP_EVENT_CODE_WRITE_FILE_FAIL
@ CM_HTTP_EVENT_CODE_WRITE_FILE_FAIL
Definition: cm_http.h:104
CM_HTTP_EVENT_CODE_CONNECT_TIMEOUT
@ CM_HTTP_EVENT_CODE_CONNECT_TIMEOUT
Definition: cm_http.h:97
CM_HTTP_RET_CODE_MALLOC_FAIL
@ CM_HTTP_RET_CODE_MALLOC_FAIL
Definition: cm_http.h:112
CM_HTTP_RET_CODE_CONNECT_FAIL
@ CM_HTTP_RET_CODE_CONNECT_FAIL
Definition: cm_http.h:120
CM_HTTP_RET_CODE_PARAM_ERROR
@ CM_HTTP_RET_CODE_PARAM_ERROR
Definition: cm_http.h:113
CM_HTTP_RET_CODE_CLIENT_NOT_CREATE
@ CM_HTTP_RET_CODE_CLIENT_NOT_CREATE
Definition: cm_http.h:116
CM_HTTP_RET_CODE_OPEN_FILE_FAIL
@ CM_HTTP_RET_CODE_OPEN_FILE_FAIL
Definition: cm_http.h:122
CM_HTTP_RET_CODE_SSL_NOT_ENABLE
@ CM_HTTP_RET_CODE_SSL_NOT_ENABLE
Definition: cm_http.h:119
CM_HTTP_RET_CODE_OK
@ CM_HTTP_RET_CODE_OK
Definition: cm_http.h:110
CM_HTTP_RET_CODE_UNKNOWN_ERROR
@ CM_HTTP_RET_CODE_UNKNOWN_ERROR
Definition: cm_http.h:114
CM_HTTP_RET_CODE_NO_MORE_FREE_CLIENT
@ CM_HTTP_RET_CODE_NO_MORE_FREE_CLIENT
Definition: cm_http.h:115
CM_HTTP_RET_CODE_OPERATION_NOT_ALLOWED
@ CM_HTTP_RET_CODE_OPERATION_NOT_ALLOWED
Definition: cm_http.h:111
CM_HTTP_RET_CODE_URL_PARSE_FAIL
@ CM_HTTP_RET_CODE_URL_PARSE_FAIL
Definition: cm_http.h:118
CM_HTTP_RET_CODE_SEND_DATA_FAIL
@ CM_HTTP_RET_CODE_SEND_DATA_FAIL
Definition: cm_http.h:121
CM_HTTP_RET_CODE_CLIENT_IS_BUSY
@ CM_HTTP_RET_CODE_CLIENT_IS_BUSY
Definition: cm_http.h:117
cm_httpclient_handle_t
void * cm_httpclient_handle_t
Definition: cm_http.h:134
cm_httpclient_event_callback_func
void(* cm_httpclient_event_callback_func)(cm_httpclient_handle_t client_handle, cm_httpclient_callback_event_e event, void *param)
Definition: cm_http.h:148
cm_httpclient_callback_rsp_content_param_t
Definition: cm_http.h:158
cm_httpclient_callback_rsp_content_param_t::current_len
uint32_t current_len
Definition: cm_http.h:161
cm_httpclient_callback_rsp_content_param_t::total_len
uint32_t total_len
Definition: cm_http.h:159
cm_httpclient_callback_rsp_content_param_t::sum_len
uint32_t sum_len
Definition: cm_http.h:160
cm_httpclient_callback_rsp_content_param_t::response_content
const uint8_t * response_content
Definition: cm_http.h:162
cm_httpclient_callback_rsp_header_param_t
Definition: cm_http.h:151
cm_httpclient_callback_rsp_header_param_t::response_header
const uint8_t * response_header
Definition: cm_http.h:154
cm_httpclient_callback_rsp_header_param_t::response_header_len
uint16_t response_header_len
Definition: cm_http.h:153
cm_httpclient_callback_rsp_header_param_t::response_code
uint16_t response_code
Definition: cm_http.h:152
cm_httpclient_cfg_t
Definition: cm_http.h:166
cm_httpclient_cfg_t::conn_timeout
uint8_t conn_timeout
Definition: cm_http.h:170
cm_httpclient_cfg_t::rsp_timeout
uint8_t rsp_timeout
Definition: cm_http.h:171
cm_httpclient_cfg_t::ssl_id
int32_t ssl_id
Definition: cm_http.h:168
cm_httpclient_cfg_t::ssl_enable
uint8_t ssl_enable
Definition: cm_http.h:167
cm_httpclient_cfg_t::cid
uint8_t cid
Definition: cm_http.h:169
cm_httpclient_cfg_t::dns_priority
uint8_t dns_priority
Definition: cm_http.h:172
cm_httpclient_sync_param_t
Definition: cm_http.h:176
cm_httpclient_sync_param_t::path
const uint8_t * path
Definition: cm_http.h:178
cm_httpclient_sync_param_t::method
cm_httpclient_request_type_e method
Definition: cm_http.h:177
cm_httpclient_sync_param_t::content_length
uint32_t content_length
Definition: cm_http.h:179
cm_httpclient_sync_param_t::content
uint8_t * content
Definition: cm_http.h:180
cm_httpclient_sync_response_t
Definition: cm_http.h:184
cm_httpclient_sync_response_t::response_code
uint32_t response_code
Definition: cm_http.h:185
cm_httpclient_sync_response_t::response_header_len
uint32_t response_header_len
Definition: cm_http.h:186
cm_httpclient_sync_response_t::response_header
uint8_t * response_header
Definition: cm_http.h:188
cm_httpclient_sync_response_t::response_content
uint8_t * response_content
Definition: cm_http.h:189
cm_httpclient_sync_response_t::response_content_len
uint32_t response_content_len
Definition: cm_http.h:187


ML305A_ML307A_OpenCPU_API: cm_i2c.h 源文件

  • cmiot
cm_i2c.h
1
13 #ifndef __CM_I2C_H__
14 #define __CM_I2C_H__
15
16
17 /****************************************************************************
18 * Included Files
19 ****************************************************************************/
20
21 #include <stdint.h>
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27 /*仅支持以下时钟频率，不可任意更改*/
29 #define CM_I2C_CLK_100KHZ (100000U)
30 #define CM_I2C_CLK_400KHZ (400000U)
31
32 /****************************************************************************
33 * Public Types
34 ****************************************************************************/
35
36
40 typedef enum
41 {
42 CM_I2C_DEV_0 = 0,
43 CM_I2C_DEV_1,
44 CM_I2C_DEV_2,
45 CM_I2C_DEV_NUM,
46 } cm_i2c_dev_e;
47
51 typedef enum
52 {
53 CM_I2C_MODE_MASTER = 0,
54 CM_I2C_MODE_SLAVER,
55 } cm_i2c_mode_e;
56
58 typedef enum
59 {
60 CM_I2C_ADDR_TYPE_7BIT,
61 CM_I2C_ADDR_TYPE_10BIT,
62 } cm_i2c_addr_type_e;
63
67 typedef struct
68 {
69 cm_i2c_addr_type_e addr_type;
70 cm_i2c_mode_e mode;
71 int clk;
72 } cm_i2c_cfg_t;
73
74 /****************************************************************************
75 * Public Data
76 ****************************************************************************/
77
78
79 /****************************************************************************
80 * Public Function Prototypes
81 ****************************************************************************/
82
83 #ifdef __cplusplus
84 #define EXTERN extern "C"
85 extern "C"
86 {
87 #else
88 #define EXTERN extern
89 #endif
90
102 int32_t cm_i2c_open(cm_i2c_dev_e dev, cm_i2c_cfg_t *cfg);
103
115 int32_t cm_i2c_close(cm_i2c_dev_e dev);
116
130 int32_t cm_i2c_write(cm_i2c_dev_e dev, uint16_t slave_addr, const void *data, uint32_t len);
131
145 int32_t cm_i2c_read(cm_i2c_dev_e dev, uint16_t slave_addr, void *data, uint32_t len);
146
147 #undef EXTERN
148 #ifdef __cplusplus
149 }
150 #endif
151
152 #endif /* __CM_I2C_H__ */
153
cm_i2c_read
int32_t cm_i2c_read(cm_i2c_dev_e dev, uint16_t slave_addr, void *data, uint32_t len)
i2c读数据
cm_i2c_addr_type_e
cm_i2c_addr_type_e
Definition: cm_i2c.h:59
cm_i2c_close
int32_t cm_i2c_close(cm_i2c_dev_e dev)
i2c关闭
cm_i2c_open
int32_t cm_i2c_open(cm_i2c_dev_e dev, cm_i2c_cfg_t *cfg)
i2c开启
cm_i2c_dev_e
cm_i2c_dev_e
I2C 通道
Definition: cm_i2c.h:41
cm_i2c_write
int32_t cm_i2c_write(cm_i2c_dev_e dev, uint16_t slave_addr, const void *data, uint32_t len)
i2c写数据
cm_i2c_mode_e
cm_i2c_mode_e
I2C 支持主从模式
Definition: cm_i2c.h:52
CM_I2C_ADDR_TYPE_10BIT
@ CM_I2C_ADDR_TYPE_10BIT
Definition: cm_i2c.h:61
CM_I2C_ADDR_TYPE_7BIT
@ CM_I2C_ADDR_TYPE_7BIT
Definition: cm_i2c.h:60
CM_I2C_DEV_1
@ CM_I2C_DEV_1
Definition: cm_i2c.h:43
CM_I2C_DEV_NUM
@ CM_I2C_DEV_NUM
Definition: cm_i2c.h:45
CM_I2C_DEV_0
@ CM_I2C_DEV_0
Definition: cm_i2c.h:42
CM_I2C_DEV_2
@ CM_I2C_DEV_2
Definition: cm_i2c.h:44
CM_I2C_MODE_MASTER
@ CM_I2C_MODE_MASTER
Definition: cm_i2c.h:53
CM_I2C_MODE_SLAVER
@ CM_I2C_MODE_SLAVER
Definition: cm_i2c.h:54
cm_i2c_cfg_t
I2C 配置
Definition: cm_i2c.h:68
cm_i2c_cfg_t::clk
int clk
Definition: cm_i2c.h:71
cm_i2c_cfg_t::addr_type
cm_i2c_addr_type_e addr_type
Definition: cm_i2c.h:69
cm_i2c_cfg_t::mode
cm_i2c_mode_e mode
Definition: cm_i2c.h:70


ML305A_ML307A_OpenCPU_API: cm_iomux.h 源文件

  • cmiot
cm_iomux.h
1
13 #ifndef __CM_IOMUX_H__
14 #define __CM_IOMUX_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 /****************************************************************************
22 * Public Types
23 ****************************************************************************/
25 typedef enum{
26 CM_IOMUX_PIN_0 = 0,
27 CM_IOMUX_PIN_1,
28 CM_IOMUX_PIN_2,
29 CM_IOMUX_PIN_3,
30 CM_IOMUX_PIN_4,
31 CM_IOMUX_PIN_5,
32 CM_IOMUX_PIN_6,
33 CM_IOMUX_PIN_7,
34 CM_IOMUX_PIN_8,
35 CM_IOMUX_PIN_9,
36 CM_IOMUX_PIN_10,
37 CM_IOMUX_PIN_11,
38 CM_IOMUX_PIN_12,
39 CM_IOMUX_PIN_13,
40 CM_IOMUX_PIN_14,
41 CM_IOMUX_PIN_15,
42 CM_IOMUX_PIN_16,
43 CM_IOMUX_PIN_17,
44 CM_IOMUX_PIN_18,
45 CM_IOMUX_PIN_19,
46 CM_IOMUX_PIN_20,
47 CM_IOMUX_PIN_21,
48 CM_IOMUX_PIN_22,
49 CM_IOMUX_PIN_23,
50 CM_IOMUX_PIN_24,
51 CM_IOMUX_PIN_25,
52 CM_IOMUX_PIN_26,
53 CM_IOMUX_PIN_27,
54 CM_IOMUX_PIN_28,
55 CM_IOMUX_PIN_29,
56 CM_IOMUX_PIN_30,
57 CM_IOMUX_PIN_31,
58 CM_IOMUX_PIN_32,
59 CM_IOMUX_PIN_33,
60 CM_IOMUX_PIN_34,
61 CM_IOMUX_PIN_35,
62 CM_IOMUX_PIN_36,
63 CM_IOMUX_PIN_37,
64 CM_IOMUX_PIN_38,
65 CM_IOMUX_PIN_39,
66 CM_IOMUX_PIN_40,
67 CM_IOMUX_PIN_41,
68 CM_IOMUX_PIN_42,
69 CM_IOMUX_PIN_43,
70 CM_IOMUX_PIN_44,
71 CM_IOMUX_PIN_45,
72 CM_IOMUX_PIN_46,
73 CM_IOMUX_PIN_47,
74 CM_IOMUX_PIN_48,
75 CM_IOMUX_PIN_49,
76 CM_IOMUX_PIN_50,
77 CM_IOMUX_PIN_51,
78 CM_IOMUX_PIN_52,
79 CM_IOMUX_PIN_53,
80 CM_IOMUX_PIN_54,
81 CM_IOMUX_PIN_55,
82 CM_IOMUX_PIN_56,
83 CM_IOMUX_PIN_57,
84 CM_IOMUX_PIN_58,
85 CM_IOMUX_PIN_59,
86 CM_IOMUX_PIN_60,
87 CM_IOMUX_PIN_61,
88 CM_IOMUX_PIN_62,
89 CM_IOMUX_PIN_63,
90 CM_IOMUX_PIN_64,
91 CM_IOMUX_PIN_65,
92 CM_IOMUX_PIN_66,
93 CM_IOMUX_PIN_67,
94 CM_IOMUX_PIN_68,
95 CM_IOMUX_PIN_69,
96 CM_IOMUX_PIN_70,
97 CM_IOMUX_PIN_71,
98 CM_IOMUX_PIN_72,
99 CM_IOMUX_PIN_73,
100 CM_IOMUX_PIN_74,
101 CM_IOMUX_PIN_75,
102 CM_IOMUX_PIN_76,
103 CM_IOMUX_PIN_77,
104 CM_IOMUX_PIN_78,
105 CM_IOMUX_PIN_79,
106 CM_IOMUX_PIN_80,
107 CM_IOMUX_PIN_81,
108 CM_IOMUX_PIN_82,
109 CM_IOMUX_PIN_83,
110 CM_IOMUX_PIN_84,
111 CM_IOMUX_PIN_85,
112 CM_IOMUX_PIN_86,
113 CM_IOMUX_PIN_87,
114 CM_IOMUX_PIN_88,
115 CM_IOMUX_PIN_89,
116 CM_IOMUX_PIN_90,
117 CM_IOMUX_PIN_91,
118 CM_IOMUX_PIN_92,
119 CM_IOMUX_PIN_93,
120 CM_IOMUX_PIN_94,
121 CM_IOMUX_PIN_95,
122 CM_IOMUX_PIN_96,
123 CM_IOMUX_PIN_97,
124 CM_IOMUX_PIN_98,
125 CM_IOMUX_PIN_99,
126 CM_IOMUX_PIN_100,
127 CM_IOMUX_PIN_101,
128 CM_IOMUX_PIN_102,
129 CM_IOMUX_PIN_103,
130 CM_IOMUX_PIN_104,
131 CM_IOMUX_PIN_105,
132 CM_IOMUX_PIN_106,
133 CM_IOMUX_PIN_107,
134 CM_IOMUX_PIN_108,
135 CM_IOMUX_PIN_109,
136 CM_IOMUX_PIN_110,
137 CM_IOMUX_PIN_111,
138 CM_IOMUX_PIN_112,
139 CM_IOMUX_PIN_113,
140 CM_IOMUX_PIN_114,
141 CM_IOMUX_PIN_115,
142 CM_IOMUX_PIN_116,
143 CM_IOMUX_PIN_117,
144 CM_IOMUX_PIN_118,
145 CM_IOMUX_PIN_119,
146 CM_IOMUX_PIN_120,
147 CM_IOMUX_PIN_121,
148 CM_IOMUX_PIN_122,
149 CM_IOMUX_PIN_123,
150 CM_IOMUX_PIN_124,
151 CM_IOMUX_PIN_125,
152 CM_IOMUX_PIN_126,
153 CM_IOMUX_PIN_127,
154 CM_IOMUX_PIN_128,
155 CM_IOMUX_PIN_129,
156 CM_IOMUX_PIN_130,
157 CM_IOMUX_PIN_131,
158 CM_IOMUX_PIN_132,
159 CM_IOMUX_PIN_133,
160 CM_IOMUX_PIN_134,
161 CM_IOMUX_PIN_135,
162 CM_IOMUX_PIN_136,
163 CM_IOMUX_PIN_137,
164 CM_IOMUX_PIN_138,
165 CM_IOMUX_PIN_139,
166 CM_IOMUX_PIN_140,
167 CM_IOMUX_PIN_141,
168 CM_IOMUX_PIN_142,
169 CM_IOMUX_PIN_143,
170 CM_IOMUX_PIN_144,
171 CM_IOMUX_PIN_145,
172 CM_IOMUX_PIN_146,
173 CM_IOMUX_PIN_147,
174 CM_IOMUX_PIN_148,
175 CM_IOMUX_PIN_149,
176 CM_IOMUX_PIN_150,
177 CM_IOMUX_PIN_151,
178 CM_IOMUX_PIN_152,
179 CM_IOMUX_PIN_153,
180 CM_IOMUX_PIN_154,
181 CM_IOMUX_PIN_MAX
182 } cm_iomux_pin_e;
183
184 /*IOMUX FUNC definition */
185 typedef enum{
186 CM_IOMUX_FUNC_FUNCTION0 ,
187 CM_IOMUX_FUNC_FUNCTION1,
188 CM_IOMUX_FUNC_FUNCTION2,
189 CM_IOMUX_FUNC_FUNCTION3,
190 CM_IOMUX_FUNC_FUNCTIONNUM_END,
191 } cm_iomux_func_e;
192
193
194 /*IOMUX PIN cmd*/
195 typedef enum{
196 CM_IOMUX_PINCMD0_SLEEP ,
197 CM_IOMUX_PINCMD1_LPMEDEG,
198 CM_IOMUX_PINCMD2_DRIVEABILITY,
199 CM_IOMUX_PINCMD3_PULL,
200 CM_IOMUX_PINCMDNUM_END
201 } cm_iomux_pincmd_e;
202
203 /*IOMUX PIN cmdnum enumeration*/
204 typedef enum{
205 CM_IOMUX_PINCMD0_FUNC0_SLEEP_NONE,
206 CM_IOMUX_PINCMD0_FUNC1_SLEEP_DIR,
207 CM_IOMUX_PINCMD0_FUNC2_SLEEP_DATA,
208 CM_IOMUX_PINCMD0_FUNC3_SLEEP_FLOAT,
209 CM_IOMUX_PINCMD0_FUNC4_SLEEP_OUTPUT_HIGH,
210 CM_IOMUX_PINCMD0_FUNC5_SLEEP_OUTPUT_LOW,
211 CM_IOMUX_PINCMD0_FUNCNUM_END
212 } cm_iomux_pincmd0_e;
213
214 typedef enum{
215 CM_IOMUX_PINCMD1_FUNC0_LPM_EDGE_NONE,
216 CM_IOMUX_PINCMD1_FUNC1_LPM_EDGE_RISE ,
217 CM_IOMUX_PINCMD1_FUNC2_LPM_EDGE_FALL,
218 CM_IOMUX_PINCMD1_FUNC3_EDGE_BOTH,
219 CM_IOMUX_PINCMD1_FUNCNUM_END
220 } cm_iomux_pincmd1_e;
221
222 typedef enum{
223 CM_IOMUX_PINCMD2_FUNC0_DRIVE_VERY_SLOW,
224 CM_IOMUX_PINCMD2_FUNC1_DRIVE_SLOW,
225 CM_IOMUX_PINCMD2_FUNC2_DRIVE_MEDIUM,
226 CM_IOMUX_PINCMD2_FUNC3_DRIVE_FAST,
227 CM_IOMUX_PINCMD2_FUNC4_MASK,
228 CM_IOMUX_PINCMD2_FUNCNUM_END
229 } cm_iomux_pincmd2_e;
230
231 typedef enum{
232 CM_IOMUX_PINCMD3_FUNC0_PULL_NONE,
233 CM_IOMUX_PINCMD3_FUNC1_PULL_LOW,
234 CM_IOMUX_PINCMD3_FUNC2_PULL_HIGH,
235 CM_IOMUX_PINCMD3_FUNC3_PULL_BOTH,
236 CM_IOMUX_PINCMD3_FUNC4_PULL_FLOAT,
237 CM_IOMUX_PINCMD3_FUNCNUM_END
238 } cm_iomux_pincmd3_e;
239
240 /****************************************************************************
241 * Pre-processor Definitions
242 ****************************************************************************/
243 /*IOMUX PIN FUNCTION definition*/
244
245
246 /****************************************************************************
247 * Public Data
248 ****************************************************************************/
249
250
251 /****************************************************************************
252 * Public Function Prototypes
253 ****************************************************************************/
254 #ifdef __cplusplus
255 #define EXTERN extern "C"
256 extern "C"
257 {
258 #else
259 #define EXTERN extern
260 #endif
261
272 int32_t cm_iomux_set_pin_func(cm_iomux_pin_e pin, cm_iomux_func_e fun);
273
284 int32_t cm_iomux_get_pin_func(cm_iomux_pin_e pin, cm_iomux_func_e *fun);
285
297 int32_t cm_iomux_set_pin_cmd(cm_iomux_pin_e pin, cm_iomux_pincmd_e cmd, uint8_t cmd_arg);
298
299
300 #undef EXTERN
301 #ifdef __cplusplus
302 }
303 #endif
304
305 #endif /* __CM_IOMUX_H__ */
306
cm_iomux_pin_e
cm_iomux_pin_e
Definition: cm_iomux.h:25
cm_iomux_pincmd0_e
cm_iomux_pincmd0_e
Definition: cm_iomux.h:204
cm_iomux_set_pin_func
int32_t cm_iomux_set_pin_func(cm_iomux_pin_e pin, cm_iomux_func_e fun)
IOMUX 设置引脚复用功能
cm_iomux_func_e
cm_iomux_func_e
Definition: cm_iomux.h:185
cm_iomux_pincmd1_e
cm_iomux_pincmd1_e
Definition: cm_iomux.h:214
cm_iomux_set_pin_cmd
int32_t cm_iomux_set_pin_cmd(cm_iomux_pin_e pin, cm_iomux_pincmd_e cmd, uint8_t cmd_arg)
IOMUX PIN脚控制
cm_iomux_get_pin_func
int32_t cm_iomux_get_pin_func(cm_iomux_pin_e pin, cm_iomux_func_e *fun)
IOMUX 获取引脚功能
cm_iomux_pincmd_e
cm_iomux_pincmd_e
Definition: cm_iomux.h:195
cm_iomux_pincmd2_e
cm_iomux_pincmd2_e
Definition: cm_iomux.h:222
cm_iomux_pincmd3_e
cm_iomux_pincmd3_e
Definition: cm_iomux.h:231
CM_IOMUX_PIN_55
@ CM_IOMUX_PIN_55
Definition: cm_iomux.h:81
CM_IOMUX_PIN_92
@ CM_IOMUX_PIN_92
Definition: cm_iomux.h:118
CM_IOMUX_PIN_84
@ CM_IOMUX_PIN_84
Definition: cm_iomux.h:110
CM_IOMUX_PIN_97
@ CM_IOMUX_PIN_97
Definition: cm_iomux.h:123
CM_IOMUX_PIN_104
@ CM_IOMUX_PIN_104
Definition: cm_iomux.h:130
CM_IOMUX_PIN_36
@ CM_IOMUX_PIN_36
Definition: cm_iomux.h:62
CM_IOMUX_PIN_27
@ CM_IOMUX_PIN_27
Definition: cm_iomux.h:53
CM_IOMUX_PIN_102
@ CM_IOMUX_PIN_102
Definition: cm_iomux.h:128
CM_IOMUX_PIN_5
@ CM_IOMUX_PIN_5
Definition: cm_iomux.h:31
CM_IOMUX_PIN_53
@ CM_IOMUX_PIN_53
Definition: cm_iomux.h:79
CM_IOMUX_PIN_105
@ CM_IOMUX_PIN_105
Definition: cm_iomux.h:131
CM_IOMUX_PIN_15
@ CM_IOMUX_PIN_15
Definition: cm_iomux.h:41
CM_IOMUX_PIN_51
@ CM_IOMUX_PIN_51
Definition: cm_iomux.h:77
CM_IOMUX_PIN_148
@ CM_IOMUX_PIN_148
Definition: cm_iomux.h:174
CM_IOMUX_PIN_2
@ CM_IOMUX_PIN_2
Definition: cm_iomux.h:28
CM_IOMUX_PIN_68
@ CM_IOMUX_PIN_68
Definition: cm_iomux.h:94
CM_IOMUX_PIN_35
@ CM_IOMUX_PIN_35
Definition: cm_iomux.h:61
CM_IOMUX_PIN_141
@ CM_IOMUX_PIN_141
Definition: cm_iomux.h:167
CM_IOMUX_PIN_0
@ CM_IOMUX_PIN_0
Definition: cm_iomux.h:26
CM_IOMUX_PIN_43
@ CM_IOMUX_PIN_43
Definition: cm_iomux.h:69
CM_IOMUX_PIN_MAX
@ CM_IOMUX_PIN_MAX
Definition: cm_iomux.h:181
CM_IOMUX_PIN_74
@ CM_IOMUX_PIN_74
Definition: cm_iomux.h:100
CM_IOMUX_PIN_116
@ CM_IOMUX_PIN_116
Definition: cm_iomux.h:142
CM_IOMUX_PIN_144
@ CM_IOMUX_PIN_144
Definition: cm_iomux.h:170
CM_IOMUX_PIN_142
@ CM_IOMUX_PIN_142
Definition: cm_iomux.h:168
CM_IOMUX_PIN_81
@ CM_IOMUX_PIN_81
Definition: cm_iomux.h:107
CM_IOMUX_PIN_99
@ CM_IOMUX_PIN_99
Definition: cm_iomux.h:125
CM_IOMUX_PIN_65
@ CM_IOMUX_PIN_65
Definition: cm_iomux.h:91
CM_IOMUX_PIN_42
@ CM_IOMUX_PIN_42
Definition: cm_iomux.h:68
CM_IOMUX_PIN_3
@ CM_IOMUX_PIN_3
Definition: cm_iomux.h:29
CM_IOMUX_PIN_138
@ CM_IOMUX_PIN_138
Definition: cm_iomux.h:164
CM_IOMUX_PIN_71
@ CM_IOMUX_PIN_71
Definition: cm_iomux.h:97
CM_IOMUX_PIN_20
@ CM_IOMUX_PIN_20
Definition: cm_iomux.h:46
CM_IOMUX_PIN_37
@ CM_IOMUX_PIN_37
Definition: cm_iomux.h:63
CM_IOMUX_PIN_25
@ CM_IOMUX_PIN_25
Definition: cm_iomux.h:51
CM_IOMUX_PIN_59
@ CM_IOMUX_PIN_59
Definition: cm_iomux.h:85
CM_IOMUX_PIN_22
@ CM_IOMUX_PIN_22
Definition: cm_iomux.h:48
CM_IOMUX_PIN_21
@ CM_IOMUX_PIN_21
Definition: cm_iomux.h:47
CM_IOMUX_PIN_49
@ CM_IOMUX_PIN_49
Definition: cm_iomux.h:75
CM_IOMUX_PIN_100
@ CM_IOMUX_PIN_100
Definition: cm_iomux.h:126
CM_IOMUX_PIN_106
@ CM_IOMUX_PIN_106
Definition: cm_iomux.h:132
CM_IOMUX_PIN_133
@ CM_IOMUX_PIN_133
Definition: cm_iomux.h:159
CM_IOMUX_PIN_121
@ CM_IOMUX_PIN_121
Definition: cm_iomux.h:147
CM_IOMUX_PIN_127
@ CM_IOMUX_PIN_127
Definition: cm_iomux.h:153
CM_IOMUX_PIN_54
@ CM_IOMUX_PIN_54
Definition: cm_iomux.h:80
CM_IOMUX_PIN_131
@ CM_IOMUX_PIN_131
Definition: cm_iomux.h:157
CM_IOMUX_PIN_154
@ CM_IOMUX_PIN_154
Definition: cm_iomux.h:180
CM_IOMUX_PIN_48
@ CM_IOMUX_PIN_48
Definition: cm_iomux.h:74
CM_IOMUX_PIN_134
@ CM_IOMUX_PIN_134
Definition: cm_iomux.h:160
CM_IOMUX_PIN_85
@ CM_IOMUX_PIN_85
Definition: cm_iomux.h:111
CM_IOMUX_PIN_124
@ CM_IOMUX_PIN_124
Definition: cm_iomux.h:150
CM_IOMUX_PIN_72
@ CM_IOMUX_PIN_72
Definition: cm_iomux.h:98
CM_IOMUX_PIN_18
@ CM_IOMUX_PIN_18
Definition: cm_iomux.h:44
CM_IOMUX_PIN_52
@ CM_IOMUX_PIN_52
Definition: cm_iomux.h:78
CM_IOMUX_PIN_66
@ CM_IOMUX_PIN_66
Definition: cm_iomux.h:92
CM_IOMUX_PIN_57
@ CM_IOMUX_PIN_57
Definition: cm_iomux.h:83
CM_IOMUX_PIN_123
@ CM_IOMUX_PIN_123
Definition: cm_iomux.h:149
CM_IOMUX_PIN_128
@ CM_IOMUX_PIN_128
Definition: cm_iomux.h:154
CM_IOMUX_PIN_80
@ CM_IOMUX_PIN_80
Definition: cm_iomux.h:106
CM_IOMUX_PIN_95
@ CM_IOMUX_PIN_95
Definition: cm_iomux.h:121
CM_IOMUX_PIN_39
@ CM_IOMUX_PIN_39
Definition: cm_iomux.h:65
CM_IOMUX_PIN_125
@ CM_IOMUX_PIN_125
Definition: cm_iomux.h:151
CM_IOMUX_PIN_96
@ CM_IOMUX_PIN_96
Definition: cm_iomux.h:122
CM_IOMUX_PIN_87
@ CM_IOMUX_PIN_87
Definition: cm_iomux.h:113
CM_IOMUX_PIN_117
@ CM_IOMUX_PIN_117
Definition: cm_iomux.h:143
CM_IOMUX_PIN_149
@ CM_IOMUX_PIN_149
Definition: cm_iomux.h:175
CM_IOMUX_PIN_135
@ CM_IOMUX_PIN_135
Definition: cm_iomux.h:161
CM_IOMUX_PIN_8
@ CM_IOMUX_PIN_8
Definition: cm_iomux.h:34
CM_IOMUX_PIN_93
@ CM_IOMUX_PIN_93
Definition: cm_iomux.h:119
CM_IOMUX_PIN_24
@ CM_IOMUX_PIN_24
Definition: cm_iomux.h:50
CM_IOMUX_PIN_19
@ CM_IOMUX_PIN_19
Definition: cm_iomux.h:45
CM_IOMUX_PIN_31
@ CM_IOMUX_PIN_31
Definition: cm_iomux.h:57
CM_IOMUX_PIN_150
@ CM_IOMUX_PIN_150
Definition: cm_iomux.h:176
CM_IOMUX_PIN_109
@ CM_IOMUX_PIN_109
Definition: cm_iomux.h:135
CM_IOMUX_PIN_120
@ CM_IOMUX_PIN_120
Definition: cm_iomux.h:146
CM_IOMUX_PIN_108
@ CM_IOMUX_PIN_108
Definition: cm_iomux.h:134
CM_IOMUX_PIN_78
@ CM_IOMUX_PIN_78
Definition: cm_iomux.h:104
CM_IOMUX_PIN_137
@ CM_IOMUX_PIN_137
Definition: cm_iomux.h:163
CM_IOMUX_PIN_70
@ CM_IOMUX_PIN_70
Definition: cm_iomux.h:96
CM_IOMUX_PIN_60
@ CM_IOMUX_PIN_60
Definition: cm_iomux.h:86
CM_IOMUX_PIN_139
@ CM_IOMUX_PIN_139
Definition: cm_iomux.h:165
CM_IOMUX_PIN_90
@ CM_IOMUX_PIN_90
Definition: cm_iomux.h:116
CM_IOMUX_PIN_111
@ CM_IOMUX_PIN_111
Definition: cm_iomux.h:137
CM_IOMUX_PIN_101
@ CM_IOMUX_PIN_101
Definition: cm_iomux.h:127
CM_IOMUX_PIN_110
@ CM_IOMUX_PIN_110
Definition: cm_iomux.h:136
CM_IOMUX_PIN_122
@ CM_IOMUX_PIN_122
Definition: cm_iomux.h:148
CM_IOMUX_PIN_136
@ CM_IOMUX_PIN_136
Definition: cm_iomux.h:162
CM_IOMUX_PIN_151
@ CM_IOMUX_PIN_151
Definition: cm_iomux.h:177
CM_IOMUX_PIN_153
@ CM_IOMUX_PIN_153
Definition: cm_iomux.h:179
CM_IOMUX_PIN_114
@ CM_IOMUX_PIN_114
Definition: cm_iomux.h:140
CM_IOMUX_PIN_129
@ CM_IOMUX_PIN_129
Definition: cm_iomux.h:155
CM_IOMUX_PIN_47
@ CM_IOMUX_PIN_47
Definition: cm_iomux.h:73
CM_IOMUX_PIN_38
@ CM_IOMUX_PIN_38
Definition: cm_iomux.h:64
CM_IOMUX_PIN_69
@ CM_IOMUX_PIN_69
Definition: cm_iomux.h:95
CM_IOMUX_PIN_145
@ CM_IOMUX_PIN_145
Definition: cm_iomux.h:171
CM_IOMUX_PIN_115
@ CM_IOMUX_PIN_115
Definition: cm_iomux.h:141
CM_IOMUX_PIN_50
@ CM_IOMUX_PIN_50
Definition: cm_iomux.h:76
CM_IOMUX_PIN_67
@ CM_IOMUX_PIN_67
Definition: cm_iomux.h:93
CM_IOMUX_PIN_73
@ CM_IOMUX_PIN_73
Definition: cm_iomux.h:99
CM_IOMUX_PIN_140
@ CM_IOMUX_PIN_140
Definition: cm_iomux.h:166
CM_IOMUX_PIN_88
@ CM_IOMUX_PIN_88
Definition: cm_iomux.h:114
CM_IOMUX_PIN_76
@ CM_IOMUX_PIN_76
Definition: cm_iomux.h:102
CM_IOMUX_PIN_91
@ CM_IOMUX_PIN_91
Definition: cm_iomux.h:117
CM_IOMUX_PIN_61
@ CM_IOMUX_PIN_61
Definition: cm_iomux.h:87
CM_IOMUX_PIN_143
@ CM_IOMUX_PIN_143
Definition: cm_iomux.h:169
CM_IOMUX_PIN_132
@ CM_IOMUX_PIN_132
Definition: cm_iomux.h:158
CM_IOMUX_PIN_113
@ CM_IOMUX_PIN_113
Definition: cm_iomux.h:139
CM_IOMUX_PIN_147
@ CM_IOMUX_PIN_147
Definition: cm_iomux.h:173
CM_IOMUX_PIN_98
@ CM_IOMUX_PIN_98
Definition: cm_iomux.h:124
CM_IOMUX_PIN_17
@ CM_IOMUX_PIN_17
Definition: cm_iomux.h:43
CM_IOMUX_PIN_46
@ CM_IOMUX_PIN_46
Definition: cm_iomux.h:72
CM_IOMUX_PIN_4
@ CM_IOMUX_PIN_4
Definition: cm_iomux.h:30
CM_IOMUX_PIN_29
@ CM_IOMUX_PIN_29
Definition: cm_iomux.h:55
CM_IOMUX_PIN_16
@ CM_IOMUX_PIN_16
Definition: cm_iomux.h:42
CM_IOMUX_PIN_9
@ CM_IOMUX_PIN_9
Definition: cm_iomux.h:35
CM_IOMUX_PIN_28
@ CM_IOMUX_PIN_28
Definition: cm_iomux.h:54
CM_IOMUX_PIN_58
@ CM_IOMUX_PIN_58
Definition: cm_iomux.h:84
CM_IOMUX_PIN_13
@ CM_IOMUX_PIN_13
Definition: cm_iomux.h:39
CM_IOMUX_PIN_83
@ CM_IOMUX_PIN_83
Definition: cm_iomux.h:109
CM_IOMUX_PIN_34
@ CM_IOMUX_PIN_34
Definition: cm_iomux.h:60
CM_IOMUX_PIN_26
@ CM_IOMUX_PIN_26
Definition: cm_iomux.h:52
CM_IOMUX_PIN_32
@ CM_IOMUX_PIN_32
Definition: cm_iomux.h:58
CM_IOMUX_PIN_64
@ CM_IOMUX_PIN_64
Definition: cm_iomux.h:90
CM_IOMUX_PIN_12
@ CM_IOMUX_PIN_12
Definition: cm_iomux.h:38
CM_IOMUX_PIN_33
@ CM_IOMUX_PIN_33
Definition: cm_iomux.h:59
CM_IOMUX_PIN_79
@ CM_IOMUX_PIN_79
Definition: cm_iomux.h:105
CM_IOMUX_PIN_77
@ CM_IOMUX_PIN_77
Definition: cm_iomux.h:103
CM_IOMUX_PIN_11
@ CM_IOMUX_PIN_11
Definition: cm_iomux.h:37
CM_IOMUX_PIN_1
@ CM_IOMUX_PIN_1
Definition: cm_iomux.h:27
CM_IOMUX_PIN_89
@ CM_IOMUX_PIN_89
Definition: cm_iomux.h:115
CM_IOMUX_PIN_6
@ CM_IOMUX_PIN_6
Definition: cm_iomux.h:32
CM_IOMUX_PIN_75
@ CM_IOMUX_PIN_75
Definition: cm_iomux.h:101
CM_IOMUX_PIN_44
@ CM_IOMUX_PIN_44
Definition: cm_iomux.h:70
CM_IOMUX_PIN_112
@ CM_IOMUX_PIN_112
Definition: cm_iomux.h:138
CM_IOMUX_PIN_7
@ CM_IOMUX_PIN_7
Definition: cm_iomux.h:33
CM_IOMUX_PIN_152
@ CM_IOMUX_PIN_152
Definition: cm_iomux.h:178
CM_IOMUX_PIN_107
@ CM_IOMUX_PIN_107
Definition: cm_iomux.h:133
CM_IOMUX_PIN_63
@ CM_IOMUX_PIN_63
Definition: cm_iomux.h:89
CM_IOMUX_PIN_56
@ CM_IOMUX_PIN_56
Definition: cm_iomux.h:82
CM_IOMUX_PIN_40
@ CM_IOMUX_PIN_40
Definition: cm_iomux.h:66
CM_IOMUX_PIN_94
@ CM_IOMUX_PIN_94
Definition: cm_iomux.h:120
CM_IOMUX_PIN_82
@ CM_IOMUX_PIN_82
Definition: cm_iomux.h:108
CM_IOMUX_PIN_130
@ CM_IOMUX_PIN_130
Definition: cm_iomux.h:156
CM_IOMUX_PIN_146
@ CM_IOMUX_PIN_146
Definition: cm_iomux.h:172
CM_IOMUX_PIN_119
@ CM_IOMUX_PIN_119
Definition: cm_iomux.h:145
CM_IOMUX_PIN_103
@ CM_IOMUX_PIN_103
Definition: cm_iomux.h:129
CM_IOMUX_PIN_126
@ CM_IOMUX_PIN_126
Definition: cm_iomux.h:152
CM_IOMUX_PIN_41
@ CM_IOMUX_PIN_41
Definition: cm_iomux.h:67
CM_IOMUX_PIN_45
@ CM_IOMUX_PIN_45
Definition: cm_iomux.h:71
CM_IOMUX_PIN_30
@ CM_IOMUX_PIN_30
Definition: cm_iomux.h:56
CM_IOMUX_PIN_118
@ CM_IOMUX_PIN_118
Definition: cm_iomux.h:144
CM_IOMUX_PIN_86
@ CM_IOMUX_PIN_86
Definition: cm_iomux.h:112
CM_IOMUX_PIN_14
@ CM_IOMUX_PIN_14
Definition: cm_iomux.h:40
CM_IOMUX_PIN_23
@ CM_IOMUX_PIN_23
Definition: cm_iomux.h:49
CM_IOMUX_PIN_10
@ CM_IOMUX_PIN_10
Definition: cm_iomux.h:36
CM_IOMUX_PIN_62
@ CM_IOMUX_PIN_62
Definition: cm_iomux.h:88
CM_IOMUX_PINCMD0_FUNC3_SLEEP_FLOAT
@ CM_IOMUX_PINCMD0_FUNC3_SLEEP_FLOAT
Definition: cm_iomux.h:208
CM_IOMUX_PINCMD0_FUNC0_SLEEP_NONE
@ CM_IOMUX_PINCMD0_FUNC0_SLEEP_NONE
Definition: cm_iomux.h:205
CM_IOMUX_PINCMD0_FUNC1_SLEEP_DIR
@ CM_IOMUX_PINCMD0_FUNC1_SLEEP_DIR
Definition: cm_iomux.h:206
CM_IOMUX_PINCMD0_FUNC4_SLEEP_OUTPUT_HIGH
@ CM_IOMUX_PINCMD0_FUNC4_SLEEP_OUTPUT_HIGH
Definition: cm_iomux.h:209
CM_IOMUX_PINCMD0_FUNCNUM_END
@ CM_IOMUX_PINCMD0_FUNCNUM_END
Definition: cm_iomux.h:211
CM_IOMUX_PINCMD0_FUNC5_SLEEP_OUTPUT_LOW
@ CM_IOMUX_PINCMD0_FUNC5_SLEEP_OUTPUT_LOW
Definition: cm_iomux.h:210
CM_IOMUX_PINCMD0_FUNC2_SLEEP_DATA
@ CM_IOMUX_PINCMD0_FUNC2_SLEEP_DATA
Definition: cm_iomux.h:207
CM_IOMUX_FUNC_FUNCTION2
@ CM_IOMUX_FUNC_FUNCTION2
Definition: cm_iomux.h:188
CM_IOMUX_FUNC_FUNCTION1
@ CM_IOMUX_FUNC_FUNCTION1
Definition: cm_iomux.h:187
CM_IOMUX_FUNC_FUNCTIONNUM_END
@ CM_IOMUX_FUNC_FUNCTIONNUM_END
Definition: cm_iomux.h:190
CM_IOMUX_FUNC_FUNCTION3
@ CM_IOMUX_FUNC_FUNCTION3
Definition: cm_iomux.h:189
CM_IOMUX_FUNC_FUNCTION0
@ CM_IOMUX_FUNC_FUNCTION0
Definition: cm_iomux.h:186
CM_IOMUX_PINCMD1_FUNC3_EDGE_BOTH
@ CM_IOMUX_PINCMD1_FUNC3_EDGE_BOTH
Definition: cm_iomux.h:218
CM_IOMUX_PINCMD1_FUNCNUM_END
@ CM_IOMUX_PINCMD1_FUNCNUM_END
Definition: cm_iomux.h:219
CM_IOMUX_PINCMD1_FUNC1_LPM_EDGE_RISE
@ CM_IOMUX_PINCMD1_FUNC1_LPM_EDGE_RISE
Definition: cm_iomux.h:216
CM_IOMUX_PINCMD1_FUNC0_LPM_EDGE_NONE
@ CM_IOMUX_PINCMD1_FUNC0_LPM_EDGE_NONE
Definition: cm_iomux.h:215
CM_IOMUX_PINCMD1_FUNC2_LPM_EDGE_FALL
@ CM_IOMUX_PINCMD1_FUNC2_LPM_EDGE_FALL
Definition: cm_iomux.h:217
CM_IOMUX_PINCMD1_LPMEDEG
@ CM_IOMUX_PINCMD1_LPMEDEG
Definition: cm_iomux.h:197
CM_IOMUX_PINCMD0_SLEEP
@ CM_IOMUX_PINCMD0_SLEEP
Definition: cm_iomux.h:196
CM_IOMUX_PINCMDNUM_END
@ CM_IOMUX_PINCMDNUM_END
Definition: cm_iomux.h:200
CM_IOMUX_PINCMD2_DRIVEABILITY
@ CM_IOMUX_PINCMD2_DRIVEABILITY
Definition: cm_iomux.h:198
CM_IOMUX_PINCMD3_PULL
@ CM_IOMUX_PINCMD3_PULL
Definition: cm_iomux.h:199
CM_IOMUX_PINCMD2_FUNC2_DRIVE_MEDIUM
@ CM_IOMUX_PINCMD2_FUNC2_DRIVE_MEDIUM
Definition: cm_iomux.h:225
CM_IOMUX_PINCMD2_FUNCNUM_END
@ CM_IOMUX_PINCMD2_FUNCNUM_END
Definition: cm_iomux.h:228
CM_IOMUX_PINCMD2_FUNC0_DRIVE_VERY_SLOW
@ CM_IOMUX_PINCMD2_FUNC0_DRIVE_VERY_SLOW
Definition: cm_iomux.h:223
CM_IOMUX_PINCMD2_FUNC4_MASK
@ CM_IOMUX_PINCMD2_FUNC4_MASK
Definition: cm_iomux.h:227
CM_IOMUX_PINCMD2_FUNC3_DRIVE_FAST
@ CM_IOMUX_PINCMD2_FUNC3_DRIVE_FAST
Definition: cm_iomux.h:226
CM_IOMUX_PINCMD2_FUNC1_DRIVE_SLOW
@ CM_IOMUX_PINCMD2_FUNC1_DRIVE_SLOW
Definition: cm_iomux.h:224
CM_IOMUX_PINCMD3_FUNC2_PULL_HIGH
@ CM_IOMUX_PINCMD3_FUNC2_PULL_HIGH
Definition: cm_iomux.h:234
CM_IOMUX_PINCMD3_FUNC3_PULL_BOTH
@ CM_IOMUX_PINCMD3_FUNC3_PULL_BOTH
Definition: cm_iomux.h:235
CM_IOMUX_PINCMD3_FUNC1_PULL_LOW
@ CM_IOMUX_PINCMD3_FUNC1_PULL_LOW
Definition: cm_iomux.h:233
CM_IOMUX_PINCMD3_FUNC4_PULL_FLOAT
@ CM_IOMUX_PINCMD3_FUNC4_PULL_FLOAT
Definition: cm_iomux.h:236
CM_IOMUX_PINCMD3_FUNCNUM_END
@ CM_IOMUX_PINCMD3_FUNCNUM_END
Definition: cm_iomux.h:237
CM_IOMUX_PINCMD3_FUNC0_PULL_NONE
@ CM_IOMUX_PINCMD3_FUNC0_PULL_NONE
Definition: cm_iomux.h:232


ML305A_ML307A_OpenCPU_API: cm_keypad.h 源文件

  • cmiot
cm_keypad.h
1
13 #ifndef __CM_KEYPAD_H__
14 #define __CM_KEYPAD_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26
27 /****************************************************************************
28 * Public Types
29 ****************************************************************************/
30
31 /****************************************************************************
32 * Public Data
33 ****************************************************************************/
34
35
36 /****************************************************************************
37 * Public Function Prototypes
38 ****************************************************************************/
39
40 #ifdef __cplusplus
41 #define EXTERN extern "C"
42 extern "C"
43 {
44 #else
45 #define EXTERN extern
46 #endif
47
48 /****************************************************************************/
49
54 typedef uint32_t cm_keypad_map_t;
55
60 typedef enum
61 {
62 CM_KEY_EVENT_RELEASE = 0,
63 CM_KEY_EVENT_PRESS = 1,
64 } cm_keypad_event_e;
65
66 /*具体配置参照资源综述*/
67 typedef enum cm_keypad_kp_mkin{
68 CM_KP_MKI0 = 0,
69 CM_KP_MKI1,
70 CM_KP_MKI2,
71 CM_KP_MKI3,
72 CM_KP_MKI4,
73 CM_KP_MKI5,
74 CM_KP_MKI6,
75 CM_KP_MKI7,
76 CM_KP_MKI_NO_VALID
77 }cm_keypad_kp_mkin_e;
78
79 /*具体配置参照资源综述*/
80 typedef enum cm_keypad_kp_mkout{
81 CM_KP_MKO0 = 0,
82 CM_KP_MKO1,
83 CM_KP_MKO2,
84 CM_KP_MKO3,
85 CM_KP_MKO4,
86 CM_KP_MKO5,
87 CM_KP_MKO6,
88 CM_KP_MKO7,
89 CM_KP_MKO_NO_VALID
90 }cm_keypad_kp_mkout_e;
91
93 typedef struct{
94 cm_keypad_kp_mkin_e *cm_col;
95 cm_keypad_kp_mkout_e *cm_row;
96 uint8_t cm_col_len;//*cm_col长度
97 uint8_t cm_row_len;//*cm_cow长度
98 } cm_keypad_cfg_t;
99
107 typedef void (*cm_key_event_callback_t)(cm_keypad_map_t key, cm_keypad_event_e event);
108
121 int32_t cm_keypad_config(cm_keypad_cfg_t *cm_keypad_cfg);
122
123
131 int32_t cm_keypad_init(void);
132
144 int32_t cm_keypad_register(cm_key_event_callback_t cb);
145
157 int32_t cm_keypad_unregister(cm_key_event_callback_t cb);
158
164 void cm_keypad_deinit(void);
165
166 #undef EXTERN
167 #ifdef __cplusplus
168 }
169 #endif
170
171 #endif /* __CM_KEYPAD_H__ */
172
cm_keypad_kp_mkin_e
enum cm_keypad_kp_mkin cm_keypad_kp_mkin_e
cm_keypad_init
int32_t cm_keypad_init(void)
keypad初始化
cm_keypad_kp_mkout
cm_keypad_kp_mkout
Definition: cm_keypad.h:80
cm_keypad_kp_mkout_e
enum cm_keypad_kp_mkout cm_keypad_kp_mkout_e
cm_key_event_callback_t
void(* cm_key_event_callback_t)(cm_keypad_map_t key, cm_keypad_event_e event)
keypad事件回调函数
Definition: cm_keypad.h:107
cm_keypad_config
int32_t cm_keypad_config(cm_keypad_cfg_t *cm_keypad_cfg)
keypad配置
cm_keypad_unregister
int32_t cm_keypad_unregister(cm_key_event_callback_t cb)
keypad事件回调注销
cm_keypad_register
int32_t cm_keypad_register(cm_key_event_callback_t cb)
keypad事件回调注册
cm_keypad_map_t
uint32_t cm_keypad_map_t
key map
Definition: cm_keypad.h:54
cm_keypad_deinit
void cm_keypad_deinit(void)
keypad去初始化
cm_keypad_kp_mkin
cm_keypad_kp_mkin
Definition: cm_keypad.h:67
cm_keypad_event_e
cm_keypad_event_e
key事件类型
Definition: cm_keypad.h:61
CM_KP_MKO1
@ CM_KP_MKO1
Definition: cm_keypad.h:82
CM_KP_MKO2
@ CM_KP_MKO2
Definition: cm_keypad.h:83
CM_KP_MKO_NO_VALID
@ CM_KP_MKO_NO_VALID
Definition: cm_keypad.h:89
CM_KP_MKO7
@ CM_KP_MKO7
Definition: cm_keypad.h:88
CM_KP_MKO6
@ CM_KP_MKO6
Definition: cm_keypad.h:87
CM_KP_MKO4
@ CM_KP_MKO4
Definition: cm_keypad.h:85
CM_KP_MKO5
@ CM_KP_MKO5
Definition: cm_keypad.h:86
CM_KP_MKO0
@ CM_KP_MKO0
Definition: cm_keypad.h:81
CM_KP_MKO3
@ CM_KP_MKO3
Definition: cm_keypad.h:84
CM_KP_MKI4
@ CM_KP_MKI4
Definition: cm_keypad.h:72
CM_KP_MKI2
@ CM_KP_MKI2
Definition: cm_keypad.h:70
CM_KP_MKI1
@ CM_KP_MKI1
Definition: cm_keypad.h:69
CM_KP_MKI5
@ CM_KP_MKI5
Definition: cm_keypad.h:73
CM_KP_MKI_NO_VALID
@ CM_KP_MKI_NO_VALID
Definition: cm_keypad.h:76
CM_KP_MKI3
@ CM_KP_MKI3
Definition: cm_keypad.h:71
CM_KP_MKI6
@ CM_KP_MKI6
Definition: cm_keypad.h:74
CM_KP_MKI7
@ CM_KP_MKI7
Definition: cm_keypad.h:75
CM_KP_MKI0
@ CM_KP_MKI0
Definition: cm_keypad.h:68
CM_KEY_EVENT_RELEASE
@ CM_KEY_EVENT_RELEASE
Definition: cm_keypad.h:62
CM_KEY_EVENT_PRESS
@ CM_KEY_EVENT_PRESS
Definition: cm_keypad.h:63
cm_keypad_cfg_t
Definition: cm_keypad.h:93
cm_keypad_cfg_t::cm_row_len
uint8_t cm_row_len
Definition: cm_keypad.h:97
cm_keypad_cfg_t::cm_row
cm_keypad_kp_mkout_e * cm_row
Definition: cm_keypad.h:95
cm_keypad_cfg_t::cm_col
cm_keypad_kp_mkin_e * cm_col
Definition: cm_keypad.h:94
cm_keypad_cfg_t::cm_col_len
uint8_t cm_col_len
Definition: cm_keypad.h:96


ML305A_ML307A_OpenCPU_API: cm_lbs.h 源文件

  • cmiot
cm_lbs.h
1
18 #ifndef __CM_LBS_H__
19 #define __CM_LBS_H__
20
21
22 /****************************************************************************
23 * Included Files
24 ****************************************************************************/
25 #include <stdint.h>
26
27 /****************************************************************************
28 * Pre-processor Definitions
29 ****************************************************************************/
30 #define CM_LBS_NVCONFIG_ONEOSPOS_PIDLEN (64)
31 #define CM_LBS_NVCONFIG_AMAP_KEYLEN (128)
32 #define CM_LBS_NVCONFIG_AMAP_SIGNALEN (128)
33
34
35
36 /****************************************************************************
37 * Public Types
38 ****************************************************************************/
40 typedef enum
41 {
42 CM_LBS_PLAT_START,
43 CM_LBS_PLAT_AMAP10 = 10,
44 CM_LBS_PLAT_AMAP20 = 11,
45 CM_LBS_PLAT_MANTU = 20,
46 CM_LBS_PLAT_BAIDU = 30,
47 CM_LBS_PLAT_ONEOSPOS= 40,
48 CM_LBS_PLAT_END
49 } cm_lbs_location_platform_e;
50
52 typedef enum
53 {
54 CM_LBS_LOCATION_OK = 0,
55 CM_LBS_NET_ERR = -1,
56 CM_LBS_TIMEOUT = -2,
57 CM_LBS_KEY_ERR = -3,
58 CM_LBS_PARAM_INVALID = -4,
59 CM_LBS_OVER_DAYQUTA = -5,
60 CM_LBS_OVER_QUOTA = -6,
61 CM_LBS_OVER_QPS = -7,
62 CM_LBS_UNKNOW_ERR = -100
63 } cm_lbs_callback_event_e;
64
66 typedef struct
67 {
68 int platform;
69 cm_lbs_callback_event_e state;
70 char *longitude;
71 char *latitude;
72 char *radius;
73 char *country;
74 char *province;
75 char *city;
76 char *citycode;
77 char *adcode;
78 char *poi;
79 char *location_describe;
80 }cm_lbs_location_rsp_t;
81
86 typedef struct
87 {
88 uint8_t *api_key;
89 int time_out;
90 int digital_sign_enable;
91 uint8_t *digital_key;
92 int show_fields_enable;
93 int nearbts_enable;
94 }cm_lbs_amap_location_attr_t;
95
97 typedef struct
98 {
99 uint8_t appid[64];
100 uint8_t password[64];
101 uint8_t transid[64];
102 int time_out;
104 }cm_lbs_mantu_location_attr_t;
105
106
107 /*ONEOS 定位配置信息*/
108 typedef struct
109 {
110 char *pid;
111 int time_out;
112 int nearbts_enable;
113 }cm_lbs_oneospos_attr_t;
114
115
117 typedef void (*cm_lbs_callback)(cm_lbs_callback_event_e event,cm_lbs_location_rsp_t *location,void *cb_arg);
118
119
120 /****************************************************************************
121 * Public Data
122 ****************************************************************************/
123
124
125 /****************************************************************************
126 * Public Function Prototypes
127 ****************************************************************************/
128
129 #ifdef __cplusplus
130 #define EXTERN extern "C"
131 extern "C"
132 {
133 #else
134 #define EXTERN extern
135 #endif
136 /*
137 *@brief LBS初始化
138 *@param[in] platform 定位平台
139 *@param[in] attr 定位配置参数
140 *
141 *@return
142 * 0：成功\n
143 * -1：参数错误\n
144 * -2：未知错误
145 */
146 int32_t cm_lbs_init(cm_lbs_location_platform_e platform,void *attr);
147
148 /*
149 *@brief LBS获取位置信息(异步)
150 *@param[in] cb 获取结果的回调函数
151 *@param[in] cb_arg 回调函数参数
152 *
153 *@return
154 * 0：成功 n
155 * -1：参数错误\n
156 * -2：未知错误\n
157 * -3：LBS忙
158 */
159 int32_t cm_lbs_location(cm_lbs_callback cb,void *cb_arg);
160
161 /*
162 *@brief LBS逆初始化
163 *
164 */
165 void cm_lbs_deinit(void);
166
167 /*
168 *@brief 获取平台定位配置信息
169 *
170 *@param[in] platform 定位平台
171 *@param[out] attr 不同平台配置参数结构体
172 *
173 *@return
174 * 0:成功\n
175 * -1：参数错误\n
176 * -2：未知错误\n
177 * -3：数据为空\n
178 */
179 int32_t cm_lbs_get_attr(int platform,void *attr);
180
181 #undef EXTERN
182 #ifdef __cplusplus
183 }
184 #endif
185
186
187 #endif /* __CM_LBS_H__ */
188
cm_lbs_callback
void(* cm_lbs_callback)(cm_lbs_callback_event_e event, cm_lbs_location_rsp_t *location, void *cb_arg)
Definition: cm_lbs.h:117
cm_lbs_deinit
void cm_lbs_deinit(void)
cm_lbs_location
int32_t cm_lbs_location(cm_lbs_callback cb, void *cb_arg)
cm_lbs_init
int32_t cm_lbs_init(cm_lbs_location_platform_e platform, void *attr)
cm_lbs_get_attr
int32_t cm_lbs_get_attr(int platform, void *attr)
cm_lbs_location_platform_e
cm_lbs_location_platform_e
Definition: cm_lbs.h:41
cm_lbs_callback_event_e
cm_lbs_callback_event_e
Definition: cm_lbs.h:53
CM_LBS_PLAT_START
@ CM_LBS_PLAT_START
Definition: cm_lbs.h:42
CM_LBS_PLAT_END
@ CM_LBS_PLAT_END
Definition: cm_lbs.h:48
CM_LBS_PLAT_ONEOSPOS
@ CM_LBS_PLAT_ONEOSPOS
Definition: cm_lbs.h:47
CM_LBS_PLAT_AMAP10
@ CM_LBS_PLAT_AMAP10
Definition: cm_lbs.h:43
CM_LBS_PLAT_AMAP20
@ CM_LBS_PLAT_AMAP20
Definition: cm_lbs.h:44
CM_LBS_PLAT_BAIDU
@ CM_LBS_PLAT_BAIDU
Definition: cm_lbs.h:46
CM_LBS_PLAT_MANTU
@ CM_LBS_PLAT_MANTU
Definition: cm_lbs.h:45
CM_LBS_UNKNOW_ERR
@ CM_LBS_UNKNOW_ERR
Definition: cm_lbs.h:62
CM_LBS_LOCATION_OK
@ CM_LBS_LOCATION_OK
Definition: cm_lbs.h:54
CM_LBS_OVER_DAYQUTA
@ CM_LBS_OVER_DAYQUTA
Definition: cm_lbs.h:59
CM_LBS_KEY_ERR
@ CM_LBS_KEY_ERR
Definition: cm_lbs.h:57
CM_LBS_OVER_QUOTA
@ CM_LBS_OVER_QUOTA
Definition: cm_lbs.h:60
CM_LBS_OVER_QPS
@ CM_LBS_OVER_QPS
Definition: cm_lbs.h:61
CM_LBS_NET_ERR
@ CM_LBS_NET_ERR
Definition: cm_lbs.h:55
CM_LBS_TIMEOUT
@ CM_LBS_TIMEOUT
Definition: cm_lbs.h:56
CM_LBS_PARAM_INVALID
@ CM_LBS_PARAM_INVALID
Definition: cm_lbs.h:58
cm_lbs_amap_location_attr_t
Definition: cm_lbs.h:87
cm_lbs_amap_location_attr_t::show_fields_enable
int show_fields_enable
Definition: cm_lbs.h:92
cm_lbs_amap_location_attr_t::nearbts_enable
int nearbts_enable
Definition: cm_lbs.h:93
cm_lbs_amap_location_attr_t::digital_sign_enable
int digital_sign_enable
Definition: cm_lbs.h:90
cm_lbs_amap_location_attr_t::digital_key
uint8_t * digital_key
Definition: cm_lbs.h:91
cm_lbs_amap_location_attr_t::api_key
uint8_t * api_key
Definition: cm_lbs.h:88
cm_lbs_amap_location_attr_t::time_out
int time_out
Definition: cm_lbs.h:89
cm_lbs_location_rsp_t
Definition: cm_lbs.h:67
cm_lbs_location_rsp_t::radius
char * radius
Definition: cm_lbs.h:72
cm_lbs_location_rsp_t::city
char * city
Definition: cm_lbs.h:75
cm_lbs_location_rsp_t::poi
char * poi
Definition: cm_lbs.h:78
cm_lbs_location_rsp_t::citycode
char * citycode
Definition: cm_lbs.h:76
cm_lbs_location_rsp_t::province
char * province
Definition: cm_lbs.h:74
cm_lbs_location_rsp_t::longitude
char * longitude
Definition: cm_lbs.h:70
cm_lbs_location_rsp_t::adcode
char * adcode
Definition: cm_lbs.h:77
cm_lbs_location_rsp_t::country
char * country
Definition: cm_lbs.h:73
cm_lbs_location_rsp_t::platform
int platform
Definition: cm_lbs.h:68
cm_lbs_location_rsp_t::location_describe
char * location_describe
Definition: cm_lbs.h:79
cm_lbs_location_rsp_t::latitude
char * latitude
Definition: cm_lbs.h:71
cm_lbs_location_rsp_t::state
cm_lbs_callback_event_e state
Definition: cm_lbs.h:69
cm_lbs_mantu_location_attr_t
Definition: cm_lbs.h:98
cm_lbs_mantu_location_attr_t::time_out
int time_out
Definition: cm_lbs.h:102
cm_lbs_oneospos_attr_t
Definition: cm_lbs.h:109
cm_lbs_oneospos_attr_t::nearbts_enable
int nearbts_enable
Definition: cm_lbs.h:112
cm_lbs_oneospos_attr_t::pid
char * pid
Definition: cm_lbs.h:110
cm_lbs_oneospos_attr_t::time_out
int time_out
Definition: cm_lbs.h:111


ML305A_ML307A_OpenCPU_API: cm_lcd.h 源文件

  • cmiot
cm_lcd.h
1
13 #ifndef __CM_LCD_H__
14 #define __CM_LCD_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19 #include "stdint.h"
20
21 /****************************************************************************
22 * Pre-processor Definitions
23 ****************************************************************************/
24 #define LCD_PIN_RST 77 // HAL_GPIO_77
25 #define LCD_PIN_SPI_4L_DCX 14 // HAL_GPIO_14
26 #define LCD_PIN_SPI_CS 13 // HAL_GPIO_13
27 #define LCD_PIN_BACKLIGHT 23 // HAL_GPIO_23
28
29 /****************************************************************************
30 * Public Function Prototypes
31 ****************************************************************************/
32
42 void cm_lcd_write_cmd(unsigned char cmd);
43
53 void cm_lcd_write_data(unsigned char data);
54
65 void cm_lcd_write_buf(unsigned char *data, int len);
66
75 void cm_lcd_init(void);
76
85 void cm_lcd_deinit(void);
86
97 uint32_t cm_lcd_read_id(void);
98
113 int32_t cm_lcd_read_id_v2(const uint32_t cmd, int cmd_len, void *id, int id_len);
114
115 #endif
cm_lcd_write_cmd
void cm_lcd_write_cmd(unsigned char cmd)
配置时发送cmd
cm_lcd_write_buf
void cm_lcd_write_buf(unsigned char *data, int len)
发送刷屏数据
cm_lcd_read_id
uint32_t cm_lcd_read_id(void)
lcd 获取ID
cm_lcd_init
void cm_lcd_init(void)
lcd 驱动初始化
cm_lcd_write_data
void cm_lcd_write_data(unsigned char data)
配置时发送data
cm_lcd_read_id_v2
int32_t cm_lcd_read_id_v2(const uint32_t cmd, int cmd_len, void *id, int id_len)
lcd 获取ID
cm_lcd_deinit
void cm_lcd_deinit(void)
lcd 驱动去初始化


ML305A_ML307A_OpenCPU_API: cm_local_tts.h 源文件

  • cmiot
cm_local_tts.h
1
14 #ifndef __CM_LOCAL_TTS_H__
15 #define __CM_LOCAL_TTS_H__
16
17 /****************************************************************************
18 * Included Files
19 ****************************************************************************/
20
21 #include <stdint.h>
22
23
24 /****************************************************************************
25 * Pre-processor Definitions
26 ****************************************************************************/
27
28 /****************************************************************************
29 * Public Types
30 ****************************************************************************/
36 typedef enum
37 {
38 CM_LOCAL_TTS_ENCODE_TYPE_GB2312 = 1,
39 CM_LOCAL_TTS_ENCODE_TYPE_UTF8,
40 } cm_local_tts_encode_e;
41
45 typedef enum
46 {
47 CM_LOCAL_TTS_DIGIT_AUTO = 0,
48 CM_LOCAL_TTS_DIGIT_AS_NUMBER,
49 CM_LOCAL_TTS_DIGIT_AS_VALUE,
50 } cm_local_tts_digit_e;
51
57 typedef enum
58 {
59 CM_LOCAL_TTS_TONE_NORMAL = 1,
60 } cm_local_tts_tone_e;
61
67 typedef enum
68 {
69 CM_LOCAL_TTS_EFFECT_NORMAL = 1,
70 } cm_local_tts_effect_e;
71
76 typedef enum
77 {
78 CM_LOCAL_TTS_STATE_IDLE = 1,
79 CM_LOCAL_TTS_STATE_WORKING,
80 } cm_local_tts_state_e;
81
83 typedef struct
84 {
85 int32_t speed;
86 int32_t volume;
87 cm_local_tts_encode_e encode;
88 cm_local_tts_digit_e digit;
89 cm_local_tts_tone_e tone;
90 cm_local_tts_effect_e effect;
91 } cm_local_tts_cfg_t;
92
94 typedef enum
95 {
96 CM_LOCAL_TTS_EVENT_SYNTH_DATA = 1,
97 CM_LOCAL_TTS_EVENT_SYNTH_FAIL,
98 CM_LOCAL_TTS_EVENT_SYNTH_INTERRUPT,
99 CM_LOCAL_TTS_EVENT_SYNTH_FINISH,
100 CM_LOCAL_TTS_EVENT_PLAY_FAIL,
101 CM_LOCAL_TTS_EVENT_PLAY_INTERRUPT,
102 CM_LOCAL_TTS_EVENT_PLAY_FINISH,
103 } cm_local_tts_event_e;
104
105 /*
106 * TTS语音合成数据结构体
107 */
108 typedef struct
109 {
110 uint8_t *data;
111 uint32_t len;
112 void *user;
113 } cm_local_tts_synth_data_t;
114
121 typedef void (*cm_local_tts_callback)(cm_local_tts_event_e event, void *param);
122
134 int32_t cm_local_tts_init(cm_local_tts_cfg_t *cfg);
135
141 void cm_local_tts_deinit(void);
142
160 int32_t cm_local_tts_synth(const void *text, int32_t len, cm_local_tts_callback cb, void *cb_param);
161
179 int32_t cm_local_tts_play(const char *text, int32_t len, cm_local_tts_callback cb, void *cb_param);
180
190 int32_t cm_local_tts_play_stop(void);
191
192 #undef EXTERN
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #endif /* __CM_LOCAL_TTS_H__ */
198
cm_local_tts_synth
int32_t cm_local_tts_synth(const void *text, int32_t len, cm_local_tts_callback cb, void *cb_param)
文字转语音PCM数据（不播放，转码后为PCM数据，采样率8k）
cm_local_tts_deinit
void cm_local_tts_deinit(void)
TTS去初始化
cm_local_tts_effect_e
cm_local_tts_effect_e
音效
Definition: cm_local_tts.h:68
cm_local_tts_digit_e
cm_local_tts_digit_e
数字播放方式
Definition: cm_local_tts.h:46
cm_local_tts_init
int32_t cm_local_tts_init(cm_local_tts_cfg_t *cfg)
TTS初始化
cm_local_tts_play
int32_t cm_local_tts_play(const char *text, int32_t len, cm_local_tts_callback cb, void *cb_param)
TTS播放文字
cm_local_tts_callback
void(* cm_local_tts_callback)(cm_local_tts_event_e event, void *param)
TTS转码回调函数
Definition: cm_local_tts.h:121
cm_local_tts_event_e
cm_local_tts_event_e
Definition: cm_local_tts.h:95
cm_local_tts_state_e
cm_local_tts_state_e
TTS状态
Definition: cm_local_tts.h:77
cm_local_tts_tone_e
cm_local_tts_tone_e
音调
Definition: cm_local_tts.h:58
cm_local_tts_encode_e
cm_local_tts_encode_e
中文文本编码方式
Definition: cm_local_tts.h:37
cm_local_tts_play_stop
int32_t cm_local_tts_play_stop(void)
停止TTS播放文字
CM_LOCAL_TTS_EFFECT_NORMAL
@ CM_LOCAL_TTS_EFFECT_NORMAL
Definition: cm_local_tts.h:69
CM_LOCAL_TTS_DIGIT_AS_VALUE
@ CM_LOCAL_TTS_DIGIT_AS_VALUE
Definition: cm_local_tts.h:49
CM_LOCAL_TTS_DIGIT_AUTO
@ CM_LOCAL_TTS_DIGIT_AUTO
Definition: cm_local_tts.h:47
CM_LOCAL_TTS_DIGIT_AS_NUMBER
@ CM_LOCAL_TTS_DIGIT_AS_NUMBER
Definition: cm_local_tts.h:48
CM_LOCAL_TTS_EVENT_PLAY_FINISH
@ CM_LOCAL_TTS_EVENT_PLAY_FINISH
Definition: cm_local_tts.h:102
CM_LOCAL_TTS_EVENT_SYNTH_FINISH
@ CM_LOCAL_TTS_EVENT_SYNTH_FINISH
Definition: cm_local_tts.h:99
CM_LOCAL_TTS_EVENT_SYNTH_FAIL
@ CM_LOCAL_TTS_EVENT_SYNTH_FAIL
Definition: cm_local_tts.h:97
CM_LOCAL_TTS_EVENT_SYNTH_INTERRUPT
@ CM_LOCAL_TTS_EVENT_SYNTH_INTERRUPT
Definition: cm_local_tts.h:98
CM_LOCAL_TTS_EVENT_SYNTH_DATA
@ CM_LOCAL_TTS_EVENT_SYNTH_DATA
Definition: cm_local_tts.h:96
CM_LOCAL_TTS_EVENT_PLAY_FAIL
@ CM_LOCAL_TTS_EVENT_PLAY_FAIL
Definition: cm_local_tts.h:100
CM_LOCAL_TTS_EVENT_PLAY_INTERRUPT
@ CM_LOCAL_TTS_EVENT_PLAY_INTERRUPT
Definition: cm_local_tts.h:101
CM_LOCAL_TTS_STATE_IDLE
@ CM_LOCAL_TTS_STATE_IDLE
Definition: cm_local_tts.h:78
CM_LOCAL_TTS_STATE_WORKING
@ CM_LOCAL_TTS_STATE_WORKING
Definition: cm_local_tts.h:79
CM_LOCAL_TTS_TONE_NORMAL
@ CM_LOCAL_TTS_TONE_NORMAL
Definition: cm_local_tts.h:59
CM_LOCAL_TTS_ENCODE_TYPE_UTF8
@ CM_LOCAL_TTS_ENCODE_TYPE_UTF8
Definition: cm_local_tts.h:39
CM_LOCAL_TTS_ENCODE_TYPE_GB2312
@ CM_LOCAL_TTS_ENCODE_TYPE_GB2312
Definition: cm_local_tts.h:38
cm_local_tts_cfg_t
Definition: cm_local_tts.h:84
cm_local_tts_cfg_t::tone
cm_local_tts_tone_e tone
Definition: cm_local_tts.h:89
cm_local_tts_cfg_t::encode
cm_local_tts_encode_e encode
Definition: cm_local_tts.h:87
cm_local_tts_cfg_t::speed
int32_t speed
Definition: cm_local_tts.h:85
cm_local_tts_cfg_t::effect
cm_local_tts_effect_e effect
Definition: cm_local_tts.h:90
cm_local_tts_cfg_t::volume
int32_t volume
Definition: cm_local_tts.h:86
cm_local_tts_cfg_t::digit
cm_local_tts_digit_e digit
Definition: cm_local_tts.h:88
cm_local_tts_synth_data_t
Definition: cm_local_tts.h:109
cm_local_tts_synth_data_t::user
void * user
Definition: cm_local_tts.h:112
cm_local_tts_synth_data_t::len
uint32_t len
Definition: cm_local_tts.h:111
cm_local_tts_synth_data_t::data
uint8_t * data
Definition: cm_local_tts.h:110


ML305A_ML307A_OpenCPU_API: cm_mem.h 源文件

  • cmiot
cm_mem.h
1
13 #ifndef __CM_MEM_H__
14 #define __CM_MEM_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19 #include "stdint.h"
20 #include "stddef.h"
21
27 /****************************************************************************
28 * Pre-processor Definitions
29 ****************************************************************************/
30
31 /****************************************************************************
32 * Public Types
33 ****************************************************************************/
34
36 typedef struct{
37 uint32_t total_size;
38 uint32_t allocated;
39 uint32_t free;
40 uint32_t max_continuity_free;
41 uint32_t allocated_peak;
42 uint32_t allocated_times;
43 uint32_t free_times;
44 } cm_heap_stats_t;
45
46 /****************************************************************************
47 * Public Data
48 ****************************************************************************/
49
50
51 /****************************************************************************
52 * Public Function Prototypes
53 ****************************************************************************/
54
55 #ifdef __cplusplus
56 #define EXTERN extern "C"
57 extern "C"
58 {
59 #else
60 #define EXTERN extern
61 #endif
62
74 int32_t cm_mem_get_heap_stats(cm_heap_stats_t *stats);
75
85 void *cm_malloc(size_t size);
86
97 void *cm_realloc(void *ptr, size_t size);
98
109 void *cm_calloc(size_t nitems, size_t size);
110
120 void cm_free(void *ptr);
121
122 #undef EXTERN
123 #ifdef __cplusplus
124 }
125 #endif
126
129 #endif /* __CM_MEM_H__ */
130
cm_heap_stats_t::free_times
uint32_t free_times
Definition: cm_mem.h:43
cm_heap_stats_t::max_continuity_free
uint32_t max_continuity_free
Definition: cm_mem.h:40
cm_malloc
void * cm_malloc(size_t size)
申请内存
cm_realloc
void * cm_realloc(void *ptr, size_t size)
申请内存
cm_free
void cm_free(void *ptr)
释放内存
cm_heap_stats_t::allocated_times
uint32_t allocated_times
Definition: cm_mem.h:42
cm_heap_stats_t::allocated
uint32_t allocated
Definition: cm_mem.h:38
cm_mem_get_heap_stats
int32_t cm_mem_get_heap_stats(cm_heap_stats_t *stats)
获取目前系统heap状态
cm_heap_stats_t::free
uint32_t free
Definition: cm_mem.h:39
cm_heap_stats_t::total_size
uint32_t total_size
Definition: cm_mem.h:37
cm_calloc
void * cm_calloc(size_t nitems, size_t size)
申请内存
cm_heap_stats_t::allocated_peak
uint32_t allocated_peak
Definition: cm_mem.h:41
cm_heap_stats_t
Definition: cm_mem.h:36


ML305A_ML307A_OpenCPU_API: cm_modem_info.h 源文件

  • cmiot
cm_modem_info.h
1
12 #ifndef __CM_MODEM_INFO_H__
13 #define __CM_MODEM_INFO_H__
14
15 /****************************************************************************
16 * Included Files
17 ****************************************************************************/
18
19 #include <stdint.h>
20 #include<stdbool.h>
21
22 #ifdef __cplusplus
23 #define EXTERN extern "C"
24 extern "C"
25 {
26 #else
27 #define EXTERN extern
28 #endif
29
31 typedef struct
32 {
33 uint8_t rat;
34 uint16_t rsrp;
35 uint16_t rsrq;
36 uint16_t rssi;
37 uint16_t rxlev;
38 uint16_t tx_power;
39 uint32_t tx_time;
40 uint32_t rx_time;
41 uint32_t last_cellid;
42 uint8_t last_ecl;
43 uint16_t last_snr;
44 uint32_t last_earfcn;
45 uint16_t last_pci;
46 } cm_radio_info_t;
47
48
50 typedef struct
51 {
52 bool primary_cell;
53 uint8_t mcc[8];
54 uint8_t mnc[8];
55 uint32_t earfcn;
56 uint8_t earfcn_offset;
57 uint16_t tac;
58 uint16_t pci;
59 uint16_t rsrp;
60 uint16_t rsrq;
61 uint16_t rssi;
62 uint16_t snr;
63 uint32_t bandwidth;
64 uint32_t cid;
65 } cm_cell_info_t;
78 int32_t cm_modem_info_cell(cm_cell_info_t cell_info[], uint16_t cell_info_num);
79
91 int32_t cm_modem_info_radio(cm_radio_info_t *radio_info);
92
93 #undef EXTERN
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* __CM_MODEM_H__ */
99
cm_modem_info_cell
int32_t cm_modem_info_cell(cm_cell_info_t cell_info[], uint16_t cell_info_num)
获取模组小区信息
cm_modem_info_radio
int32_t cm_modem_info_radio(cm_radio_info_t *radio_info)
获取模组无线信息
cm_cell_info_t
Definition: cm_modem_info.h:51
cm_cell_info_t::rsrq
uint16_t rsrq
Definition: cm_modem_info.h:60
cm_cell_info_t::earfcn_offset
uint8_t earfcn_offset
Definition: cm_modem_info.h:56
cm_cell_info_t::tac
uint16_t tac
Definition: cm_modem_info.h:57
cm_cell_info_t::bandwidth
uint32_t bandwidth
Definition: cm_modem_info.h:63
cm_cell_info_t::pci
uint16_t pci
Definition: cm_modem_info.h:58
cm_cell_info_t::primary_cell
bool primary_cell
Definition: cm_modem_info.h:52
cm_cell_info_t::earfcn
uint32_t earfcn
Definition: cm_modem_info.h:55
cm_cell_info_t::snr
uint16_t snr
Definition: cm_modem_info.h:62
cm_cell_info_t::cid
uint32_t cid
Definition: cm_modem_info.h:64
cm_cell_info_t::rsrp
uint16_t rsrp
Definition: cm_modem_info.h:59
cm_cell_info_t::rssi
uint16_t rssi
Definition: cm_modem_info.h:61
cm_radio_info_t
Definition: cm_modem_info.h:32
cm_radio_info_t::tx_time
uint32_t tx_time
Definition: cm_modem_info.h:39
cm_radio_info_t::rx_time
uint32_t rx_time
Definition: cm_modem_info.h:40
cm_radio_info_t::last_cellid
uint32_t last_cellid
Definition: cm_modem_info.h:41
cm_radio_info_t::last_snr
uint16_t last_snr
Definition: cm_modem_info.h:43
cm_radio_info_t::last_ecl
uint8_t last_ecl
Definition: cm_modem_info.h:42
cm_radio_info_t::last_pci
uint16_t last_pci
Definition: cm_modem_info.h:45
cm_radio_info_t::rsrq
uint16_t rsrq
Definition: cm_modem_info.h:35
cm_radio_info_t::rxlev
uint16_t rxlev
Definition: cm_modem_info.h:37
cm_radio_info_t::last_earfcn
uint32_t last_earfcn
Definition: cm_modem_info.h:44
cm_radio_info_t::tx_power
uint16_t tx_power
Definition: cm_modem_info.h:38
cm_radio_info_t::rat
uint8_t rat
Definition: cm_modem_info.h:33
cm_radio_info_t::rsrp
uint16_t rsrp
Definition: cm_modem_info.h:34
cm_radio_info_t::rssi
uint16_t rssi
Definition: cm_modem_info.h:36


ML305A_ML307A_OpenCPU_API: cm_mqtt.h 源文件

  • cmiot
cm_mqtt.h
1
13 #ifndef __CM_MQTT_H__
14 #define __CM_MQTT_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include "cm_linklist.h"
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 #define CM_MQTT_RETAIN_0 (0x0)
27 #define CM_MQTT_RETAIN_1 (0x1)
28 #define CM_MQTT_QOS_0 (0x0)
29 #define CM_MQTT_QOS_1 (0x1 << 1)
30 #define CM_MQTT_QOS_2 (0x2 << 1)
31 #define CM_MQTT_DUP_0 (0x0)
32 #define CM_MQTT_DUP_1 (0x1 << 3)
33
34 #define CM_MQTT_TOPIC_SUBSCRIBING 0
35 #define CM_MQTT_TOPIC_SUBSCRIBED 1
36 #define CM_MQTT_TOPIC_UNSUBSCRIBING 2
37
38 /****************************************************************************
39 * Public Types
40 ****************************************************************************/
41
42 struct _cm_mqtt_client_t;
43 typedef struct _cm_mqtt_client_t cm_mqtt_client_t;
44
46 typedef enum{
47 CM_MQTT_STATE_DISCONNECTED,
48 CM_MQTT_STATE_CONNECTED,
49 CM_MQTT_STATE_CONNECTING,
50 CM_MQTT_STATE_RECONNECTING,
51 } cm_mqtt_state_e;
52
54 typedef enum{
55 CM_MQTT_CONN_STATE_SUCCESS = 0,
56 CM_MQTT_CONN_STATE_RECONNECTING,
57 CM_MQTT_CONN_STATE_CLIENT_SHUTDOWN,
58 CM_MQTT_CONN_STATE_SERVER_REJECED,
59 CM_MQTT_CONN_STATE_SERVER_SHUTDOWN,
60 CM_MQTT_CONN_STATE_PING_TIMEOUT,
61 CM_MQTT_CONN_STATE_NET_ERR,
62 CM_MQTT_CONN_STATE_UNKNOWN_ERR = 255,
63 } cm_mqtt_conn_state_e;
64
66 typedef enum{
67 CM_MQTT_OPT_START = 0,
68 CM_MQTT_OPT_CID = CM_MQTT_OPT_START,
69 CM_MQTT_OPT_VERSION,
70 CM_MQTT_OPT_DNS_PRIORITY,
71 CM_MQTT_OPT_SSL_ENABLE,
72 CM_MQTT_OPT_SSL_ID,
73 CM_MQTT_OPT_PING_CYCLE,
74 CM_MQTT_OPT_PKT_TIMEOUT,
75 CM_MQTT_OPT_RETRY_TIMES,
76 CM_MQTT_OPT_RECONN_MODE,
77 CM_MQTT_OPT_RECONN_TIMES,
78 CM_MQTT_OPT_RECONN_CYCLE,
79 CM_MQTT_OPT_EVENT,
80 CM_MQTT_OPT_EVENT_CONNACK_CB,
81 CM_MQTT_OPT_EVENT_PUBLISH_CB,
82 CM_MQTT_OPT_EVENT_PUBACK_CB,
83 CM_MQTT_OPT_EVENT_PUBREC_CB,
84 CM_MQTT_OPT_EVENT_PUBREL_CB,
85 CM_MQTT_OPT_EVENT_PUBCOMP_CB,
86 CM_MQTT_OPT_EVENT_SUBACK_CB,
87 CM_MQTT_OPT_EVENT_UNSUBACK_CB,
88 CM_MQTT_OPT_EVENT_PINGRESP_CB,
89 CM_MQTT_OPT_EVENT_TIMEOUT_CB,
90 CM_MQTT_OPT_END,
91 } cm_mqtt_option_e;
92
94 typedef enum{
95 CM_MQTT_RET_OK = 0,
96 CM_MQTT_RET_INVALID_PARAM = -1,
97 CM_MQTT_RET_NOT_CONNECT = -2,
98 CM_MQTT_RET_CONNECTING = -3,
99 CM_MQTT_RET_ALREADY_CONNECTED = -4,
100 CM_MQTT_RET_NET_ERR = -5,
101 CM_MQTT_RET_MEM_ERR = -6,
102 CM_MQTT_RET_STATE_ERR = -7,
103 CM_MQTT_RET_DNS_ERR = -8,
104 CM_MQTT_RET_UNKNOWN_ERR = -99,
105 } cm_mqtt_err_code_e;
106
108 typedef struct{
109 char state;
110 char qos;
111 unsigned short msg_id;
112 int topic_len;
113 char topic[0];
114 } cm_mqtt_topic_t;
115
117 typedef struct{
118 unsigned short hostport;
119 const char* hostname;
120 const char* clientid;
121 const char* username;
122 const char* password;
123 const char* will_topic;
124 const char* will_message;
125 int will_message_len;
126 char will_flag;
127 char will_qos;
128 char will_retain;
129 char clean_session;
130 char conn_flags;
131 unsigned short keepalive;
132 } cm_mqtt_connect_options_t;
133
135 typedef struct{
136 int (*connack_cb)(cm_mqtt_client_t* client, int session, cm_mqtt_conn_state_e conn_res);
137 int (*publish_cb)(cm_mqtt_client_t* client, unsigned short msgid, char* topic, int total_len, int payload_len, char* payload);
138 int (*puback_cb)(cm_mqtt_client_t* client, unsigned short msgid, char dup);
139 int (*pubrec_cb)(cm_mqtt_client_t* client, unsigned short msgid, char dup);
140 int (*pubrel_cb)(cm_mqtt_client_t* client, unsigned short msgid, char dup);
141 int (*pubcomp_cb)(cm_mqtt_client_t* client, unsigned short msgid, char dup);
142 int (*suback_cb)(cm_mqtt_client_t* client, unsigned short msgid, int count, int qos[]);
143 int (*unsuback_cb)(cm_mqtt_client_t* client, unsigned short msgid);
144 int (*pingresp_cb)(cm_mqtt_client_t* client, int ret);
145 int (*timeout_cb)(cm_mqtt_client_t* client, unsigned short msgid);
146 } cm_mqtt_client_cb_t;
147
148 /****************************************************************************
149 * Public Data
150 ****************************************************************************/
151
152
153 /****************************************************************************
154 * Public Function Prototypes
155 ****************************************************************************/
156
157 #ifdef __cplusplus
158 #define EXTERN extern "C"
159 extern "C"
160 {
161 #else
162 #define EXTERN extern
163 #endif
164
165 /****************************************************************************/
166
174 cm_mqtt_client_t* cm_mqtt_client_create(void);
175
184 int cm_mqtt_client_destroy(cm_mqtt_client_t* client);
185
195 int cm_mqtt_client_connect(cm_mqtt_client_t* client, cm_mqtt_connect_options_t* option);
196
209 int cm_mqtt_client_publish(cm_mqtt_client_t* client, const char* topic, const char* payload, int payload_len, char publish_flags);
210
223 int cm_mqtt_client_subscribe(cm_mqtt_client_t* client, const char* topic[], const char qos[], int count);
224
235 int cm_mqtt_client_unsubscribe(cm_mqtt_client_t* client, const char* topic[], int count);
236
245 int cm_mqtt_client_disconnect(cm_mqtt_client_t* client);
246
257 int cm_mqtt_client_set_opt(cm_mqtt_client_t* client, cm_mqtt_option_e option, void* param);
258
267 int cm_mqtt_client_get_msgid(cm_mqtt_client_t* client);
268
277 int cm_mqtt_client_get_state(cm_mqtt_client_t* client);
278
287 linklist_t* cm_mqtt_client_get_sub_topics(cm_mqtt_client_t* client);
288
289 #undef EXTERN
290 #ifdef __cplusplus
291 }
292 #endif
293
294 #endif /* __CM_MQTT_H__ */
295
cm_mqtt_client_unsubscribe
int cm_mqtt_client_unsubscribe(cm_mqtt_client_t *client, const char *topic[], int count)
取消订阅
cm_mqtt_client_disconnect
int cm_mqtt_client_disconnect(cm_mqtt_client_t *client)
断开连接
cm_mqtt_client_publish
int cm_mqtt_client_publish(cm_mqtt_client_t *client, const char *topic, const char *payload, int payload_len, char publish_flags)
发布消息
cm_mqtt_client_set_opt
int cm_mqtt_client_set_opt(cm_mqtt_client_t *client, cm_mqtt_option_e option, void *param)
client参数设置
cm_mqtt_state_e
cm_mqtt_state_e
Definition: cm_mqtt.h:46
cm_mqtt_client_create
cm_mqtt_client_t * cm_mqtt_client_create(void)
创建mqtt client
cm_mqtt_client_get_state
int cm_mqtt_client_get_state(cm_mqtt_client_t *client)
获取client当前的状态
cm_mqtt_conn_state_e
cm_mqtt_conn_state_e
Definition: cm_mqtt.h:54
cm_mqtt_option_e
cm_mqtt_option_e
Definition: cm_mqtt.h:66
cm_mqtt_client_t
struct _cm_mqtt_client_t cm_mqtt_client_t
Definition: cm_mqtt.h:43
cm_mqtt_client_destroy
int cm_mqtt_client_destroy(cm_mqtt_client_t *client)
销毁mqtt client
cm_mqtt_client_get_sub_topics
linklist_t * cm_mqtt_client_get_sub_topics(cm_mqtt_client_t *client)
获取client订阅列表
cm_mqtt_client_connect
int cm_mqtt_client_connect(cm_mqtt_client_t *client, cm_mqtt_connect_options_t *option)
连接
cm_mqtt_client_get_msgid
int cm_mqtt_client_get_msgid(cm_mqtt_client_t *client)
获取client当前的消息ID
cm_mqtt_err_code_e
cm_mqtt_err_code_e
Definition: cm_mqtt.h:94
cm_mqtt_client_subscribe
int cm_mqtt_client_subscribe(cm_mqtt_client_t *client, const char *topic[], const char qos[], int count)
订阅
CM_MQTT_STATE_DISCONNECTED
@ CM_MQTT_STATE_DISCONNECTED
Definition: cm_mqtt.h:47
CM_MQTT_STATE_CONNECTING
@ CM_MQTT_STATE_CONNECTING
Definition: cm_mqtt.h:49
CM_MQTT_STATE_CONNECTED
@ CM_MQTT_STATE_CONNECTED
Definition: cm_mqtt.h:48
CM_MQTT_STATE_RECONNECTING
@ CM_MQTT_STATE_RECONNECTING
Definition: cm_mqtt.h:50
CM_MQTT_CONN_STATE_UNKNOWN_ERR
@ CM_MQTT_CONN_STATE_UNKNOWN_ERR
Definition: cm_mqtt.h:62
CM_MQTT_CONN_STATE_NET_ERR
@ CM_MQTT_CONN_STATE_NET_ERR
Definition: cm_mqtt.h:61
CM_MQTT_CONN_STATE_SERVER_SHUTDOWN
@ CM_MQTT_CONN_STATE_SERVER_SHUTDOWN
Definition: cm_mqtt.h:59
CM_MQTT_CONN_STATE_SERVER_REJECED
@ CM_MQTT_CONN_STATE_SERVER_REJECED
Definition: cm_mqtt.h:58
CM_MQTT_CONN_STATE_RECONNECTING
@ CM_MQTT_CONN_STATE_RECONNECTING
Definition: cm_mqtt.h:56
CM_MQTT_CONN_STATE_SUCCESS
@ CM_MQTT_CONN_STATE_SUCCESS
Definition: cm_mqtt.h:55
CM_MQTT_CONN_STATE_CLIENT_SHUTDOWN
@ CM_MQTT_CONN_STATE_CLIENT_SHUTDOWN
Definition: cm_mqtt.h:57
CM_MQTT_CONN_STATE_PING_TIMEOUT
@ CM_MQTT_CONN_STATE_PING_TIMEOUT
Definition: cm_mqtt.h:60
CM_MQTT_OPT_EVENT_PUBLISH_CB
@ CM_MQTT_OPT_EVENT_PUBLISH_CB
Definition: cm_mqtt.h:81
CM_MQTT_OPT_RECONN_TIMES
@ CM_MQTT_OPT_RECONN_TIMES
Definition: cm_mqtt.h:77
CM_MQTT_OPT_EVENT
@ CM_MQTT_OPT_EVENT
Definition: cm_mqtt.h:79
CM_MQTT_OPT_PING_CYCLE
@ CM_MQTT_OPT_PING_CYCLE
Definition: cm_mqtt.h:73
CM_MQTT_OPT_EVENT_PINGRESP_CB
@ CM_MQTT_OPT_EVENT_PINGRESP_CB
Definition: cm_mqtt.h:88
CM_MQTT_OPT_START
@ CM_MQTT_OPT_START
Definition: cm_mqtt.h:67
CM_MQTT_OPT_SSL_ENABLE
@ CM_MQTT_OPT_SSL_ENABLE
Definition: cm_mqtt.h:71
CM_MQTT_OPT_SSL_ID
@ CM_MQTT_OPT_SSL_ID
Definition: cm_mqtt.h:72
CM_MQTT_OPT_RETRY_TIMES
@ CM_MQTT_OPT_RETRY_TIMES
Definition: cm_mqtt.h:75
CM_MQTT_OPT_EVENT_PUBCOMP_CB
@ CM_MQTT_OPT_EVENT_PUBCOMP_CB
Definition: cm_mqtt.h:85
CM_MQTT_OPT_CID
@ CM_MQTT_OPT_CID
Definition: cm_mqtt.h:68
CM_MQTT_OPT_VERSION
@ CM_MQTT_OPT_VERSION
Definition: cm_mqtt.h:69
CM_MQTT_OPT_RECONN_MODE
@ CM_MQTT_OPT_RECONN_MODE
Definition: cm_mqtt.h:76
CM_MQTT_OPT_DNS_PRIORITY
@ CM_MQTT_OPT_DNS_PRIORITY
Definition: cm_mqtt.h:70
CM_MQTT_OPT_EVENT_TIMEOUT_CB
@ CM_MQTT_OPT_EVENT_TIMEOUT_CB
Definition: cm_mqtt.h:89
CM_MQTT_OPT_PKT_TIMEOUT
@ CM_MQTT_OPT_PKT_TIMEOUT
Definition: cm_mqtt.h:74
CM_MQTT_OPT_END
@ CM_MQTT_OPT_END
Definition: cm_mqtt.h:90
CM_MQTT_OPT_EVENT_CONNACK_CB
@ CM_MQTT_OPT_EVENT_CONNACK_CB
Definition: cm_mqtt.h:80
CM_MQTT_OPT_EVENT_PUBREC_CB
@ CM_MQTT_OPT_EVENT_PUBREC_CB
Definition: cm_mqtt.h:83
CM_MQTT_OPT_RECONN_CYCLE
@ CM_MQTT_OPT_RECONN_CYCLE
Definition: cm_mqtt.h:78
CM_MQTT_OPT_EVENT_UNSUBACK_CB
@ CM_MQTT_OPT_EVENT_UNSUBACK_CB
Definition: cm_mqtt.h:87
CM_MQTT_OPT_EVENT_SUBACK_CB
@ CM_MQTT_OPT_EVENT_SUBACK_CB
Definition: cm_mqtt.h:86
CM_MQTT_OPT_EVENT_PUBREL_CB
@ CM_MQTT_OPT_EVENT_PUBREL_CB
Definition: cm_mqtt.h:84
CM_MQTT_OPT_EVENT_PUBACK_CB
@ CM_MQTT_OPT_EVENT_PUBACK_CB
Definition: cm_mqtt.h:82
CM_MQTT_RET_UNKNOWN_ERR
@ CM_MQTT_RET_UNKNOWN_ERR
Definition: cm_mqtt.h:104
CM_MQTT_RET_OK
@ CM_MQTT_RET_OK
Definition: cm_mqtt.h:95
CM_MQTT_RET_STATE_ERR
@ CM_MQTT_RET_STATE_ERR
Definition: cm_mqtt.h:102
CM_MQTT_RET_ALREADY_CONNECTED
@ CM_MQTT_RET_ALREADY_CONNECTED
Definition: cm_mqtt.h:99
CM_MQTT_RET_INVALID_PARAM
@ CM_MQTT_RET_INVALID_PARAM
Definition: cm_mqtt.h:96
CM_MQTT_RET_NOT_CONNECT
@ CM_MQTT_RET_NOT_CONNECT
Definition: cm_mqtt.h:97
CM_MQTT_RET_NET_ERR
@ CM_MQTT_RET_NET_ERR
Definition: cm_mqtt.h:100
CM_MQTT_RET_CONNECTING
@ CM_MQTT_RET_CONNECTING
Definition: cm_mqtt.h:98
CM_MQTT_RET_DNS_ERR
@ CM_MQTT_RET_DNS_ERR
Definition: cm_mqtt.h:103
CM_MQTT_RET_MEM_ERR
@ CM_MQTT_RET_MEM_ERR
Definition: cm_mqtt.h:101
cm_mqtt_client_cb_t
Definition: cm_mqtt.h:135
cm_mqtt_connect_options_t
Definition: cm_mqtt.h:117
cm_mqtt_connect_options_t::will_qos
char will_qos
Definition: cm_mqtt.h:127
cm_mqtt_connect_options_t::will_retain
char will_retain
Definition: cm_mqtt.h:128
cm_mqtt_connect_options_t::will_topic
const char * will_topic
Definition: cm_mqtt.h:123
cm_mqtt_connect_options_t::will_flag
char will_flag
Definition: cm_mqtt.h:126
cm_mqtt_connect_options_t::will_message
const char * will_message
Definition: cm_mqtt.h:124
cm_mqtt_connect_options_t::will_message_len
int will_message_len
Definition: cm_mqtt.h:125
cm_mqtt_connect_options_t::conn_flags
char conn_flags
Definition: cm_mqtt.h:130
cm_mqtt_connect_options_t::clean_session
char clean_session
Definition: cm_mqtt.h:129
cm_mqtt_connect_options_t::clientid
const char * clientid
Definition: cm_mqtt.h:120
cm_mqtt_connect_options_t::hostport
unsigned short hostport
Definition: cm_mqtt.h:118
cm_mqtt_connect_options_t::password
const char * password
Definition: cm_mqtt.h:122
cm_mqtt_connect_options_t::hostname
const char * hostname
Definition: cm_mqtt.h:119
cm_mqtt_connect_options_t::username
const char * username
Definition: cm_mqtt.h:121
cm_mqtt_connect_options_t::keepalive
unsigned short keepalive
Definition: cm_mqtt.h:131
cm_mqtt_topic_t
Definition: cm_mqtt.h:108
cm_mqtt_topic_t::topic_len
int topic_len
Definition: cm_mqtt.h:112
cm_mqtt_topic_t::msg_id
unsigned short msg_id
Definition: cm_mqtt.h:111
cm_mqtt_topic_t::qos
char qos
Definition: cm_mqtt.h:110
cm_mqtt_topic_t::state
char state
Definition: cm_mqtt.h:109


ML305A_ML307A_OpenCPU_API: cm_ntp.h 源文件

  • cmiot
cm_ntp.h
1
13 #ifndef __CM_NTP_H__
14 #define __CM_NTP_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 #include <stdbool.h>
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27 /****************************************************************************
28 * Public Types
29 ****************************************************************************/
30
31
32 /****************************************************************************
33 * Public Data
34 ****************************************************************************/
35
37 typedef enum
38 {
39 CM_NTP_EVENT_SYNC_FAIL,
40 CM_NTP_EVENT_SYNC_OK,
41 CM_NTP_EVENT_SETTIME_FAIL,
42 } cm_ntp_event_e;
43
45 typedef enum
46 {
47 CM_NTP_CFG_SERVER = 1,
48 CM_NTP_CFG_PORT,
49 CM_NTP_CFG_TIMEOUT,
50 CM_NTP_CFG_DNS,
51 CM_NTP_CFG_SET_RTC,
52 CM_NTP_CFG_CB,
53 CM_NTP_CFG_CB_PARAM,
54 } cm_ntp_cfg_type_e;
55
57 typedef void (*cm_ntp_event_cb_t)(cm_ntp_event_e event, void *event_param, void *cb_param);
58
59 /****************************************************************************
60 * Public Function Prototypes
61 ****************************************************************************/
62
63 #ifdef __cplusplus
64 #define EXTERN extern "C"
65 extern "C"
66 {
67 #else
68 #define EXTERN extern
69 #endif
70
83 int32_t cm_ntp_set_cfg(cm_ntp_cfg_type_e type, void *value);
84
94 int32_t cm_ntp_sync(void);
95
96 #undef EXTERN
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif /* __CM_NTP_H__ */
102
cm_ntp_cfg_type_e
cm_ntp_cfg_type_e
Definition: cm_ntp.h:46
cm_ntp_event_e
cm_ntp_event_e
Definition: cm_ntp.h:38
cm_ntp_set_cfg
int32_t cm_ntp_set_cfg(cm_ntp_cfg_type_e type, void *value)
NTP服务设置参数
cm_ntp_sync
int32_t cm_ntp_sync(void)
执行NTP时间同步
cm_ntp_event_cb_t
void(* cm_ntp_event_cb_t)(cm_ntp_event_e event, void *event_param, void *cb_param)
Definition: cm_ntp.h:57
CM_NTP_CFG_TIMEOUT
@ CM_NTP_CFG_TIMEOUT
Definition: cm_ntp.h:49
CM_NTP_CFG_CB
@ CM_NTP_CFG_CB
Definition: cm_ntp.h:52
CM_NTP_CFG_DNS
@ CM_NTP_CFG_DNS
Definition: cm_ntp.h:50
CM_NTP_CFG_PORT
@ CM_NTP_CFG_PORT
Definition: cm_ntp.h:48
CM_NTP_CFG_SET_RTC
@ CM_NTP_CFG_SET_RTC
Definition: cm_ntp.h:51
CM_NTP_CFG_CB_PARAM
@ CM_NTP_CFG_CB_PARAM
Definition: cm_ntp.h:53
CM_NTP_CFG_SERVER
@ CM_NTP_CFG_SERVER
Definition: cm_ntp.h:47
CM_NTP_EVENT_SYNC_FAIL
@ CM_NTP_EVENT_SYNC_FAIL
Definition: cm_ntp.h:39
CM_NTP_EVENT_SYNC_OK
@ CM_NTP_EVENT_SYNC_OK
Definition: cm_ntp.h:40
CM_NTP_EVENT_SETTIME_FAIL
@ CM_NTP_EVENT_SETTIME_FAIL
Definition: cm_ntp.h:41


ML305A_ML307A_OpenCPU_API: cm_os.h 源文件

  • cmiot
cm_os.h
1
19 #ifndef __CM_OS_H__
20 #define __CM_OS_H__
21
22 /****************************************************************************
23 * Included Files
24 ****************************************************************************/
25
26 #include <stdint.h>
27 #include <stddef.h>
28
29 #ifndef __NO_RETURN
30 #if defined(__CC_ARM)
31 #define __NO_RETURN __declspec(noreturn)
32 #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
33 #define __NO_RETURN __attribute__((__noreturn__))
34 #elif defined(__GNUC__)
35 #define __NO_RETURN __attribute__((__noreturn__))
36 #elif defined(__ICCARM__)
37 #define __NO_RETURN __noreturn
38 #else
39 #define __NO_RETURN
40 #endif
41 #endif
42 /****************************************************************************
43 * Pre-processor Definitions
44 ****************************************************************************/
45
46
47 /****************************************************************************
48 * Public Types
49 ****************************************************************************/
50
52 typedef struct {
53 uint32_t api;
54 uint32_t kernel;
55 } osVersion_t;
56
58 typedef enum {
59 osKernelInactive = 0,
60 osKernelReady = 1,
61 osKernelRunning = 2,
62 osKernelLocked = 3,
63 osKernelSuspended = 4,
64 osKernelError = -1,
65 osKernelReserved = 0x7FFFFFFF
66 } osKernelState_t;
67
69 typedef enum {
70 osThreadInactive = 0,
71 osThreadReady = 1,
72 osThreadRunning = 2,
73 osThreadBlocked = 3,
74 osThreadTerminated = 4,
75 osThreadError = -1,
76 osThreadReserved = 0x7FFFFFFF
77 } osThreadState_t;
78
80 typedef enum {
81 osPriorityIdle = 0,
82 osPriorityLow = 2,
83 osPriorityBelowNormal = 3,
84 osPriorityNormal = 4,
85 osPriorityAboveNormal = 5,
86 osPriorityHigh = 6,
87 osPrioritySoftRealtime = 7,
88 osPriorityHardRealtime = 8,
89 osPriorityISR = 32,
90 osPriorityError = -1,
91 osPriorityReserved = 0x7FFFFFFF
92 } osPriority_t;
94 typedef void (*osThreadFunc_t) (void *argument);
95
97 typedef void (*osTimerFunc_t) (void *argument);
98
100 typedef enum {
101 osTimerOnce = 0,
102 osTimerPeriodic = 1
103 } osTimerType_t;
104
106 #define osWaitForever 0xFFFFFFFFU
109 #define osFlagsWaitAny 0x00000000U
110 #define osFlagsWaitAll 0x00000001U
111 #define osFlagsNoClear 0x00000002U
114 #define osFlagsError 0x80000000U
115 #define osFlagsErrorUnknown 0xFFFFFFFFU
116 #define osFlagsErrorTimeout 0xFFFFFFFEU
117 #define osFlagsErrorResource 0xFFFFFFFDU
118 #define osFlagsErrorParameter 0xFFFFFFFCU
119 #define osFlagsErrorISR 0xFFFFFFFAU
122 #define osThreadDetached 0x00000000U
123 #define osThreadJoinable 0x00000001U
126 #define osMutexRecursive 0x00000001U
127 #define osMutexPrioInherit 0x00000002U
128 #define osMutexRobust 0x00000008U
131 typedef enum {
132 osOK = 0,
133 osError = -1,
134 osErrorTimeout = -2,
135 osErrorResource = -3,
136 osErrorParameter = -4,
137 osErrorNoMemory = -5,
138 osErrorISR = -6,
139 osStatusReserved = 0x7FFFFFFF
140 } osStatus_t;
141
142
144 typedef void *osThreadId_t;
145
147 typedef void *osTimerId_t;
148
150 typedef void *osEventFlagsId_t;
151
153 typedef void *osMutexId_t;
154
156 typedef void *osSemaphoreId_t;
157
159 typedef void *osMemoryPoolId_t;
160
162 typedef void *osMessageQueueId_t;
163
165 typedef uint32_t TZ_ModuleId_t;
166
168 typedef struct {
169 const char *name;
170 uint32_t attr_bits;
171 void *cb_mem;
172 uint32_t cb_size;
173 void *stack_mem;
174 uint32_t stack_size;
175 osPriority_t priority;
176 TZ_ModuleId_t tz_module;
177 uint32_t reserved;
178 } osThreadAttr_t;
179
181 typedef struct {
182 const char *name;
183 uint32_t attr_bits;
184 void *cb_mem;
185 uint32_t cb_size;
186 } osTimerAttr_t;
187
189 typedef struct {
190 const char *name;
191 uint32_t attr_bits;
192 void *cb_mem;
193 uint32_t cb_size;
194 } osEventFlagsAttr_t;
195
197 typedef struct {
198 const char *name;
199 uint32_t attr_bits;
200 void *cb_mem;
201 uint32_t cb_size;
202 } osMutexAttr_t;
203
205 typedef struct {
206 const char *name;
207 uint32_t attr_bits;
208 void *cb_mem;
209 uint32_t cb_size;
210 } osSemaphoreAttr_t;
211
213 typedef struct {
214 const char *name;
215 uint32_t attr_bits;
216 void *cb_mem;
217 uint32_t cb_size;
218 void *mp_mem;
219 uint32_t mp_size;
220 } osMemoryPoolAttr_t;
221
223 typedef struct {
224 const char *name;
225 uint32_t attr_bits;
226 void *cb_mem;
227 uint32_t cb_size;
228 void *mq_mem;
229 uint32_t mq_size;
230 } osMessageQueueAttr_t;
231
232 /****************************************************************************
233 * Public Data
234 ****************************************************************************/
235
236
237 /****************************************************************************
238 * Public Function Prototypes
239 ****************************************************************************/
240
241 #ifdef __cplusplus
242 #define EXTERN extern "C"
243 extern "C"
244 {
245 #else
246 #define EXTERN extern
247 #endif
248
255 int32_t osKernelLock (void);
256
262 int32_t osKernelUnlock (void);
263
269 uint32_t osKernelGetTickFreq (void);
270
276 uint32_t osKernelGetTickCount (void);
277
287 osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
288
296 const char *osThreadGetName (osThreadId_t thread_id);
297
303 osThreadId_t osThreadGetId (void);
304
312 osThreadState_t osThreadGetState (osThreadId_t thread_id);
313
321 uint32_t osThreadGetStackSize (osThreadId_t thread_id);
322
330 uint32_t osThreadGetStackSpace (osThreadId_t thread_id);
331
340 osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority);
341
349 osPriority_t osThreadGetPriority (osThreadId_t thread_id);
350
356 osStatus_t osThreadYield (void);
357
365 osStatus_t osThreadSuspend (osThreadId_t thread_id);
366
374 osStatus_t osThreadResume (osThreadId_t thread_id);
375
376
377
379 //__NO_RETURN void osThreadExit (void);
380
388 osStatus_t osThreadTerminate (osThreadId_t thread_id);
389
395 uint32_t osThreadGetCount (void);
396
397
398
406 osStatus_t osDelay (uint32_t ticks);
407
408
409
420 osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
421
429 //const char *osTimerGetName (osTimerId_t timer_id);
430
439 osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks);
440
448 osStatus_t osTimerStop (osTimerId_t timer_id);
449
459 uint32_t osTimerIsRunning (osTimerId_t timer_id);
460
468 osStatus_t osTimerDelete (osTimerId_t timer_id);
469
477 osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr);
478
479
488 uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);
489
498 //uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);
499
507 //uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);
508
519 uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
520
528 osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id);
529
537 osMutexId_t osMutexNew (const osMutexAttr_t *attr);
538
539
548 osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout);
549
557 osStatus_t osMutexRelease (osMutexId_t mutex_id);
558
566 //osThreadId_t osMutexGetOwner (osMutexId_t mutex_id);
567
575 osStatus_t osMutexDelete (osMutexId_t mutex_id);
576
586 osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);
587
596 osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);
597
605 osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id);
606
614 //uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id);
615
623 osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id);
624
625
626
627
637 osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
638
639
650 osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
651
662 osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
663
671 //uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id);
672
680 //uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id);
681
689 //uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id);
690
698 //uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id);
699
707 //osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id);
708
716 osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id);
717
718
719 #undef EXTERN
720 #ifdef __cplusplus
721 }
722 #endif
723
724 #endif /* __CM_OS_H__ */
725
osKernelState_t
osKernelState_t
Definition: cm_os.h:58
osSemaphoreRelease
osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id)
Release a Semaphore token up to the initial maximum count.
osThreadGetPriority
osPriority_t osThreadGetPriority(osThreadId_t thread_id)
Get current priority of a thread.
osMessageQueueId_t
void * osMessageQueueId_t
Definition: cm_os.h:162
osMessageQueueNew
osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr)
Create and Initialize a Message Queue object.
osMutexId_t
void * osMutexId_t
Definition: cm_os.h:153
osSemaphoreNew
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
Create and Initialize a Semaphore object.
osThreadTerminate
osStatus_t osThreadTerminate(osThreadId_t thread_id)
Terminate execution of a thread.
osThreadGetName
const char * osThreadGetName(osThreadId_t thread_id)
Get name of a thread.
osEventFlagsSet
uint32_t osEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags)
Set the specified Event Flags.
osThreadResume
osStatus_t osThreadResume(osThreadId_t thread_id)
Resume execution of a thread.
osThreadNew
osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr)
Create a thread and add it to Active Threads.
osThreadGetCount
uint32_t osThreadGetCount(void)
Get number of active threads.
osEventFlagsWait
uint32_t osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)
Clear the specified Event Flags.
osSemaphoreId_t
void * osSemaphoreId_t
Definition: cm_os.h:156
osThreadId_t
void * osThreadId_t
Definition: cm_os.h:144
osTimerIsRunning
uint32_t osTimerIsRunning(osTimerId_t timer_id)
Check if a timer is running.
osStatus_t
osStatus_t
Definition: cm_os.h:131
osTimerFunc_t
void(* osTimerFunc_t)(void *argument)
Definition: cm_os.h:97
osKernelGetTickFreq
uint32_t osKernelGetTickFreq(void)
Get the RTOS kernel tick frequency.
osEventFlagsDelete
osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id)
Delete an Event Flags object.
osTimerType_t
osTimerType_t
Definition: cm_os.h:100
osSemaphoreAcquire
osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout)
Acquire a Semaphore token or timeout if no tokens are available.
osSemaphoreDelete
osStatus_t osSemaphoreDelete(osSemaphoreId_t semaphore_id)
Get current Semaphore token count.
osKernelGetTickCount
uint32_t osKernelGetTickCount(void)
Get the RTOS kernel tick count.
osThreadSetPriority
osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
Change priority of a thread.
osThreadGetId
osThreadId_t osThreadGetId(void)
Return the thread ID of the current running thread.
osThreadFunc_t
void(* osThreadFunc_t)(void *argument)
Definition: cm_os.h:94
osKernelLock
int32_t osKernelLock(void)
Lock the RTOS Kernel scheduler.
osThreadGetStackSpace
uint32_t osThreadGetStackSpace(osThreadId_t thread_id)
Get available stack space of a thread based on stack watermark recording during execution.
osMessageQueuePut
osStatus_t osMessageQueuePut(osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout)
Put a Message into a Queue or timeout if Queue is full.
osThreadSuspend
osStatus_t osThreadSuspend(osThreadId_t thread_id)
Suspend execution of a thread.
osEventFlagsNew
osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t *attr)
Create and Initialize an Event Flags object.
osTimerStart
osStatus_t osTimerStart(osTimerId_t timer_id, uint32_t ticks)
Get name of a timer.
osMutexNew
osMutexId_t osMutexNew(const osMutexAttr_t *attr)
Create and Initialize a Mutex object.
osThreadGetStackSize
uint32_t osThreadGetStackSize(osThreadId_t thread_id)
Get stack size of a thread.
osMessageQueueDelete
osStatus_t osMessageQueueDelete(osMessageQueueId_t mq_id)
Get maximum number of messages in a Message Queue.
osMutexAcquire
osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
Acquire a Mutex or timeout if it is locked.
osTimerStop
osStatus_t osTimerStop(osTimerId_t timer_id)
Stop a timer.
osMemoryPoolId_t
void * osMemoryPoolId_t
Definition: cm_os.h:159
osMutexDelete
osStatus_t osMutexDelete(osMutexId_t mutex_id)
Get Thread which owns a Mutex object.
osTimerId_t
void * osTimerId_t
Definition: cm_os.h:147
osThreadGetState
osThreadState_t osThreadGetState(osThreadId_t thread_id)
Get current thread state of a thread.
osTimerDelete
osStatus_t osTimerDelete(osTimerId_t timer_id)
Delete a timer.
osThreadYield
osStatus_t osThreadYield(void)
Pass control to next thread that is in state READY.
osThreadState_t
osThreadState_t
Definition: cm_os.h:69
osPriority_t
osPriority_t
Definition: cm_os.h:80
osTimerNew
osTimerId_t osTimerNew(osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
Create and Initialize a timer.
TZ_ModuleId_t
uint32_t TZ_ModuleId_t
Definition: cm_os.h:165
osMessageQueueGet
osStatus_t osMessageQueueGet(osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout)
Get a Message from a Queue or timeout if Queue is empty.
osMutexRelease
osStatus_t osMutexRelease(osMutexId_t mutex_id)
Release a Mutex that was acquired by osMutexAcquire.
osEventFlagsId_t
void * osEventFlagsId_t
Definition: cm_os.h:150
osKernelUnlock
int32_t osKernelUnlock(void)
Unlock the RTOS Kernel scheduler.
osDelay
osStatus_t osDelay(uint32_t ticks)
Wait for Timeout (Time Delay).
osKernelLocked
@ osKernelLocked
Definition: cm_os.h:62
osKernelError
@ osKernelError
Definition: cm_os.h:64
osKernelSuspended
@ osKernelSuspended
Definition: cm_os.h:63
osKernelReady
@ osKernelReady
Definition: cm_os.h:60
osKernelRunning
@ osKernelRunning
Definition: cm_os.h:61
osKernelReserved
@ osKernelReserved
Definition: cm_os.h:65
osKernelInactive
@ osKernelInactive
Definition: cm_os.h:59
osErrorISR
@ osErrorISR
Definition: cm_os.h:138
osStatusReserved
@ osStatusReserved
Definition: cm_os.h:139
osErrorResource
@ osErrorResource
Definition: cm_os.h:135
osErrorTimeout
@ osErrorTimeout
Definition: cm_os.h:134
osOK
@ osOK
Definition: cm_os.h:132
osError
@ osError
Definition: cm_os.h:133
osErrorParameter
@ osErrorParameter
Definition: cm_os.h:136
osErrorNoMemory
@ osErrorNoMemory
Definition: cm_os.h:137
osTimerPeriodic
@ osTimerPeriodic
Definition: cm_os.h:102
osTimerOnce
@ osTimerOnce
Definition: cm_os.h:101
osThreadBlocked
@ osThreadBlocked
Definition: cm_os.h:73
osThreadRunning
@ osThreadRunning
Definition: cm_os.h:72
osThreadInactive
@ osThreadInactive
Definition: cm_os.h:70
osThreadReserved
@ osThreadReserved
Definition: cm_os.h:76
osThreadTerminated
@ osThreadTerminated
Definition: cm_os.h:74
osThreadError
@ osThreadError
Definition: cm_os.h:75
osThreadReady
@ osThreadReady
Definition: cm_os.h:71
osPriorityAboveNormal
@ osPriorityAboveNormal
Priority: above normal
Definition: cm_os.h:85
osPriorityBelowNormal
@ osPriorityBelowNormal
Priority: below normal
Definition: cm_os.h:83
osPriorityISR
@ osPriorityISR
Reserved for ISR deferred thread,Do not use!
Definition: cm_os.h:89
osPriorityNormal
@ osPriorityNormal
Priority: normal
Definition: cm_os.h:84
osPriorityIdle
@ osPriorityIdle
Reserved for Idle thread.
Definition: cm_os.h:81
osPriorityHardRealtime
@ osPriorityHardRealtime
Priority: realtime
Definition: cm_os.h:88
osPriorityLow
@ osPriorityLow
Priority: low
Definition: cm_os.h:82
osPriorityHigh
@ osPriorityHigh
Priority: high
Definition: cm_os.h:86
osPriorityReserved
@ osPriorityReserved
Prevents enum down-size compiler optimization.
Definition: cm_os.h:91
osPriorityError
@ osPriorityError
System cannot determine priority or illegal priority.
Definition: cm_os.h:90
osPrioritySoftRealtime
@ osPrioritySoftRealtime
Priority: realtime
Definition: cm_os.h:87
osEventFlagsAttr_t
Definition: cm_os.h:189
osEventFlagsAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:193
osEventFlagsAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:191
osEventFlagsAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:192
osEventFlagsAttr_t::name
const char * name
Definition: cm_os.h:190
osMemoryPoolAttr_t
Definition: cm_os.h:213
osMemoryPoolAttr_t::mp_size
uint32_t mp_size
Definition: cm_os.h:219
osMemoryPoolAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:217
osMemoryPoolAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:215
osMemoryPoolAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:216
osMemoryPoolAttr_t::name
const char * name
Definition: cm_os.h:214
osMemoryPoolAttr_t::mp_mem
void * mp_mem
Definition: cm_os.h:218
osMessageQueueAttr_t
Definition: cm_os.h:223
osMessageQueueAttr_t::mq_size
uint32_t mq_size
Definition: cm_os.h:229
osMessageQueueAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:227
osMessageQueueAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:225
osMessageQueueAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:226
osMessageQueueAttr_t::name
const char * name
Definition: cm_os.h:224
osMessageQueueAttr_t::mq_mem
void * mq_mem
Definition: cm_os.h:228
osMutexAttr_t
Definition: cm_os.h:197
osMutexAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:201
osMutexAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:199
osMutexAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:200
osMutexAttr_t::name
const char * name
Definition: cm_os.h:198
osSemaphoreAttr_t
Definition: cm_os.h:205
osSemaphoreAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:209
osSemaphoreAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:207
osSemaphoreAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:208
osSemaphoreAttr_t::name
const char * name
Definition: cm_os.h:206
osThreadAttr_t
Definition: cm_os.h:168
osThreadAttr_t::priority
osPriority_t priority
Definition: cm_os.h:175
osThreadAttr_t::stack_mem
void * stack_mem
Definition: cm_os.h:173
osThreadAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:172
osThreadAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:170
osThreadAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:171
osThreadAttr_t::name
const char * name
Definition: cm_os.h:169
osThreadAttr_t::reserved
uint32_t reserved
Definition: cm_os.h:177
osThreadAttr_t::stack_size
uint32_t stack_size
Definition: cm_os.h:174
osThreadAttr_t::tz_module
TZ_ModuleId_t tz_module
Definition: cm_os.h:176
osTimerAttr_t
Definition: cm_os.h:181
osTimerAttr_t::cb_size
uint32_t cb_size
Definition: cm_os.h:185
osTimerAttr_t::attr_bits
uint32_t attr_bits
Definition: cm_os.h:183
osTimerAttr_t::cb_mem
void * cb_mem
Definition: cm_os.h:184
osTimerAttr_t::name
const char * name
Definition: cm_os.h:182
osVersion_t
Definition: cm_os.h:52
osVersion_t::api
uint32_t api
Definition: cm_os.h:53
osVersion_t::kernel
uint32_t kernel
Definition: cm_os.h:54


ML305A_ML307A_OpenCPU_API: cm_pm.h 源文件

  • cmiot
cm_pm.h
1
13 #ifndef __CM_PM_H__
14 #define __CM_PM_H__
15
16
17 /****************************************************************************
18 * Included Files
19 ****************************************************************************/
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 /****************************************************************************
27 * Public Types
28 ****************************************************************************/
29 typedef enum
30 {
31 CM_POWERKEY_EVENT_RELEASE = 0,
32 CM_POWERKEY_EVENT_PRESS = 1,
33 } cm_powerkey_event_e;
34
35 typedef void (*cm_pm_event_cb_t)(void);
36 typedef void (*cm_pm_powerkey_cb_t)(cm_powerkey_event_e event);
37
39 typedef enum
40 {
41 CM_PM_UNKNOWN = 0,
42 CM_PM_CHARG_POW_OFF,
43 CM_PM_RD_PRO_MODE ,
44 CM_PM_RTC_ALARM,
45 CM_PM_POWER_ON,
46 CM_PM_ERROR_RESET,
47 }cm_pm_power_on_reason_e;
48
50 typedef struct{
51 cm_pm_event_cb_t cb_enter;
52 cm_pm_event_cb_t cb_exit;
53 } cm_pm_cfg_t;
54 /****************************************************************************
55 * Public Data
56 ****************************************************************************/
57
58
59 /****************************************************************************
60 * Public Function Prototypes
61 ****************************************************************************/
62
63 #ifdef __cplusplus
64 #define EXTERN extern "C"
65 extern "C"
66 {
67 #else
68 #define EXTERN extern
69 #endif
70
71
79 void cm_pm_poweroff(void);
89 int cm_pm_get_power_on_reason(void);
90
91
101 void cm_pm_reboot(void);
102
112 void cm_pm_init(cm_pm_cfg_t pm_cfg);
113
114
122 void cm_pm_work_lock(void);
123
132 void cm_pm_work_unlock(void);
133
144 int32_t cm_pm_powerkey_regist_callback(cm_pm_powerkey_cb_t callback);
145
146
147 #undef EXTERN
148 #ifdef __cplusplus
149 }
150 #endif
151
152
153 #endif /* __CM_PM_H__ */
154
cm_pm_work_unlock
void cm_pm_work_unlock(void)
睡眠模式解锁
cm_pm_powerkey_cb_t
void(* cm_pm_powerkey_cb_t)(cm_powerkey_event_e event)
Definition: cm_pm.h:36
cm_pm_reboot
void cm_pm_reboot(void)
重启
cm_pm_event_cb_t
void(* cm_pm_event_cb_t)(void)
Definition: cm_pm.h:35
cm_pm_work_lock
void cm_pm_work_lock(void)
睡眠模式上锁
cm_pm_init
void cm_pm_init(cm_pm_cfg_t pm_cfg)
pm初始化
cm_powerkey_event_e
cm_powerkey_event_e
Definition: cm_pm.h:30
cm_pm_power_on_reason_e
cm_pm_power_on_reason_e
Definition: cm_pm.h:40
cm_pm_poweroff
void cm_pm_poweroff(void)
关机
cm_pm_powerkey_regist_callback
int32_t cm_pm_powerkey_regist_callback(cm_pm_powerkey_cb_t callback)
powerkey按键回调函数注册
cm_pm_get_power_on_reason
int cm_pm_get_power_on_reason(void)
获取上电原因
CM_POWERKEY_EVENT_PRESS
@ CM_POWERKEY_EVENT_PRESS
Definition: cm_pm.h:32
CM_POWERKEY_EVENT_RELEASE
@ CM_POWERKEY_EVENT_RELEASE
Definition: cm_pm.h:31
CM_PM_RD_PRO_MODE
@ CM_PM_RD_PRO_MODE
Definition: cm_pm.h:43
CM_PM_CHARG_POW_OFF
@ CM_PM_CHARG_POW_OFF
Definition: cm_pm.h:42
CM_PM_POWER_ON
@ CM_PM_POWER_ON
Definition: cm_pm.h:45
CM_PM_ERROR_RESET
@ CM_PM_ERROR_RESET
Definition: cm_pm.h:46
CM_PM_UNKNOWN
@ CM_PM_UNKNOWN
Definition: cm_pm.h:41
CM_PM_RTC_ALARM
@ CM_PM_RTC_ALARM
Definition: cm_pm.h:44
cm_pm_cfg_t
Definition: cm_pm.h:50
cm_pm_cfg_t::cb_exit
cm_pm_event_cb_t cb_exit
Definition: cm_pm.h:52
cm_pm_cfg_t::cb_enter
cm_pm_event_cb_t cb_enter
Definition: cm_pm.h:51


ML305A_ML307A_OpenCPU_API: cm_pwm.h 源文件

  • cmiot
cm_pwm.h
1
13 #ifndef __CM_PWM_H__
14 #define __CM_PWM_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 /****************************************************************************
27 * Public Types
28 ****************************************************************************/
29
31 typedef enum{
32 CM_PWM_DEV_0,
33 CM_PWM_DEV_1,
34 CM_PWM_DEV_2,
35 CM_PWM_DEV_3,
36 CM_PWM_DEV_NUM
37 } cm_pwm_dev_e;
38
40 typedef enum{
41 CM_PWM_CLK_32K = 32000,
42 CM_PWM_CLK_12800K = 12800000,
43 CM_PWM_CLK_END
44 } cm_pwm_clk_e;
45
46
47 /****************************************************************************
48 * Public Data
49 ****************************************************************************/
50
51
52 /****************************************************************************
53 * Public Function Prototypes
54 ****************************************************************************/
55
56 #ifdef __cplusplus
57 #define EXTERN extern "C"
58 extern "C"
59 {
60 #else
61 #define EXTERN extern
62 #endif
63
76 int32_t cm_pwm_set_clk(cm_pwm_dev_e dev, cm_pwm_clk_e clk);
77
103 int32_t cm_pwm_open_ns(cm_pwm_dev_e dev, uint32_t period, uint32_t period_h);
104
116 int32_t cm_pwm_close(cm_pwm_dev_e dev);
117
118 #undef EXTERN
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif /* __CM_PWM_H__ */
124
cm_pwm_set_clk
int32_t cm_pwm_set_clk(cm_pwm_dev_e dev, cm_pwm_clk_e clk)
PWM 时钟源选择
cm_pwm_close
int32_t cm_pwm_close(cm_pwm_dev_e dev)
关闭PWM设备
cm_pwm_dev_e
cm_pwm_dev_e
Definition: cm_pwm.h:31
cm_pwm_clk_e
cm_pwm_clk_e
Definition: cm_pwm.h:40
cm_pwm_open_ns
int32_t cm_pwm_open_ns(cm_pwm_dev_e dev, uint32_t period, uint32_t period_h)
打开PWM设备
CM_PWM_DEV_0
@ CM_PWM_DEV_0
Definition: cm_pwm.h:32
CM_PWM_DEV_2
@ CM_PWM_DEV_2
Definition: cm_pwm.h:34
CM_PWM_DEV_3
@ CM_PWM_DEV_3
Definition: cm_pwm.h:35
CM_PWM_DEV_NUM
@ CM_PWM_DEV_NUM
Definition: cm_pwm.h:36
CM_PWM_DEV_1
@ CM_PWM_DEV_1
Definition: cm_pwm.h:33
CM_PWM_CLK_END
@ CM_PWM_CLK_END
Definition: cm_pwm.h:43
CM_PWM_CLK_12800K
@ CM_PWM_CLK_12800K
Definition: cm_pwm.h:42
CM_PWM_CLK_32K
@ CM_PWM_CLK_32K
Definition: cm_pwm.h:41


ML305A_ML307A_OpenCPU_API: cm_qr.h 源文件

  • cmiot
cm_qr.h
1
13 #ifndef __CM_QR_H__
14 #define __CM_QR_H__
15
16 #define CM_QR_DATA_LEN_MAX 512
21 typedef int (*cm_qr_cb)(void *param, const char *data);
22
23 /* 解析参数 */
24 typedef struct
25 {
26 void *data;
27 int width;
28 int height;
29 int format;
30 void *usrdata;
31 cm_qr_cb callback;
32 } cm_qr_param_t;
33
34 /* 图像编码格式 */
35 typedef enum
36 {
37 CM_QR_FMT_UYVY,
38 CM_QR_FMT_Y800,
39 CM_QR_FMT_OTHER,
40 } cm_qr_fmt_e;
41
42 /* 二维码解析结果码 */
43 typedef enum
44 {
45 CM_QR_RET_SUCCESS,
46 CM_QR_RET_NOT_INIT,
47 CM_QR_RET_CREATE_FAILED,
48 CM_QR_RET_MEMORY_ERR,
49 CM_QR_RET_FMT_ERR,
50 CM_QR_RET_CONVERT_ERR,
51 CM_QR_RET_SCAN_ERR,
52 CM_QR_RET_NO_DECODE_DATA,
53 } cm_qr_retult_e;
54
64 int cm_qr_convert_init(int width, int height);
65
73 void cm_qr_convert_destroy(void);
74
89 int32_t cm_qr_scan(cm_qr_param_t *param, char *data, int *datalen);
90 #endif
cm_qr_convert_destroy
void cm_qr_convert_destroy(void)
解码缓存回收.
cm_qr_scan
int32_t cm_qr_scan(cm_qr_param_t *param, char *data, int *datalen)
二维码解码.
cm_qr_param_t::width
int width
Definition: cm_qr.h:27
cm_qr_param_t::format
int format
Definition: cm_qr.h:29
cm_qr_cb
int(* cm_qr_cb)(void *param, const char *data)
Definition: cm_qr.h:21
cm_qr_param_t::callback
cm_qr_cb callback
Definition: cm_qr.h:31
cm_qr_param_t::usrdata
void * usrdata
Definition: cm_qr.h:30
cm_qr_param_t::data
void * data
Definition: cm_qr.h:26
cm_qr_fmt_e
cm_qr_fmt_e
Definition: cm_qr.h:36
cm_qr_convert_init
int cm_qr_convert_init(int width, int height)
解码缓存初始化.
cm_qr_param_t::height
int height
Definition: cm_qr.h:28
cm_qr_retult_e
cm_qr_retult_e
Definition: cm_qr.h:44
CM_QR_FMT_OTHER
@ CM_QR_FMT_OTHER
Definition: cm_qr.h:39
CM_QR_FMT_UYVY
@ CM_QR_FMT_UYVY
Definition: cm_qr.h:37
CM_QR_FMT_Y800
@ CM_QR_FMT_Y800
Definition: cm_qr.h:38
CM_QR_RET_NOT_INIT
@ CM_QR_RET_NOT_INIT
Definition: cm_qr.h:46
CM_QR_RET_CONVERT_ERR
@ CM_QR_RET_CONVERT_ERR
Definition: cm_qr.h:50
CM_QR_RET_FMT_ERR
@ CM_QR_RET_FMT_ERR
Definition: cm_qr.h:49
CM_QR_RET_SUCCESS
@ CM_QR_RET_SUCCESS
Definition: cm_qr.h:45
CM_QR_RET_SCAN_ERR
@ CM_QR_RET_SCAN_ERR
Definition: cm_qr.h:51
CM_QR_RET_NO_DECODE_DATA
@ CM_QR_RET_NO_DECODE_DATA
Definition: cm_qr.h:52
CM_QR_RET_MEMORY_ERR
@ CM_QR_RET_MEMORY_ERR
Definition: cm_qr.h:48
CM_QR_RET_CREATE_FAILED
@ CM_QR_RET_CREATE_FAILED
Definition: cm_qr.h:47
cm_qr_param_t
Definition: cm_qr.h:25


ML305A_ML307A_OpenCPU_API: cm_rtc.h 源文件

  • cmiot
cm_rtc.h
1
13 #ifndef __CM_RTC_H__
14 #define __CM_RTC_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21 #include <time.h>
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26
27
28 /****************************************************************************
29 * Public Types
30 ****************************************************************************/
31
32
33 /****************************************************************************
34 * Public Data
35 ****************************************************************************/
36
37
38 /****************************************************************************
39 * Public Function Prototypes
40 ****************************************************************************/
41
42 #ifdef __cplusplus
43 #define EXTERN extern "C"
44 extern "C"
45 {
46 #else
47 #define EXTERN extern
48 #endif
49
61 int32_t cm_rtc_set_current_time(uint64_t second);
62
70 uint64_t cm_rtc_get_current_time(void);
71
83 int32_t cm_rtc_set_timezone(int32_t timezone);
84
92 int32_t cm_rtc_get_timezone(void);
93
94 #undef EXTERN
95 #ifdef __cplusplus
96 }
97 #endif
98
99 #endif /* __CM_RTC_H__ */
100
cm_rtc_get_current_time
uint64_t cm_rtc_get_current_time(void)
获取系统时间（秒）
cm_rtc_set_current_time
int32_t cm_rtc_set_current_time(uint64_t second)
设置系统时间（秒）
cm_rtc_get_timezone
int32_t cm_rtc_get_timezone(void)
获取时区
cm_rtc_set_timezone
int32_t cm_rtc_set_timezone(int32_t timezone)
设置时区


ML305A_ML307A_OpenCPU_API: cm_sd.h 源文件

  • cmiot
cm_sd.h
1
14 #ifndef __CM_SDCARD_H__
15 #define __CM_SDCARD_H__
16
17 /****************************************************************************
18 * Included Files
19 ****************************************************************************/
20 #include <stdint.h>
21 #include <stdbool.h>
22
23 /****************************************************************************
24 * Pre-processor Definitions
25 ****************************************************************************/
26 #define CM_SD_SEEK_SET (0)
27 #define CM_SD_SEEK_CUR (1)
28 #define CM_SD_SEEK_END (2)
30 #define CM_SD_MAX_PATH (256)
31
32 /****************************************************************************
33 * Public Types
34 ****************************************************************************/
35 typedef struct
36 {
37 long long free_size;
38 long long total_size;
39 } cm_sd_system_info_t;
40
41
42 /****************************************************************************
43 * Public Data
44 ****************************************************************************/
45
46
47 /****************************************************************************
48 * Public Function Prototypes
49 ****************************************************************************/
50
51 /****************************************************************************
52 ***********************SD卡使用注意事项*************************************
53 * 1、通常情况开发板的硬件设计上，SD卡不会单独供电，即SD卡硬件上下
54 * 电和复位不由模组控制，故模组SD功能是在开发板上电时（也是SD卡
55 * 上电时）完成SD卡初始化操作
56 * 2、如1所言，模组上电时，默认情况下，SD卡控制引脚会发出一段脉冲用
57 * 于初始化SD卡。发出初始化脉冲操作早于OpenCPU SDK的入口函数执行
58 * 3、对于不使用SD卡功能的用户，上述2中发起的脉冲可能干扰用户硬件使
59 * 用（例如用户需要将该PIN脚配置为UART用于控制挂载芯片，该PIN脚发
60 * 发出的脉冲存在干扰挂载芯片工作的可能）。故SDK提供给用户禁用SD卡
61 * 发出脉冲的机制，如4所言
62 * 4、用户需禁止SD功能发出脉冲时，可通过如下任一方式进行设置
63 * （1）在文件系统中创建一个内容为"0"，名称为"sd.cfg"的文件用于禁止
64 * SD卡控制引脚发出脉冲，重启生效。模组上电的逻辑为：检查文件系统是
65 * 否存在"sd.cfg"的文件，若存在则读取其内容，若内容为"0"，则禁止SD
66 * 卡控制引脚发出脉冲。创建文件操作参考如下：
67 * int32_t fd = cm_fs_open("sd.cfg", CM_FS_WB);
68 * int32_t f_len = cm_fs_write(fd, "0", 1);
69 * int32_t ret = cm_fs_close(fd);
70 * （2）执行cm_sd_set_flag(0)，参考cm_sd_set_flag()接口说明
71 * 5、SD卡控制引脚和复用关系见《资源综述》
72 ***************************************************************************/
73
74 #ifdef __cplusplus
75 #define EXTERN extern "C"
76 extern "C"
77 {
78 #else
79 #define EXTERN extern
80 #endif
81
92 int32_t cm_sd_get_flag(void);
93
105 int32_t cm_sd_set_flag(int32_t flag);
106
119 bool cm_sd_is_formatted(char *vol);
120
134 int32_t cm_sd_format(char *vol);
135
154 int32_t cm_sd_fopen(const char *filename, const char *mode);
155
168 int32_t cm_sd_fclose(int32_t fd);
169
184 int32_t cm_sd_fread(int32_t fd, void *buf, uint32_t size);
185
200 int32_t cm_sd_fwrite(int32_t fd, const void *buf, uint32_t size);
201
217 int32_t cm_sd_fseek(int32_t fd, int32_t offset, int32_t base);
218
231 int32_t cm_sd_fdelete(const char *file_name);
232
246 int32_t cm_sd_fmove(const char *src, const char *dest);
247
260 int32_t cm_sd_exist(const char *file_name);
261
274 int32_t cm_sd_filesize(const char *file_name);
275
288 int32_t cm_sd_mkdir(char *path);
289
301 int32_t cm_sd_rmdir(char *path);
302
315 int32_t cm_sd_set_currentdir(char *path);
316
330 int32_t cm_sd_get_currentdir(char *path, uint32_t max_len);
331
345 int32_t cm_sd_getinfo(char *vol, cm_sd_system_info_t *info);
346
347
348 #undef EXTERN
349 #ifdef __cplusplus
350 }
351 #endif
352
356 #endif /* __CM_SDCARD_H__ */
357
cm_sd_set_flag
int32_t cm_sd_set_flag(int32_t flag)
设置SD标志位
cm_sd_getinfo
int32_t cm_sd_getinfo(char *vol, cm_sd_system_info_t *info)
获取文件系统信息
cm_sd_exist
int32_t cm_sd_exist(const char *file_name)
检查文件是否存在
cm_sd_fmove
int32_t cm_sd_fmove(const char *src, const char *dest)
更改文件名
cm_sd_get_currentdir
int32_t cm_sd_get_currentdir(char *path, uint32_t max_len)
获取当前文件夹路径
cm_sd_set_currentdir
int32_t cm_sd_set_currentdir(char *path)
设置当前文件夹路径
cm_sd_mkdir
int32_t cm_sd_mkdir(char *path)
创建文件夹
cm_sd_get_flag
int32_t cm_sd_get_flag(void)
获取SD标志位
cm_sd_fdelete
int32_t cm_sd_fdelete(const char *file_name)
删除文件
cm_sd_is_formatted
bool cm_sd_is_formatted(char *vol)
查询（SD卡）文件系统是否格式化
cm_sd_rmdir
int32_t cm_sd_rmdir(char *path)
删除文件夹
cm_sd_filesize
int32_t cm_sd_filesize(const char *file_name)
获取文件大小
cm_sd_fread
int32_t cm_sd_fread(int32_t fd, void *buf, uint32_t size)
读取文件内容
cm_sd_fwrite
int32_t cm_sd_fwrite(int32_t fd, const void *buf, uint32_t size)
写入文件内容
cm_sd_fseek
int32_t cm_sd_fseek(int32_t fd, int32_t offset, int32_t base)
文件指针定位
cm_sd_fclose
int32_t cm_sd_fclose(int32_t fd)
关闭一个文件
cm_sd_fopen
int32_t cm_sd_fopen(const char *filename, const char *mode)
打开一个文件
cm_sd_format
int32_t cm_sd_format(char *vol)
格式化（SD卡）文件系统
cm_sd_system_info_t
Definition: cm_sd.h:36
cm_sd_system_info_t::free_size
long long free_size
Definition: cm_sd.h:37
cm_sd_system_info_t::total_size
long long total_size
Definition: cm_sd.h:38


ML305A_ML307A_OpenCPU_API: cm_sim.h 源文件

  • cmiot
cm_sim.h
1
13 #ifndef __CM_SIM_H__
14 #define __CM_SIM_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 /****************************************************************************
21 * Pre-processor Definitions
22 ****************************************************************************/
23
24 #define CM_IMSI_LEN 16
26 /****************************************************************************
27 * Public Types
28 ****************************************************************************/
29
30 /****************************************************************************
31 * Public Data
32 ****************************************************************************/
33
34
35 /****************************************************************************
36 * Public Function Prototypes
37 ****************************************************************************/
38
39 #ifdef __cplusplus
40 #define EXTERN extern "C"
41 extern "C"
42 {
43 #else
44 #define EXTERN extern
45 #endif
46
47
59 int32_t cm_sim_get_imsi(char* imsi);
60
72 int32_t cm_sim_get_iccid(char* iccid);
73 #undef EXTERN
74 #ifdef __cplusplus
75 }
76 #endif
77
78
79 #endif /* __CM_SIM_H__ */
80
cm_sim_get_imsi
int32_t cm_sim_get_imsi(char *imsi)
获取设备IMSI
cm_sim_get_iccid
int32_t cm_sim_get_iccid(char *iccid)
获取设备ICCID


ML305A_ML307A_OpenCPU_API: cm_spi.h 源文件

  • cmiot
cm_spi.h
1
13 #ifndef __CM_SPI_H__
14 #define __CM_SPI_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19 #include <stdint.h>
20
21 /****************************************************************************
22 * Pre-processor Definitions
23 ****************************************************************************/
24 /*仅支持以下时钟频率，不可任意更改*/
26 #define CM_SPI_CLK_812_5KHZ (812500U)
27 #define CM_SPI_CLK_1_625MHZ (1625000U)
28 #define CM_SPI_CLK_3_25MHZ (3250000U)
29 #define CM_SPI_CLK_6_5MHZ (6500000U)
30 #define CM_SPI_CLK_13MHZ (13000000U)
31 #define CM_SPI_CLK_26MHZ (26000000U)
32 #define CM_SPI_CLK_52MHZ (52000000U)
33
34 /****************************************************************************
35 * Public Types
36 ****************************************************************************/
37
39 typedef enum
40 {
41 CM_SPI_DEV_0,
42 CM_SPI_DEV_1,
43 CM_SPI_DEV_NUM
44 } cm_spi_dev_e;
45
46
48 typedef enum
49 {
50 CM_SPI_MODE_SLAVE,
51 CM_SPI_MODE_MASTER
52 } cm_spi_mode_e;
53
55 typedef enum
56 {
57 CM_SPI_WOKR_MODE_0 ,
58 CM_SPI_WOKR_MODE_1,
59 CM_SPI_WOKR_MODE_2 ,
60 CM_SPI_WOKR_MODE_3
61 } cm_spi_work_mode_e;
62
63
65 typedef enum
66 {
67 CM_SPI_DATA_WIDTH_8BIT,
68 CM_SPI_DATA_WIDTH_16BIT,
69 CM_SPI_DATA_WIDTH_32BIT
70 } cm_spi_data_width_e;
71
73 typedef enum
74 {
75 CM_SPI_NSS_SOFT,
76 CM_SPI_NSS_HARD,
77 } cm_spi_nss_e;
78
79
81 typedef struct
82 {
83 cm_spi_mode_e mode;
84 cm_spi_work_mode_e work_mode;
85 cm_spi_data_width_e data_width;
86 cm_spi_nss_e nss;
87 int clk;
88 } cm_spi_cfg_t;
89
90 /****************************************************************************
91 * Public Data
92 ****************************************************************************/
93
94
95 /****************************************************************************
96 * Public Function Prototypes
97 ****************************************************************************/
98
99 #ifdef __cplusplus
100 #define EXTERN extern "C"
101 extern "C"
102 {
103 #else
104 #define EXTERN extern
105 #endif
106
107
121 int32_t cm_spi_open(cm_spi_dev_e dev, cm_spi_cfg_t *cfg);
122
123
136 int32_t cm_spi_close(cm_spi_dev_e dev);
137
138
152 int32_t cm_spi_write(cm_spi_dev_e dev, const void *data, uint32_t len);
153
154
168 int32_t cm_spi_read(cm_spi_dev_e dev, void *data, int32_t len);
169
170
186 int32_t cm_spi_write_then_read(cm_spi_dev_e dev, const void *w_data, uint32_t w_len, void *r_data, uint32_t r_len);
187
188
189
190 #undef EXTERN
191 #ifdef __cplusplus
192 }
193 #endif
194
195
196 #endif /* __CM_SPI_H__ */
197
cm_spi_write
int32_t cm_spi_write(cm_spi_dev_e dev, const void *data, uint32_t len)
spi写数据
cm_spi_work_mode_e
cm_spi_work_mode_e
Definition: cm_spi.h:56
cm_spi_write_then_read
int32_t cm_spi_write_then_read(cm_spi_dev_e dev, const void *w_data, uint32_t w_len, void *r_data, uint32_t r_len)
SPI写数据后读出数据
cm_spi_close
int32_t cm_spi_close(cm_spi_dev_e dev)
spi关闭，去初始化
cm_spi_nss_e
cm_spi_nss_e
Definition: cm_spi.h:74
cm_spi_data_width_e
cm_spi_data_width_e
Definition: cm_spi.h:66
cm_spi_read
int32_t cm_spi_read(cm_spi_dev_e dev, void *data, int32_t len)
SPI读数据
cm_spi_mode_e
cm_spi_mode_e
Definition: cm_spi.h:49
cm_spi_dev_e
cm_spi_dev_e
Definition: cm_spi.h:40
cm_spi_open
int32_t cm_spi_open(cm_spi_dev_e dev, cm_spi_cfg_t *cfg)
spi开启指定通道
CM_SPI_WOKR_MODE_3
@ CM_SPI_WOKR_MODE_3
Definition: cm_spi.h:60
CM_SPI_WOKR_MODE_2
@ CM_SPI_WOKR_MODE_2
Definition: cm_spi.h:59
CM_SPI_WOKR_MODE_1
@ CM_SPI_WOKR_MODE_1
Definition: cm_spi.h:58
CM_SPI_WOKR_MODE_0
@ CM_SPI_WOKR_MODE_0
Definition: cm_spi.h:57
CM_SPI_NSS_SOFT
@ CM_SPI_NSS_SOFT
Definition: cm_spi.h:75
CM_SPI_NSS_HARD
@ CM_SPI_NSS_HARD
Definition: cm_spi.h:76
CM_SPI_DATA_WIDTH_16BIT
@ CM_SPI_DATA_WIDTH_16BIT
Definition: cm_spi.h:68
CM_SPI_DATA_WIDTH_32BIT
@ CM_SPI_DATA_WIDTH_32BIT
Definition: cm_spi.h:69
CM_SPI_DATA_WIDTH_8BIT
@ CM_SPI_DATA_WIDTH_8BIT
Definition: cm_spi.h:67
CM_SPI_MODE_MASTER
@ CM_SPI_MODE_MASTER
Definition: cm_spi.h:51
CM_SPI_MODE_SLAVE
@ CM_SPI_MODE_SLAVE
Definition: cm_spi.h:50
CM_SPI_DEV_1
@ CM_SPI_DEV_1
Definition: cm_spi.h:42
CM_SPI_DEV_NUM
@ CM_SPI_DEV_NUM
Definition: cm_spi.h:43
CM_SPI_DEV_0
@ CM_SPI_DEV_0
Definition: cm_spi.h:41
cm_spi_cfg_t
Definition: cm_spi.h:82
cm_spi_cfg_t::work_mode
cm_spi_work_mode_e work_mode
Definition: cm_spi.h:84
cm_spi_cfg_t::mode
cm_spi_mode_e mode
Definition: cm_spi.h:83
cm_spi_cfg_t::data_width
cm_spi_data_width_e data_width
Definition: cm_spi.h:85
cm_spi_cfg_t::nss
cm_spi_nss_e nss
Definition: cm_spi.h:86
cm_spi_cfg_t::clk
int clk
Definition: cm_spi.h:87


ML305A_ML307A_OpenCPU_API: cm_ssl.h 源文件

  • cmiot
cm_ssl.h
1
13 #ifndef _CM_API_SSL_H_
14 #define _CM_API_SSL_H_
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 /****************************************************************************
21 * Pre-processor Definitions
22 ****************************************************************************/
23
24 /****************************************************************************
25 * Public Types
26 ****************************************************************************/
27
29 typedef enum
30 {
31 CM_SSL_PARAM_VERIFY,
32 CM_SSL_PARAM_NEGOTIME,
33 CM_SSL_PARAM_CA_CERT,
34 CM_SSL_PARAM_CLI_CERT,
35 CM_SSL_PARAM_CLI_KEY,
36 CM_SSL_PARAM_CA_CERT_DELETE,
37 CM_SSL_PARAM_CLI_CERT_DELETE,
38 CM_SSL_PARAM_CLI_KEY_DELETE,
39 } cm_ssl_param_type_e;
40
41 struct cm_ssl_ctx;
42 typedef struct cm_ssl_ctx cm_ssl_ctx_t;
43
44 /****************************************************************************
45 * Public Data
46 ****************************************************************************/
47
48 /****************************************************************************
49 * Public Function Prototypes
50 ****************************************************************************/
51
52 #ifdef __cplusplus
53 #define EXTERN extern "C"
54 extern "C"
55 {
56 #else
57 #define EXTERN extern
58 #endif
59
73 int32_t cm_ssl_setopt(int32_t ssl_id,cm_ssl_param_type_e type,void * value);
74
89 int cm_ssl_conn(void **cm_ssl_ctx_p, int ssl_id, int socket, int timeout);
90
98 void cm_ssl_close(void **cm_ssl_ctx_p);
99
113 int cm_ssl_write(cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len);
114
128 int cm_ssl_read(cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len);
129
141 int cm_ssl_check_pending(cm_ssl_ctx_t *cm_ssl_ctx);
142
153 int cm_ssl_get_bytes_avail(cm_ssl_ctx_t *cm_ssl_ctx);
154
155 #undef EXTERN
156 #ifdef __cplusplus
157 }
158 #endif
159
160 #endif /* __CM_SSL_H__ */
161
cm_ssl_close
void cm_ssl_close(void **cm_ssl_ctx_p)
SSL关闭
cm_ssl_conn
int cm_ssl_conn(void **cm_ssl_ctx_p, int ssl_id, int socket, int timeout)
SSL连接
cm_ssl_read
int cm_ssl_read(cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len)
SSL读
cm_ssl_check_pending
int cm_ssl_check_pending(cm_ssl_ctx_t *cm_ssl_ctx)
缓存区是否有未读数据
cm_ssl_setopt
int32_t cm_ssl_setopt(int32_t ssl_id, cm_ssl_param_type_e type, void *value)
配置SSL参数
cm_ssl_ctx_t
struct cm_ssl_ctx cm_ssl_ctx_t
Definition: cm_ssl.h:42
cm_ssl_write
int cm_ssl_write(cm_ssl_ctx_t *cm_ssl_ctx, void *data, int data_len)
SSL写
cm_ssl_get_bytes_avail
int cm_ssl_get_bytes_avail(cm_ssl_ctx_t *cm_ssl_ctx)
缓存区可读数据长度
cm_ssl_param_type_e
cm_ssl_param_type_e
Definition: cm_ssl.h:30
CM_SSL_PARAM_CLI_KEY_DELETE
@ CM_SSL_PARAM_CLI_KEY_DELETE
Definition: cm_ssl.h:38
CM_SSL_PARAM_VERIFY
@ CM_SSL_PARAM_VERIFY
Definition: cm_ssl.h:31
CM_SSL_PARAM_CLI_CERT
@ CM_SSL_PARAM_CLI_CERT
Definition: cm_ssl.h:34
CM_SSL_PARAM_CA_CERT
@ CM_SSL_PARAM_CA_CERT
Definition: cm_ssl.h:33
CM_SSL_PARAM_CA_CERT_DELETE
@ CM_SSL_PARAM_CA_CERT_DELETE
Definition: cm_ssl.h:36
CM_SSL_PARAM_CLI_KEY
@ CM_SSL_PARAM_CLI_KEY
Definition: cm_ssl.h:35
CM_SSL_PARAM_NEGOTIME
@ CM_SSL_PARAM_NEGOTIME
Definition: cm_ssl.h:32
CM_SSL_PARAM_CLI_CERT_DELETE
@ CM_SSL_PARAM_CLI_CERT_DELETE
Definition: cm_ssl.h:37


ML305A_ML307A_OpenCPU_API: cm_sys.h 源文件

  • cmiot
cm_sys.h
1
13 #ifndef __CM_SYS_H__
14 #define __CM_SYS_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19 #include <stdint.h>
20 #include <stdbool.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 #define CM_IMEI_LEN 16
27 #define CM_SN_LEN 65
28 #define CM_VER_LEN 65
30 /****************************************************************************
31 * Public Types
32 ****************************************************************************/
33
34 /****************************************************************************
35 * Public Data
36 ****************************************************************************/
37
38
39 /****************************************************************************
40 * Public Function Prototypes
41 ****************************************************************************/
42
43 #ifdef __cplusplus
44 #define EXTERN extern "C"
45 extern "C"
46 {
47 #else
48 #define EXTERN extern
49 #endif
50
62 int32_t cm_sys_get_imei(char *imei);
63
75 int32_t cm_sys_get_sn(char *sn);
76
87 int32_t cm_sys_get_cm_ver(char *ver_buff, uint32_t len);
88
102 void cm_log_printf(uint8_t log_level, const char *fmt, ...);
103
104 #undef EXTERN
105 #ifdef __cplusplus
106 }
107 #endif
108
112 #endif /* __CM_SYS_H__ */
113
cm_sys_get_cm_ver
int32_t cm_sys_get_cm_ver(char *ver_buff, uint32_t len)
获取SDK版本号
cm_log_printf
void cm_log_printf(uint8_t log_level, const char *fmt,...)
打印log信息
cm_sys_get_sn
int32_t cm_sys_get_sn(char *sn)
获取模组SN
cm_sys_get_imei
int32_t cm_sys_get_imei(char *imei)
获取模组IMEI


ML305A_ML307A_OpenCPU_API: cm_tts.h 源文件

  • cmiot
cm_tts.h
1
13 #ifndef __CM_TTS_CLIENT_H__
14 #define __CM_TTS_CLIENT_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 /****************************************************************************
27 * Public Types
28 ****************************************************************************/
29
35 typedef enum
36 {
37 CM_TTS_ENCODE_TYPE_UCS2 = 0,
38 CM_TTS_ENCODE_TYPE_GBK,
39 CM_TTS_ENCODE_TYPE_UTF8,
40 CM_TTS_ENCODE_TYPE_GB2312,
41 } cm_tts_encode_e;
42
46 typedef enum
47 {
48 CM_TTS_RDN_AUTO = 0,
49 CM_TTS_RDN_AS_VALUE,
50 CM_TTS_RDN_AS_NUMBER,
51 CM_TTS_RDN_AS_STR,
52 } cm_tts_rdn_e;
53
59 typedef enum
60 {
61 CM_TTS_PITCH_0 = 0,
62 CM_TTS_PITCH_1,
63 CM_TTS_PITCH_2,
64 CM_TTS_PITCH_3,
65 CM_TTS_PITCH_4,
66 CM_TTS_PITCH_5,
67 CM_TTS_PITCH_6,
68 CM_TTS_PITCH_7,
69 CM_TTS_PITCH_8,
70 CM_TTS_PITCH_9,
71 CM_TTS_PITCH_10,
72 CM_TTS_PITCH_11,
73 CM_TTS_PITCH_12,
74 CM_TTS_PITCH_13,
75 CM_TTS_PITCH_14,
76 CM_TTS_PITCH_15,
77 } cm_tts_pitch_e;
78
84 typedef enum
85 {
86 CM_TTS_VOICE_0 = 0,
87 CM_TTS_VOICE_1 = 1,
88 CM_TTS_VOICE_2 = 2,
89 CM_TTS_VOICE_3 = 3,
90 CM_TTS_VOICE_4 = 4,
91 } cm_tts_voice_e;
92
98 typedef enum
99 {
100 CM_TTS_CHANNEL_0 = 0,
101 CM_TTS_CHANNEL_1 = 1,
102 CM_TTS_CHANNEL_2 = 2,
103 CM_TTS_CHANNEL_3 = 3,
104 } cm_tts_channel_e;
105
110 typedef enum
111 {
112 CM_TTS_STATE_IDLE = 0,
113 CM_TTS_STATE_INTERRUPT,
114 CM_TTS_STATE_FAIL,
115 CM_TTS_STATE_WORKING,
116 } cm_tts_state_e;
117
119 typedef struct
120 {
121 int32_t speed;
122 int32_t volume;
123 cm_tts_encode_e encode;
124 cm_tts_rdn_e rdn;
125 cm_tts_pitch_e pitch;
126 cm_tts_voice_e voice;
127 int32_t channel;
128 char *url;
129 char *apiKey;
130 char *secretKey;
131 } cm_tts_cfg_t;
132
134 typedef enum
135 {
136 CM_TTS_EVENT_SYNTH_DATA = 1,
137 CM_TTS_EVENT_SYNTH_FAIL,
138 CM_TTS_EVENT_SYNTH_INTERRUPT,
139 CM_TTS_EVENT_SYNTH_FINISH,
140 CM_TTS_EVENT_PLAY_FAIL,
141 CM_TTS_EVENT_PLAY_INTERRUPT,
142 CM_TTS_EVENT_PLAY_FINISH,
143 } cm_tts_event_e;
144
145
146 /****************************************************************************
147 * Public Data
148 ****************************************************************************/
149
150 /****************************************************************************
151 * Public Function Prototypes
152 ****************************************************************************/
153
154 #ifdef __cplusplus
155 #define EXTERN extern "C"
156 extern "C" {
157 #else
158 #define EXTERN extern
159 #endif
160
161 /****************************************************************************/
162
163
170 typedef void (*cm_tts_callback)(cm_tts_event_e event, void *param);
171
184 int32_t cm_tts_init(cm_tts_cfg_t *cfg);
185
190 void cm_tts_deinit(void);
191
208 int32_t cm_tts_play(const void *text, int32_t len, cm_tts_callback cb, void *cb_param);
209
217 int32_t cm_tts_play_stop(void);
218
225 cm_tts_state_e cm_tts_get_state(void);
226
227 #undef EXTERN
228 #ifdef __cplusplus
229 }
230 #endif
231
232 #endif /* __CM_TTS_CLIENT_H__ */
233
cm_tts_get_state
cm_tts_state_e cm_tts_get_state(void)
获取TTS状态
cm_tts_deinit
void cm_tts_deinit(void)
TTS去初始化
cm_tts_encode_e
cm_tts_encode_e
中文文本编码方式
Definition: cm_tts.h:36
cm_tts_pitch_e
cm_tts_pitch_e
音调
Definition: cm_tts.h:60
cm_tts_rdn_e
cm_tts_rdn_e
数字播放方式
Definition: cm_tts.h:47
cm_tts_play_stop
int32_t cm_tts_play_stop(void)
停止TTS播放文字
cm_tts_event_e
cm_tts_event_e
Definition: cm_tts.h:135
cm_tts_callback
void(* cm_tts_callback)(cm_tts_event_e event, void *param)
TTS回调函数
Definition: cm_tts.h:170
cm_tts_init
int32_t cm_tts_init(cm_tts_cfg_t *cfg)
TTS初始化
cm_tts_state_e
cm_tts_state_e
TTS状态
Definition: cm_tts.h:111
cm_tts_voice_e
cm_tts_voice_e
音效
Definition: cm_tts.h:85
cm_tts_play
int32_t cm_tts_play(const void *text, int32_t len, cm_tts_callback cb, void *cb_param)
TTS播放文字
cm_tts_channel_e
cm_tts_channel_e
播放通道
Definition: cm_tts.h:99
CM_TTS_ENCODE_TYPE_UTF8
@ CM_TTS_ENCODE_TYPE_UTF8
Definition: cm_tts.h:39
CM_TTS_ENCODE_TYPE_GBK
@ CM_TTS_ENCODE_TYPE_GBK
Definition: cm_tts.h:38
CM_TTS_ENCODE_TYPE_GB2312
@ CM_TTS_ENCODE_TYPE_GB2312
Definition: cm_tts.h:40
CM_TTS_ENCODE_TYPE_UCS2
@ CM_TTS_ENCODE_TYPE_UCS2
Definition: cm_tts.h:37
CM_TTS_PITCH_15
@ CM_TTS_PITCH_15
Definition: cm_tts.h:76
CM_TTS_PITCH_11
@ CM_TTS_PITCH_11
Definition: cm_tts.h:72
CM_TTS_PITCH_10
@ CM_TTS_PITCH_10
Definition: cm_tts.h:71
CM_TTS_PITCH_3
@ CM_TTS_PITCH_3
Definition: cm_tts.h:64
CM_TTS_PITCH_14
@ CM_TTS_PITCH_14
Definition: cm_tts.h:75
CM_TTS_PITCH_0
@ CM_TTS_PITCH_0
Definition: cm_tts.h:61
CM_TTS_PITCH_9
@ CM_TTS_PITCH_9
Definition: cm_tts.h:70
CM_TTS_PITCH_8
@ CM_TTS_PITCH_8
Definition: cm_tts.h:69
CM_TTS_PITCH_4
@ CM_TTS_PITCH_4
Definition: cm_tts.h:65
CM_TTS_PITCH_6
@ CM_TTS_PITCH_6
Definition: cm_tts.h:67
CM_TTS_PITCH_2
@ CM_TTS_PITCH_2
Definition: cm_tts.h:63
CM_TTS_PITCH_1
@ CM_TTS_PITCH_1
Definition: cm_tts.h:62
CM_TTS_PITCH_5
@ CM_TTS_PITCH_5
Definition: cm_tts.h:66
CM_TTS_PITCH_13
@ CM_TTS_PITCH_13
Definition: cm_tts.h:74
CM_TTS_PITCH_7
@ CM_TTS_PITCH_7
Definition: cm_tts.h:68
CM_TTS_PITCH_12
@ CM_TTS_PITCH_12
Definition: cm_tts.h:73
CM_TTS_RDN_AUTO
@ CM_TTS_RDN_AUTO
Definition: cm_tts.h:48
CM_TTS_RDN_AS_STR
@ CM_TTS_RDN_AS_STR
Definition: cm_tts.h:51
CM_TTS_RDN_AS_NUMBER
@ CM_TTS_RDN_AS_NUMBER
Definition: cm_tts.h:50
CM_TTS_RDN_AS_VALUE
@ CM_TTS_RDN_AS_VALUE
Definition: cm_tts.h:49
CM_TTS_EVENT_PLAY_FAIL
@ CM_TTS_EVENT_PLAY_FAIL
Definition: cm_tts.h:140
CM_TTS_EVENT_SYNTH_FINISH
@ CM_TTS_EVENT_SYNTH_FINISH
Definition: cm_tts.h:139
CM_TTS_EVENT_PLAY_FINISH
@ CM_TTS_EVENT_PLAY_FINISH
Definition: cm_tts.h:142
CM_TTS_EVENT_SYNTH_FAIL
@ CM_TTS_EVENT_SYNTH_FAIL
Definition: cm_tts.h:137
CM_TTS_EVENT_SYNTH_DATA
@ CM_TTS_EVENT_SYNTH_DATA
Definition: cm_tts.h:136
CM_TTS_EVENT_PLAY_INTERRUPT
@ CM_TTS_EVENT_PLAY_INTERRUPT
Definition: cm_tts.h:141
CM_TTS_EVENT_SYNTH_INTERRUPT
@ CM_TTS_EVENT_SYNTH_INTERRUPT
Definition: cm_tts.h:138
CM_TTS_STATE_IDLE
@ CM_TTS_STATE_IDLE
Definition: cm_tts.h:112
CM_TTS_STATE_INTERRUPT
@ CM_TTS_STATE_INTERRUPT
Definition: cm_tts.h:113
CM_TTS_STATE_FAIL
@ CM_TTS_STATE_FAIL
Definition: cm_tts.h:114
CM_TTS_STATE_WORKING
@ CM_TTS_STATE_WORKING
Definition: cm_tts.h:115
CM_TTS_VOICE_1
@ CM_TTS_VOICE_1
Definition: cm_tts.h:87
CM_TTS_VOICE_3
@ CM_TTS_VOICE_3
Definition: cm_tts.h:89
CM_TTS_VOICE_0
@ CM_TTS_VOICE_0
Definition: cm_tts.h:86
CM_TTS_VOICE_4
@ CM_TTS_VOICE_4
Definition: cm_tts.h:90
CM_TTS_VOICE_2
@ CM_TTS_VOICE_2
Definition: cm_tts.h:88
CM_TTS_CHANNEL_3
@ CM_TTS_CHANNEL_3
Definition: cm_tts.h:103
CM_TTS_CHANNEL_1
@ CM_TTS_CHANNEL_1
Definition: cm_tts.h:101
CM_TTS_CHANNEL_2
@ CM_TTS_CHANNEL_2
Definition: cm_tts.h:102
CM_TTS_CHANNEL_0
@ CM_TTS_CHANNEL_0
Definition: cm_tts.h:100
cm_tts_cfg_t
Definition: cm_tts.h:120
cm_tts_cfg_t::channel
int32_t channel
Definition: cm_tts.h:127
cm_tts_cfg_t::speed
int32_t speed
Definition: cm_tts.h:121
cm_tts_cfg_t::encode
cm_tts_encode_e encode
Definition: cm_tts.h:123
cm_tts_cfg_t::apiKey
char * apiKey
Definition: cm_tts.h:129
cm_tts_cfg_t::rdn
cm_tts_rdn_e rdn
Definition: cm_tts.h:124
cm_tts_cfg_t::voice
cm_tts_voice_e voice
Definition: cm_tts.h:126
cm_tts_cfg_t::pitch
cm_tts_pitch_e pitch
Definition: cm_tts.h:125
cm_tts_cfg_t::url
char * url
Definition: cm_tts.h:128
cm_tts_cfg_t::volume
int32_t volume
Definition: cm_tts.h:122
cm_tts_cfg_t::secretKey
char * secretKey
Definition: cm_tts.h:130


ML305A_ML307A_OpenCPU_API: cm_uart.h 源文件

  • cmiot
cm_uart.h
1
13 #ifndef __CM_UART_H__
14 #define __CM_UART_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
27 #define CM_UART_BAUDRATE_300 (300U)
28 #define CM_UART_BAUDRATE_600 (600U)
29 #define CM_UART_BAUDRATE_1200 (1200U)
30 #define CM_UART_BAUDRATE_2400 (2400U)
31 #define CM_UART_BAUDRATE_4800 (4800U)
32 #define CM_UART_BAUDRATE_9600 (9600U)
33 #define CM_UART_BAUDRATE_14400 (14400U)
34 #define CM_UART_BAUDRATE_19200 (19200U)
35 #define CM_UART_BAUDRATE_28800 (28800U)
36 #define CM_UART_BAUDRATE_38400 (38400U)
37 #define CM_UART_BAUDRATE_57600 (57600U)
38 #define CM_UART_BAUDRATE_76800 (76800U)
39 #define CM_UART_BAUDRATE_115200 (115200U)
40 #define CM_UART_BAUDRATE_230400 (230400U)
41 #define CM_UART_BAUDRATE_460800 (460800U)
42 #define CM_UART_BAUDRATE_921600 (921600U)
43
45 /* 注意事项：受分频时钟影响，当某串口配置成某一特殊波特率后，分频时钟即被修改，即之后所有配置成普通模式的串口仅支持该特殊波特率。
46 * 配置成低功耗模式的串口采用单独的分频时钟，故不受该影响，即低功耗模式的串口依然可以使用115200及以下的标准波特率(不支持76800)。
47 * 若某串口配置成任意特殊波特率后，GNSS功能将无法正常使用。
48 * 示例：若某一串口配置成256000波特率的普通模式，则之后所有配置成普通模式的串口仅支持256000波特率，而配置成低功耗模式的串口依然支持115200及以下的标准波特率(不支持76800)。
49 */
50 #define CM_UART_BAUDRATE_256000 (256000U)
51 #define CM_UART_BAUDRATE_2000000 (2000000U)
52
53 /****************************************************************************
54 * Public Types
55 ****************************************************************************/
56
58 /* FOTA升级期间，可能会有数据从主串口吐出（对应ML307A、ML305A为UART0，ML302A为UART1），用户无需关注该数据，也不应处理该数据 */
59 /* 对于ML307A，UART2和GNSS有冲突，两者不可同时使用 */
60 typedef enum{
61 CM_UART_DEV_0,
62 CM_UART_DEV_1,
63 CM_UART_DEV_2,
64 CM_UART_DEV_NUM
65 } cm_uart_dev_e;
66
68 typedef enum{
69 CM_UART_BYTE_SIZE_8 = 8,
70 CM_UART_BYTE_SIZE_7 = 7,
71 CM_UART_BYTE_SIZE_6 = 6,
72 CM_UART_BYTE_SIZE_5 = 5,
73 } cm_uart_byte_size_e;
74
76 typedef enum{
77 CM_UART_PARITY_NONE,
78 CM_UART_PARITY_ODD,
79 CM_UART_PARITY_EVEN,
80 CM_UART_PARITY_MARK,
81 CM_UART_PARITY_SPACE
82 } cm_uart_parity_e;
83
85 typedef enum{
86 CM_UART_STOP_BIT_ONE,
87 CM_UART_STOP_BIT_ONE_HALF,
88 CM_UART_STOP_BIT_TWO
89 } cm_uart_stop_bit_e;
90
92 typedef enum{
93 CM_UART_FLOW_CTRL_NONE,
94 CM_UART_FLOW_CTRL_HW,
95 } cm_uart_flow_ctrl_e;
96
98 typedef enum{
99 CM_UART_RET_OK = 0,
100 CM_UART_RET_INVALID_PARAM = -1,
101 } cm_uart_ret_e;
102
104 typedef struct{
105 cm_uart_byte_size_e byte_size;
106 cm_uart_parity_e parity;
107 cm_uart_stop_bit_e stop_bit;
108 cm_uart_flow_ctrl_e flow_ctrl;
109 int baudrate;
110 int is_lpuart;
111 } cm_uart_cfg_t;
112
114 typedef enum
115 {
116 CM_UART_EVENT_TYPE_RX_ARRIVED = (1 << 0),
117 CM_UART_EVENT_TYPE_RX_OVERFLOW = (1 << 1),
118 CM_UART_EVENT_TYPE_TX_COMPLETE = (1 << 2)
119 }cm_uart_event_type_e;
120
122 typedef struct{
123 uint32_t event_type;
124 void *event_param;
125 void *event_entry;
126 } cm_uart_event_t;
127
128 typedef void (*cm_uart_event_cb_t)(void *param, uint32_t evt);
129
130 /****************************************************************************
131 * Public Data
132 ****************************************************************************/
133
134
135 /****************************************************************************
136 * Public Function Prototypes
137 ****************************************************************************/
138
139 /****************************************************************************
140 ***********************UART使用注意事项*************************************
141 * 1、UART引脚和SD卡控制引脚所用PIN脚存在复用关系，若用户使用此PIN脚进行
142 * UART功能开发，请阅知cm_sd.h中【SD卡使用注意事项】
143 * 2、UART引脚和SD卡控制引脚复用关系见《资源综述》
144 ***************************************************************************/
145
146
147 #ifdef __cplusplus
148 #define EXTERN extern "C"
149 extern "C"
150 {
151 #else
152 #define EXTERN extern
153 #endif
154
155 /****************************************************************************/
156
170 int32_t cm_uart_open(cm_uart_dev_e dev, cm_uart_cfg_t *cfg);
171
186 int32_t cm_uart_register_event(cm_uart_dev_e dev, void *event);
187
199 int32_t cm_uart_close(cm_uart_dev_e dev);
200
215 int32_t cm_uart_write(cm_uart_dev_e dev, const void *data, int32_t len, int32_t timeout);
216
231 int32_t cm_uart_read(cm_uart_dev_e dev, void* data, int32_t len, int32_t timeout);
232
233 #undef EXTERN
234 #ifdef __cplusplus
235 }
236 #endif
237
238 #endif /* __CM_UART_H__ */
239
cm_uart_write
int32_t cm_uart_write(cm_uart_dev_e dev, const void *data, int32_t len, int32_t timeout)
串口写数据
cm_uart_stop_bit_e
cm_uart_stop_bit_e
Definition: cm_uart.h:85
cm_uart_read
int32_t cm_uart_read(cm_uart_dev_e dev, void *data, int32_t len, int32_t timeout)
串口读数据
cm_uart_event_cb_t
void(* cm_uart_event_cb_t)(void *param, uint32_t evt)
Definition: cm_uart.h:128
cm_uart_open
int32_t cm_uart_open(cm_uart_dev_e dev, cm_uart_cfg_t *cfg)
打开串口
cm_uart_close
int32_t cm_uart_close(cm_uart_dev_e dev)
关闭串口
cm_uart_dev_e
cm_uart_dev_e
Definition: cm_uart.h:60
cm_uart_byte_size_e
cm_uart_byte_size_e
Definition: cm_uart.h:68
cm_uart_flow_ctrl_e
cm_uart_flow_ctrl_e
Definition: cm_uart.h:92
cm_uart_event_type_e
cm_uart_event_type_e
Definition: cm_uart.h:115
cm_uart_ret_e
cm_uart_ret_e
Definition: cm_uart.h:98
cm_uart_register_event
int32_t cm_uart_register_event(cm_uart_dev_e dev, void *event)
注册串口事件
cm_uart_parity_e
cm_uart_parity_e
Definition: cm_uart.h:76
CM_UART_STOP_BIT_ONE
@ CM_UART_STOP_BIT_ONE
Definition: cm_uart.h:86
CM_UART_STOP_BIT_TWO
@ CM_UART_STOP_BIT_TWO
Definition: cm_uart.h:88
CM_UART_STOP_BIT_ONE_HALF
@ CM_UART_STOP_BIT_ONE_HALF
Definition: cm_uart.h:87
CM_UART_DEV_2
@ CM_UART_DEV_2
Definition: cm_uart.h:63
CM_UART_DEV_1
@ CM_UART_DEV_1
Definition: cm_uart.h:62
CM_UART_DEV_NUM
@ CM_UART_DEV_NUM
Definition: cm_uart.h:64
CM_UART_DEV_0
@ CM_UART_DEV_0
Definition: cm_uart.h:61
CM_UART_BYTE_SIZE_8
@ CM_UART_BYTE_SIZE_8
Definition: cm_uart.h:69
CM_UART_BYTE_SIZE_6
@ CM_UART_BYTE_SIZE_6
Definition: cm_uart.h:71
CM_UART_BYTE_SIZE_7
@ CM_UART_BYTE_SIZE_7
Definition: cm_uart.h:70
CM_UART_BYTE_SIZE_5
@ CM_UART_BYTE_SIZE_5
Definition: cm_uart.h:72
CM_UART_FLOW_CTRL_NONE
@ CM_UART_FLOW_CTRL_NONE
Definition: cm_uart.h:93
CM_UART_FLOW_CTRL_HW
@ CM_UART_FLOW_CTRL_HW
Definition: cm_uart.h:94
CM_UART_EVENT_TYPE_RX_ARRIVED
@ CM_UART_EVENT_TYPE_RX_ARRIVED
Definition: cm_uart.h:116
CM_UART_EVENT_TYPE_TX_COMPLETE
@ CM_UART_EVENT_TYPE_TX_COMPLETE
Definition: cm_uart.h:118
CM_UART_EVENT_TYPE_RX_OVERFLOW
@ CM_UART_EVENT_TYPE_RX_OVERFLOW
Definition: cm_uart.h:117
CM_UART_RET_INVALID_PARAM
@ CM_UART_RET_INVALID_PARAM
Definition: cm_uart.h:100
CM_UART_RET_OK
@ CM_UART_RET_OK
Definition: cm_uart.h:99
CM_UART_PARITY_MARK
@ CM_UART_PARITY_MARK
Definition: cm_uart.h:80
CM_UART_PARITY_EVEN
@ CM_UART_PARITY_EVEN
Definition: cm_uart.h:79
CM_UART_PARITY_SPACE
@ CM_UART_PARITY_SPACE
Definition: cm_uart.h:81
CM_UART_PARITY_ODD
@ CM_UART_PARITY_ODD
Definition: cm_uart.h:78
CM_UART_PARITY_NONE
@ CM_UART_PARITY_NONE
Definition: cm_uart.h:77
cm_uart_cfg_t
Definition: cm_uart.h:104
cm_uart_cfg_t::is_lpuart
int is_lpuart
Definition: cm_uart.h:110
cm_uart_cfg_t::stop_bit
cm_uart_stop_bit_e stop_bit
Definition: cm_uart.h:107
cm_uart_cfg_t::flow_ctrl
cm_uart_flow_ctrl_e flow_ctrl
Definition: cm_uart.h:108
cm_uart_cfg_t::byte_size
cm_uart_byte_size_e byte_size
Definition: cm_uart.h:105
cm_uart_cfg_t::baudrate
int baudrate
Definition: cm_uart.h:109
cm_uart_cfg_t::parity
cm_uart_parity_e parity
Definition: cm_uart.h:106
cm_uart_event_t
Definition: cm_uart.h:122
cm_uart_event_t::event_param
void * event_param
Definition: cm_uart.h:124
cm_uart_event_t::event_type
uint32_t event_type
Definition: cm_uart.h:123
cm_uart_event_t::event_entry
void * event_entry
Definition: cm_uart.h:125


ML305A_ML307A_OpenCPU_API: cm_usb.h 源文件

  • cmiot
cm_usb.h
1
14 #ifndef __CM_USB_H__
15 #define __CM_USB_H__
16
17
18 #include <stddef.h>
19
20
21 #define CM_USB_EVT_INSERT 1
22 #define CM_USB_EVT_REMOVE 0
23
24
26 typedef void (*cm_usb2com_recv_cb)(void *data, int32_t len);
27
29 typedef void (*cm_usb2com_status_cb)(int32_t evt);
30
31
41 void cm_usb2com_register_recv_cb(cm_usb2com_recv_cb recv_cb);
42
53 int32_t cm_usb2com_send_data(void *data, int32_t len);
54
64 void cm_usb2com_register_status_cb(cm_usb2com_status_cb status_cb);
65
66
67 #endif
68
cm_usb2com_register_recv_cb
void cm_usb2com_register_recv_cb(cm_usb2com_recv_cb recv_cb)
注册USB2COM接收回调函数
cm_usb2com_status_cb
void(* cm_usb2com_status_cb)(int32_t evt)
Definition: cm_usb.h:29
cm_usb2com_send_data
int32_t cm_usb2com_send_data(void *data, int32_t len)
USB2COM发送数据
cm_usb2com_recv_cb
void(* cm_usb2com_recv_cb)(void *data, int32_t len)
Definition: cm_usb.h:26
cm_usb2com_register_status_cb
void cm_usb2com_register_status_cb(cm_usb2com_status_cb status_cb)
注册USB2COM插拔事件回调函数


ML305A_ML307A_OpenCPU_API: cm_utils.h 源文件

  • cmiot
cm_utils.h
1
10 #ifndef __CM_UTILS_H__
11 #define __CM_UTILS_H__
12
13 /*函数声明时可通过此宏定义指定加载段落，不加修饰即默认使用.text段*/
14 #define __RUN_AT_RAM __attribute__((used, section(".sramtext")))
15 #define __RUN_AT_XIP __attribute__((used, section(".text")))
16
17 #endif


ML305A_ML307A_OpenCPU_API: cm_virt_at.h 源文件

  • cmiot
cm_virt_at.h
1
13 #ifndef __CM_VIRT_AT_H__
14 #define __CM_VIRT_AT_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26
27 /****************************************************************************
28 * Public Types
29 ****************************************************************************/
30
31
32 /****************************************************************************
33 * Public Data
34 ****************************************************************************/
35
36
37 /****************************************************************************
38 * Public Function Prototypes
39 ****************************************************************************/
40 /****************************************************************************
41 ***********************虚拟AT需注意事项*************************************
42 * 1、虚拟AT不完全支持中移开发的AT手册中的指令,仅支持3GPP的AT指令，
43 * 例如：
44 * AT+MUESTATS=radio AT+MUESTATS=cell AT+MUESTATS=sband
45 * 等AT指令不支持,用户需根据实际使用测试结果为准；其中部分功能
46 * 的AT指令也有所区别，虚拟AT都遵循了使用3GPP标准的AT指令，
47 * 例如：
48 * (1)获取ICCID的指令为【AT*ICCID?】(2)开启拨号上网的AT指令为
49 * 【AT+MDIALUPCFG="auto",1】,关闭为【AT+MDIALUPCFG="auto",0】
50 * 2、为了避免虚拟AT使用频繁导致程序阻塞，暂不支持使用多线程操作虚
51 * 拟AT，同时在使用虚拟AT时每次都需要初始化和去初始化。
52 * 3、虚拟AT读取数据的方式是使用消息队列一次性读取固定长度的数据，
53 * 当需要读取的数据过长时，需要多次发指令进行一逐读取；例如：
54 * 读取短信消息。
55 * 4、使用接口cm_virt_at_sms_send发送PDU格式的短信时，需要在发送
56 * 的信息编码中加入：短信中心号码（SMSC）。
57 ***************************************************************************/
58
59 #ifdef __cplusplus
60 #define EXTERN extern "C"
61 extern "C"
62 {
63 #else
64 #define EXTERN extern
65 #endif
67 typedef void (*cm_at_urc_callback)(char *urc);
69 typedef void (*cm_virt_at_cb)(void *param);
70
82 int32_t cm_virt_at_init(cm_virt_at_cb cb);
95 int32_t cm_virt_at_send(uint8_t * data,int32_t len);
108 int32_t cm_virt_at_get(unsigned char* data,int len);
109
118 void cm_virt_at_deinit(void);
119
131 void cm_virt_at_urc_reg(cm_at_urc_callback cb);
132
146 int cm_virt_at_sms_send(char* atCmgs, char* msgData, int simId);
147
161 int cm_virt_at_msg_memory(char* smsNum, char* msgData, int simId);
162
163 #undef EXTERN
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif /* __CM_VIRT_AT_H__ */
169
cm_virt_at_init
int32_t cm_virt_at_init(cm_virt_at_cb cb)
初始化AT虚拟通道
cm_virt_at_send
int32_t cm_virt_at_send(uint8_t *data, int32_t len)
通过AT虚拟通道发送数据
cm_at_urc_callback
void(* cm_at_urc_callback)(char *urc)
Definition: cm_virt_at.h:67
cm_virt_at_deinit
void cm_virt_at_deinit(void)
AT虚拟通道去初始化
cm_virt_at_get
int32_t cm_virt_at_get(unsigned char *data, int len)
通过AT虚拟通道接收数据
cm_virt_at_msg_memory
int cm_virt_at_msg_memory(char *smsNum, char *msgData, int simId)
本地短信存储
cm_virt_at_urc_reg
void cm_virt_at_urc_reg(cm_at_urc_callback cb)
初始化消息主动上报通道
cm_virt_at_cb
void(* cm_virt_at_cb)(void *param)
Definition: cm_virt_at.h:69
cm_virt_at_sms_send
int cm_virt_at_sms_send(char *atCmgs, char *msgData, int simId)
发送短信


ML305A_ML307A_OpenCPU_API: cm_wifiscan.h 源文件

  • cmiot
cm_wifiscan.h
1
13 #ifndef __CM_WIFISCAN_H__
14 #define __CM_WIFISCAN_H__
15
16 /****************************************************************************
17 * Included Files
18 ****************************************************************************/
19
20 #include <stdint.h>
21
22 /****************************************************************************
23 * Pre-processor Definitions
24 ****************************************************************************/
25
26 #define MAX_BSSID_NUM_TOTAL 30
27 #define SIZE_MAC_ADDRESS 6
29 /****************************************************************************
30 * Public Types
31 ****************************************************************************/
32
34 typedef enum
35 {
36 CM_WIFI_SCAN_LTE_HIGH =0,
37 CM_WIFI_SCAN_WIFI_HIGH,
38 }cm_wifi_scan_priority_e;
39
41 typedef struct
42 {
43 uint8_t bssid[SIZE_MAC_ADDRESS];
44 uint8_t padding[2];
45 int32_t rssi;
46 uint32_t channel_number;
47 }cm_wifi_scan_cell_info_t;
48
50 typedef struct
51 {
52 uint8_t bssid_number;
53 cm_wifi_scan_cell_info_t channel_cell_list[MAX_BSSID_NUM_TOTAL];
54 }cm_wifi_scan_info_t;
55
57 typedef enum
58 {
59 CM_WIFI_SCAN_CFG_ROUND,
60 CM_WIFI_SCAN_CFG_MAX_COUNT,
61 CM_WIFI_SCAN_CFG_TIMEOUT,
62 CM_WIFI_SCAN_CFG_PRIORITY,
63 } cm_wifi_scan_cfg_type_e;
64
65 /****************************************************************************
66 * Public Data
67 ****************************************************************************/
68
69
70 /****************************************************************************
71 * Public Function Prototypes
72 ****************************************************************************/
73
74 #ifdef __cplusplus
75 #define EXTERN extern "C"
76 extern "C"
77 {
78 #else
79 #define EXTERN extern
80 #endif
81
90 typedef void (*cm_wifiscan_callback_t)(cm_wifi_scan_info_t *param, void *user_param);
91
104 int32_t cm_wifiscan_cfg(cm_wifi_scan_cfg_type_e type, void *value);
105
119 int32_t cm_wifiscan_start(cm_wifiscan_callback_t cb, void *user_param);
120
130 int32_t cm_wifiscan_stop(void);
131
143 int32_t cm_wifiscan_query(cm_wifi_scan_info_t **param);
144
145 #undef EXTERN
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif
151
cm_wifiscan_stop
int32_t cm_wifiscan_stop(void)
停止扫描
cm_wifi_scan_cfg_type_e
cm_wifi_scan_cfg_type_e
Definition: cm_wifiscan.h:58
cm_wifiscan_callback_t
void(* cm_wifiscan_callback_t)(cm_wifi_scan_info_t *param, void *user_param)
扫描回调函数
Definition: cm_wifiscan.h:90
MAX_BSSID_NUM_TOTAL
#define MAX_BSSID_NUM_TOTAL
Definition: cm_wifiscan.h:26
SIZE_MAC_ADDRESS
#define SIZE_MAC_ADDRESS
Definition: cm_wifiscan.h:27
cm_wifiscan_cfg
int32_t cm_wifiscan_cfg(cm_wifi_scan_cfg_type_e type, void *value)
设置扫描参数
cm_wifiscan_start
int32_t cm_wifiscan_start(cm_wifiscan_callback_t cb, void *user_param)
开始扫描
cm_wifiscan_query
int32_t cm_wifiscan_query(cm_wifi_scan_info_t **param)
查询最近一次扫描结果
cm_wifi_scan_priority_e
cm_wifi_scan_priority_e
Definition: cm_wifiscan.h:35
CM_WIFI_SCAN_CFG_MAX_COUNT
@ CM_WIFI_SCAN_CFG_MAX_COUNT
Definition: cm_wifiscan.h:60
CM_WIFI_SCAN_CFG_TIMEOUT
@ CM_WIFI_SCAN_CFG_TIMEOUT
Definition: cm_wifiscan.h:61
CM_WIFI_SCAN_CFG_PRIORITY
@ CM_WIFI_SCAN_CFG_PRIORITY
Definition: cm_wifiscan.h:62
CM_WIFI_SCAN_CFG_ROUND
@ CM_WIFI_SCAN_CFG_ROUND
Definition: cm_wifiscan.h:59
CM_WIFI_SCAN_LTE_HIGH
@ CM_WIFI_SCAN_LTE_HIGH
Definition: cm_wifiscan.h:36
CM_WIFI_SCAN_WIFI_HIGH
@ CM_WIFI_SCAN_WIFI_HIGH
Definition: cm_wifiscan.h:37
cm_wifi_scan_cell_info_t
Definition: cm_wifiscan.h:42
cm_wifi_scan_cell_info_t::rssi
int32_t rssi
Definition: cm_wifiscan.h:45
cm_wifi_scan_cell_info_t::channel_number
uint32_t channel_number
Definition: cm_wifiscan.h:46
cm_wifi_scan_info_t
Definition: cm_wifiscan.h:51
cm_wifi_scan_info_t::bssid_number
uint8_t bssid_number
Definition: cm_wifiscan.h:52


ML305A_ML307A_OpenCPU_API: cmiot 目录参考

  • cmiot
cmiot 目录参考

文件

文件 | cm_adc.h [代码]
ADC设备接口
文件 | cm_asocket.h [代码]
异步socket接口
文件 | cm_async_dns.h [代码]
异步DNS解析接口
文件 | cm_audio_common.h [代码]
Audio 通用接口
文件 | cm_audio_player.h [代码]
Audio player接口
文件 | cm_audio_recorder.h [代码]
Audio recorder接口
文件 | cm_camera.h [代码]
相机接口
文件 | cm_camera_sensor.h [代码]
相机硬件驱动适配接口
文件 | cm_cpuinfo.h [代码]
cpu信息统计，禁止跨线程使用
文件 | cm_eloop.h [代码]
Event Loop模块接口定义
文件 | cm_fota.h [代码]
FOTA
文件 | cm_fs.h [代码]
文件系统通用API接口
文件 | cm_ftp.h [代码]
FTP接口
文件 | cm_gnss.h [代码]
GNSS接口
文件 | cm_gpio.h [代码]
GPIO接口
文件 | cm_http.h [代码]
文件 | cm_i2c.h [代码]
I2C驱动接口
文件 | cm_iomux.h [代码]
IOMUX接口
文件 | cm_keypad.h [代码]
cm_keypad接口
文件 | cm_lbs.h [代码]
LBS接口
文件 | cm_lcd.h [代码]
内存管理
文件 | cm_local_tts.h [代码]
离线TTS接口
文件 | cm_mem.h [代码]
内存管理
文件 | cm_modem_info.h [代码]
Modem_info接口
文件 | cm_mqtt.h [代码]
MQTT接口
文件 | cm_ntp.h [代码]
NTP协议客户端接口
文件 | cm_os.h [代码]
操作系统接口
文件 | cm_pm.h [代码]
PM接口
文件 | cm_pwm.h [代码]
PWM接口
文件 | cm_qr.h [代码]
二维码解码接口
文件 | cm_rtc.h [代码]
RTC管理
文件 | cm_sd.h [代码]
SDCARD
文件 | cm_sim.h [代码]
SIM接口
文件 | cm_spi.h [代码]
SPI驱动接口
文件 | cm_ssl.h [代码]
SSL通用API接口
文件 | cm_sys.h [代码]
系统管理
文件 | cm_tts.h [代码]
文件 | cm_uart.h [代码]
UART接口
文件 | cm_usb.h [代码]
usb虚拟串口功能
文件 | cm_utils.h [代码]
通用定义
文件 | cm_virt_at.h [代码]
虚拟AT通道接口
文件 | cm_wifiscan.h [代码]
wifiscan 接口


ML305A_ML307A_OpenCPU_API: 首页

ML305A_ML307A_OpenCPU_API 文档