InPlay API
hal_ir.h
1 
12 #ifndef HAL_IR_H
13 #define HAL_IR_H
14 #include <stdint.h>
15 
16 #include "hal/hal_counter.h"
30 #define IR_IDLE 0x1
32 #define IR_SEND 0x2
33 #define IR_RECV 0x4
34 //#define IR_FREQ 0x8
35 #define IR_RECV_FREQ 0x10
36 
37 
38 #define IR_FREQ_BUF_LEN 6
39 
40 
41 //#define IR_MSG_BASE 0x00020000UL ///<Message base
42 //#define IR_MSG_RECV_STOP 0x1UL ///< Recieve stop message
43 //#define IR_MSG_SEND_STOP 0x2UL ///< Send stop message
44 
46 enum {
47  IR0_ID = 0,
48  IR_MAX_ID,
49 };
50 enum ir_error{
51  IR_ERR_OK = 0,
52  IR_ERR_INVALID_PARAM = -1,
53  IR_ERR_SEM = -2,
54  IR_ERR_STOP = -3,
55 };
56 
57 typedef struct {
58  char cnt_id;
59  char tx_port;
60  char tx_pin;
61  char rx_port;
62  char rx_pin;
63  char prio;
64  void *rx_arg;
65  void (*rx_cb)(void* arg, int status, int sz);
66  void *tx_arg;
67  void (*tx_cb)(void* arg, int status);
68 } ir_init_t;
69 
70 
71 
78 void *hal_ir_open(int id, ir_init_t *init);
79 
84 void hal_ir_close(void* hdl);
85 
94 int hal_ir_rx(void* hdl, uint32_t *buf, int size, uint32_t *out_sz);
95 
104 int hal_ir_rx_freq(void *hdl, uint32_t *buf, int size, uint32_t *out_sz);
105 
111 int hal_ir_stop_rx(void* hdl);
112 
120 int hal_ir_tx(void* hdl, uint32_t *buf, int size);
121 
127 int hal_ir_stop_tx(void *hdl);
128 
138 int hal_ir_tx_repeat(void *hdl, uint32_t *buf, int size, uint32_t *repeat_buf, int repeat_size);
139 
146 int hal_ir_set_clk(void *hdl, uint32_t high_usec, uint32_t low_usec);
147 
148 //int hal_ir_is_stop(ir_dev_t *dev);
149 
150 
152 #endif
int hal_ir_set_clk(void *hdl, uint32_t high_usec, uint32_t low_usec)
Set IR carrier clock mannually.
void hal_ir_close(void *hdl)
Close IR device.
int hal_ir_tx(void *hdl, uint32_t *buf, int size)
Start send data.
int hal_ir_stop_rx(void *hdl)
Stop reciece data.
int hal_ir_tx_repeat(void *hdl, uint32_t *buf, int size, uint32_t *repeat_buf, int repeat_size)
Send data and then send repeated data continually.
int hal_ir_rx_freq(void *hdl, uint32_t *buf, int size, uint32_t *out_sz)
Start reciece data for frequence caculation. Need call.
int hal_ir_stop_tx(void *hdl)
Stop send data.
int hal_ir_rx(void *hdl, uint32_t *buf, int size, uint32_t *out_sz)
Start reciece data. Need call.
void * hal_ir_open(int id, ir_init_t *init)
Open IR device.