1 /******************************************************************************
2 ** File Name: pcm_drvapi.h *
3 ** Author: Thomas.Chai *
5 ** Copyright: 2006 Spreatrum, Incoporated. All Rights Reserved. *
6 ** Description: This file contains driver for LCM controller.
8 ******************************************************************************/
10 #ifndef _PCM_DRVAPI_H_
11 #define _PCM_DRVAPI_H_
13 /**---------------------------------------------------------------------------*
15 **---------------------------------------------------------------------------*/
22 /**---------------------------------------------------------------------------*
24 **---------------------------------------------------------------------------*/
27 /**---------------------------------------------------------------------------*
29 **---------------------------------------------------------------------------*/
33 LONG_FRAME_SYNC_MODE = 0, //long frame sync mode.
34 SHORT_FRAME_SYNC_MODE = 1, //short frame sync mode
35 MULTI_SLOT_OPERATOR_MODE = 2
41 MASTER_MODE = 0, //PCM working at master mode
42 SLAVE_MODE = 1 //PCM working at slave mode
55 TX_8BITS_PER_FRAME = 0, // the data bit number of user transmitting/receiving is 8 bits
56 TX_16BITS_PER_FRAME = 1, // the data bit number of user transmitting/receiving is 16 bits
57 TX_32BITS_PER_FRAME = 2 // the data bit number of user transmitting/receiving is 32 bits
70 ERR_PCM_NO_TX_DATA, // No vaild data to transmit
71 ERR_PCM_TIMEOUT , // receive data is timeout
72 ERR_PCM_CLOSE , // PCM had been closed
73 ERR_PCM_PARAM_SCALE_WRONG , // PCM_PARA_T Parameter scale wrong
74 ERR_PCM_PARAM_DISMATCH_WRONG, // INPUT Parameters dismatch
75 ERR_PCM_POINTER_NULL, // Input pointer is PNULL
76 ERR_PCM_OPERATE_FAIL, // Operate fail
77 ERR_PCM_FUNC_NOT_SUPPORT // PCM not support this function
83 /**---------------------------------------------------------------------------*
85 **---------------------------------------------------------------------------*/
88 uint32 value; //the data number had been transmitted/received
89 ERR_PCM_E error; //the status of current transmitting/receiving
93 typedef ERR_PCM_E (*PCMCallback) (CALL_RET_T ret);
98 PCM_SYNC_MODE_E sync_mode; //pcm operate mode.(sc6600m only support short frame sync mode)
99 PCM_OPERATE_MODE_E operate_mode; //Master/Slave mode.0:master 1:slave
100 DATA_BIT_NUM_E data_bit_num; //the data bit number want to transmit
102 uint8 tx_watermark; // the watermark value when the Tx interrupt will happen 1 ~~~~~ 32
103 uint8 rx_watermark; // the watermark value when the Rx interrupt will happen
104 PCMCallback tx_CallBack; // Tx call back function
105 PCMCallback rx_CallBack; // Rx call back function
110 uint32 size; // Total Size of the buffer.
111 uint32 start_point; // First data in the buffer.
112 uint8 *sio_buf_ptr; // Sio buffer address.
120 PCM_STATUS_E pcm_status;
121 uint8 byte_per_frame;
126 /**---------------------------------------------------------------------------*
127 ** Function Prototype
128 **---------------------------------------------------------------------------*/
129 /*****************************************************************************/
130 // Description: This function initalize PCM Paramer
131 // Author: Thomas.Chai
134 /*****************************************************************************/
135 PUBLIC void PCM_Init (void);
138 /*****************************************************************************/
139 // Description: Open a PCM interface, and start to transmit data. you can set
140 // a new paramer for PCM, and you also set the paramer to zero,
141 // then it will use the default setting to PCM. If the new paramer
142 // is unvaild, it also will use the default setting
143 // Author: Thomas.Chai
146 /*****************************************************************************/
147 PUBLIC ERR_PCM_E PCM_Open (PCM_PARA_T *paramer);
150 /*****************************************************************************/
151 // Description: Give the outside buffer pointer to PCM data sending buffer
152 // pointer. and start the transmit interrupt to transmit data
153 // Global resource dependence:
154 // Author: Thomas.Chai
156 /*****************************************************************************/
157 PUBLIC int32 PCM_SendData (uint8 *data_ptr, //data pointer of user want to send
158 uint32 data_len); //data length
161 /*****************************************************************************/
162 // Description: Move received data from fifo to outside buffer
163 // Global resource dependence:
164 // Author: Thomas.Chai
166 /*****************************************************************************/
167 PUBLIC int32 PCM_ReceiveData (uint8 *buff_ptr, //receive data buffer pointer
168 uint32 data_len); //receive data buffer length
170 /*****************************************************************************/
171 // Description: stop PCM transmit, and close pcm interface.
172 // Global resource dependence:
173 // Author: Livy.Liu&Thomas.Chai
175 /*****************************************************************************/
176 PUBLIC ERR_PCM_E PCM_Close (void);
180 /*****************************************************************************/
181 // Description: Set a new PCM Paramer to system, if the new paramer is not right,
182 // the setting is unuseful
183 // Global resource dependence:
184 // Author: Thomas.Chai
186 /*****************************************************************************/
187 PUBLIC ERR_PCM_E PCM_SetParamer (PCM_PARA_T *paramer);
189 /*****************************************************************************/
190 // Description: Get Current PCM Paramer in the PCM driver
191 // Global resource dependence:
192 // Author: Thomas.Chai
194 /*****************************************************************************/
195 PUBLIC ERR_PCM_E PCM_GetCurrentParamer (PCM_PARA_T *paramer);
198 /*****************************************************************************/
199 // Description: PCM ISR Entry
200 // Global resource dependence:
201 // Author: Thomas.Chai
203 /*****************************************************************************/
204 PUBLIC void PCM_ISRHandle (uint32 int_num);
212 #endif /*_PCM_DRVAPI_H_*/