PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
Main Page
Modules
Data Structures
Files
File List
Globals
mfs_hl.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3
*
4
* This software is owned and published by:
5
* Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6
*
7
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9
*
10
* This software contains source code for use with Spansion
11
* components. This software is licensed by Spansion to be adapted only
12
* for use in systems utilizing Spansion components. Spansion shall not be
13
* responsible for misuse or illegal use of this software for devices not
14
* supported herein. Spansion is providing this software "AS IS" and will
15
* not be responsible for issues arising from incorrect user implementation
16
* of the software.
17
*
18
* SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23
* WARRANTY OF NONINFRINGEMENT.
24
* SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30
* SAVINGS OR PROFITS,
31
* EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34
* FROM, THE SOFTWARE.
35
*
36
* This software may be replicated in part or whole for the licensed use,
37
* with the restriction that this Disclaimer and Copyright notice must be
38
* included with each copy of this software, whether used in part or whole,
39
* at all times.
40
*/
41
/******************************************************************************/
54
#ifndef __MFS_HL_H__
55
#define __MFS_HL_H__
56
57
/******************************************************************************/
58
/* Include files */
59
/******************************************************************************/
60
#include "
mfs/mfs.h
"
61
62
#if (defined(PDL_PERIPHERAL_MFS_ACTIVE))
63
64
/* C binding of definitions if building with C++ compiler */
65
#ifdef __cplusplus
66
extern
"C"
67
{
68
#endif
69
162
167
typedef
void (*
mfs_hl_tx_cb_func_ptr_t
)(uint16_t);
168
typedef
void (*
mfs_hl_rx_cb_func_ptr_t
)(uint16_t);
169
typedef
uint8_t (*
mfs_hl_i2c_slv_cb_func_prt_t
)(uint8_t);
170
typedef
void (*
mfs_hl_lin_brk_func_ptr_t
)(void);
171
172
/*****************************************************************************/
173
/* Gloval pre-processor symbols/macros ('#define") */
174
/*****************************************************************************/
179
#define MFS_HL_MODE_GROUP_CHK (0xF0u)
180
#define MFS_HL_MODE_GROUP_UART (0x10u)
181
#define MFS_HL_MODE_GROUP_CSIO (0x20u)
182
#define MFS_HL_MODE_GROUP_I2C (0x30u)
183
#define MFS_HL_MODE_GROUP_LIN (0x40u)
184
185
/******************************************************************************
186
* Global type definitions
187
******************************************************************************/
188
193
typedef
enum
en_mfs_hl_fifo_usage
194
{
195
MfsHlUseNoFifo
= 0,
196
MfsHlUseFifo
= 1
197
}
en_mfs_hl_fifo_usage_t
;
198
203
typedef
enum
en_mfs_hl_exec
204
{
205
MfsHlExecStby
= 0,
206
MfsHlExecReceiving
= 1,
207
MfsHlExecTransmitting
= 2,
208
MfsHlExecWaitTxBusIdle
= 3
209
}
en_mfs_hl_exec_t
;
210
215
typedef
enum
en_mfs_hl_mfs_mode
216
{
217
MfsHlModeStby
= 0x00,
218
MfsHlModeUartNormal
= 0x10,
219
MfsHlModeUartMulti
= 0x11,
220
MfsHlModeCsioNormalMaster
= 0x20,
221
MfsHlModeCsioNormalMasterTimer
= 0x21,
222
MfsHlModeCsioNormalSlave
= 0x22,
223
MfsHlModeCsioNormalSlaveTimer
= 0x23,
224
MfsHlModeCsioSpiMaster
= 0x28,
225
MfsHlModeCsioSpiMasterWithCs
= 0x29,
226
MfsHlModeCsioSpiSlave
= 0x2A,
227
MfsHlModeCsioSpiSlaveWithCs
= 0x2B,
228
MfsHlModeI2cMaster
= 0x30,
229
MfsHlModeI2cSlave
= 0x31,
230
MfsHlModeI2cMasterFast
= 0x32,
231
MfsHlModeI2cSlaveFast
= 0x33,
232
MfsHlModeLinMaster
= 0x40,
233
MfsHlModeLinSlave
= 0x41
234
}
en_mfs_hl_mfs_mode_t
;
235
240
typedef
enum
en_mfs_hl_i2c_wait_select
241
{
242
MfsHlI2cWaitAfterAck
= 0,
243
MfsHlI2cWaitAfterDataTxRx
= 1
244
}
en_mfs_hl_i2c_wait_select_t
;
245
250
typedef
enum
en_mfs_hl_i2c_int_state
251
{
252
MfsHlI2cIntStateStby
= 0,
253
MfsHlI2cIntStateEndData
= 1,
254
MfsHlI2cIntStateNack
= 2,
255
MfsHlI2cIntStateStopCond
= 3,
256
MfsHlI2cIntStateErr
= 0xEE
257
}
en_mfs_hl_i2c_int_state_t
;
258
265
typedef
struct
stc_mfs_hl_buffer
266
{
267
uint8_t*
pu8Buffer
;
268
uint16_t
u16BufferSize
;
269
uint16_t
u16InIndex
;
270
uint16_t
u16OutIndex
;
271
uint16_t
u16FillCount
;
272
uint16_t
u16TxCounter
;
273
uint16_t
u16TxCount
;
274
boolean_t
bOverflow
;
275
}
stc_mfs_hl_buffer_t
;
276
283
typedef
struct
stc_mfs_hl_uart_config
284
{
285
uint32_t
u32DataRate
;
286
boolean_t
bBitDirection
;
287
boolean_t
bSignalSystem
;
288
boolean_t
bHwFlow
;
289
uint8_t*
pu8TxBuf
;
290
uint8_t*
pu8RxBuf
;
291
uint16_t
u16TxBufSize
;
292
uint16_t
u16RxBufSize
;
293
uint16_t
u16RxCbBufFillLvl
;
294
uint8_t
u8UartMode
;
295
uint8_t
u8Parity
;
296
uint8_t
u8StopBit
;
297
uint8_t
u8CharLength
;
298
uint8_t
u8FifoUsage
;
299
mfs_hl_rx_cb_func_ptr_t
pfnRxCb
;
300
mfs_hl_tx_cb_func_ptr_t
pfnTxCb
;
301
}
stc_mfs_hl_uart_config_t
;
302
309
typedef
struct
stc_mfs_hl_spi_config
310
{
311
boolean_t
bCsLevel
;
314
uint16_t
u16CsDeSelect
;
315
uint8_t
u8CsSetDelay
;
316
uint8_t
u8CsHoldDelay
;
317
uint8_t
u8CsDivision
;
318
}
stc_mfs_hl_spi_config_t
;
319
326
typedef
struct
stc_mfs_hl_timer_config
327
{
328
boolean_t
bTimerSyncEnable
;
329
uint16_t
u16SerialTimer
;
330
uint8_t
u8TimerDivision
;
331
uint8_t
u8TxByte
;
332
}
stc_mfs_hl_timer_config_t
;
333
340
typedef
struct
stc_mfs_hl_csio_config
341
{
342
uint32_t
u32DataRate
;
343
boolean_t
bBitDirection
;
344
boolean_t
bSignalSystem
;
345
stc_mfs_hl_spi_config_t
*
pstcMfsSpiCsConfig
;
346
stc_mfs_hl_timer_config_t
*
pstcMfsTimerConfig
;
347
uint8_t*
pu8TxBuf
;
348
uint8_t*
pu8RxBuf
;
349
uint16_t
u16TxBufSize
;
350
uint16_t
u16RxBufSize
;
351
uint16_t
u16RxCbBufFillLvl
;
352
uint8_t
u8CsioMode
;
353
uint8_t
u8CsioActMode
;
354
uint8_t
u8SyncWaitTime
;
355
uint8_t
u8CharLength
;
356
uint8_t
u8FifoUsage
;
357
mfs_hl_rx_cb_func_ptr_t
pfnRxCb
;
358
mfs_hl_tx_cb_func_ptr_t
pfnTxCb
;
359
}
stc_mfs_hl_csio_config_t
;
360
367
typedef
struct
stc_mfs_hl_i2c_config
368
{
369
uint32_t
u32DataRate
;
370
uint8_t
u8I2cMode
;
371
uint8_t
u8SlvAddr
;
372
uint8_t
u8FastMode
;
373
uint8_t
u8FifoUsage
;
374
mfs_hl_rx_cb_func_ptr_t
pfnRxCb
;
375
mfs_hl_tx_cb_func_ptr_t
pfnTxCb
;
376
mfs_hl_i2c_slv_cb_func_prt_t
pfnI2cSlvStCb
;
377
}
stc_mfs_hl_i2c_config_t
;
378
388
typedef
struct
stc_mfs_hl_lin_config
389
{
390
uint32_t
u32DataRate
;
391
boolean_t
bExtWakeUp
;
392
boolean_t
bLinBreakIrqEnable
;
393
uint8_t*
pu8TxBuf
;
394
uint8_t*
pu8RxBuf
;
395
uint16_t
u16TxBufSize
;
396
uint16_t
u16RxBufSize
;
397
uint8_t
u8LinMode
;
398
uint8_t
u8StopBits
;
399
uint8_t
u8BreakLength
;
400
uint8_t
u8DelimiterLength
;
401
uint8_t
u8FifoUsage
;
402
mfs_hl_rx_cb_func_ptr_t
pfnRxCb
;
403
mfs_hl_tx_cb_func_ptr_t
pfnTxCb
;
404
mfs_hl_lin_brk_func_ptr_t
pfnLinBrkCb
;
405
}
stc_mfs_hl_lin_config_t
;
406
413
typedef
enum
en_mfs_hl_buffer
414
{
415
MfsHlRxBuffer
= 0u,
416
MfsHlTxBuffer
= 1u,
417
418
}
en_mfs_hl_buffer_t
;
419
420
/******************************************************************************/
421
/* Local type definitions ('typedef') */
422
/******************************************************************************/
424
typedef
struct
stc_mfs_hl_intern_data
425
{
426
mfs_hl_tx_cb_func_ptr_t
pfnTransmitCbFunction
;
427
mfs_hl_rx_cb_func_ptr_t
pfnReceiveCbFunction
;
428
mfs_hl_i2c_slv_cb_func_prt_t
pfnI2cSlvStCbFunction
;
429
mfs_hl_lin_brk_func_ptr_t
pfnLinBreakCbFunction
;
430
stc_mfs_hl_buffer_t
stcRxBuffer
;
431
stc_mfs_hl_buffer_t
stcTxBuffer
;
432
uint32_t
u32I2cProcCnt
;
433
uint16_t
u16RxCallbackBufFillLevel
;
434
uint8_t
u8FifoUsage
;
435
uint8_t
u8MfsMode
;
436
uint8_t
u8Exec
;
437
uint8_t
u8DataWidth
;
438
}
stc_mfs_hl_intern_data_t
;
439
441
typedef
struct
stc_mfs_hl_instance_data
442
{
443
volatile
stc_mfsn_t
*
pstcInstance
;
444
stc_mfs_hl_intern_data_t
stcInternData
;
445
}
stc_mfs_hl_instance_data_t
;
446
447
/******************************************************************************/
448
/* Global variable definitions ('extern') */
449
/******************************************************************************/
450
451
/******************************************************************************/
452
/* Global function prototypes (definition in C source) */
453
/******************************************************************************/
454
/* for UART */
455
/* Init/Deinit */
456
extern
en_result_t
Mfs_Hl_Uart_Init
(
volatile
stc_mfsn_t
* pstcUart,
457
stc_mfs_hl_uart_config_t
* pstcConfig
458
);
459
460
extern
en_result_t
Mfs_Hl_Uart_DeInit
(
volatile
stc_mfsn_t
* pstcUart);
461
462
/* for CSIO */
463
/* Init/Deinit */
464
extern
en_result_t
Mfs_Hl_Csio_Init
(
volatile
stc_mfsn_t
* pstcCsio,
465
stc_mfs_hl_csio_config_t
* pstcConfig
466
);
467
468
extern
en_result_t
Mfs_Hl_Csio_DeInit
(
volatile
stc_mfsn_t
* pstcCsio);
469
470
/* Data Transfer */
471
extern
en_result_t
Mfs_Hl_Csio_SynchronousTrans
(
volatile
stc_mfsn_t
* pstcCsio,
472
const
uint8_t* pu8TxData,
473
uint8_t* pu8RxData,
474
uint16_t u16TransferSize,
475
boolean_t
bCsHolding
476
);
477
478
/* for LIN */
479
/* Init/Deinit */
480
extern
en_result_t
Mfs_Hl_Lin_Init
(
volatile
stc_mfsn_t
* pstcLin,
481
stc_mfs_hl_lin_config_t
* pstcConfig
482
);
483
484
extern
en_result_t
Mfs_Hl_Lin_DeInit
(
volatile
stc_mfsn_t
* pstcLin);
485
486
/* Set configuration */
487
extern
en_result_t
Mfs_Hl_Lin_SetBreak
(
volatile
stc_mfsn_t
* pstcLin);
488
489
extern
en_result_t
Mfs_Hl_Lin_SetNewBaudDivisor
(
volatile
stc_mfsn_t
* pstcLin,
490
uint16_t u16BaudDivisor
491
);
492
493
extern
en_result_t
Mfs_Hl_Lin_DisableRxInterrupt
(
volatile
stc_mfsn_t
* pstcLin);
494
495
/* Data Transfer */
496
extern
en_result_t
Mfs_Hl_Lin_TransferRxBuffer
(
volatile
stc_mfsn_t
* pstcLin,
497
uint8_t* pu8Data,
498
uint16_t u16ReadCount
499
);
500
501
/* for I2C */
502
/* Init/Deinit */
503
extern
en_result_t
Mfs_Hl_I2c_Init
(
volatile
stc_mfsn_t
* pstcI2c,
504
stc_mfs_hl_i2c_config_t
* pstcConfig
505
);
506
507
extern
en_result_t
Mfs_Hl_I2c_DeInit
(
volatile
stc_mfsn_t
* pstcI2c);
508
509
/* Data Transfer */
510
extern
en_result_t
Mfs_Hl_I2c_Write
(
volatile
stc_mfsn_t
* pstcI2c,
511
uint8_t u8SlaveAddr,
512
uint8_t* pu8Data,
513
uint16_t* pu16WriteCnt,
514
boolean_t
bBlocking
515
);
516
517
extern
en_result_t
Mfs_Hl_I2c_Read
(
volatile
stc_mfsn_t
* pstcI2c,
518
uint8_t u8SlaveAddr,
519
uint8_t* pu8Data,
520
uint16_t* pu16ReadCnt,
521
boolean_t
bBlocking
522
);
523
524
extern
en_result_t
Mfs_Hl_I2c_WaitTxComplete
(
volatile
stc_mfsn_t
* pstcI2c,
525
uint32_t u32MaxCnt
526
);
527
528
extern
en_result_t
Mfs_Hl_I2c_WaitRxComplete
(
volatile
stc_mfsn_t
* pstcI2c,
529
uint32_t u32MaxCnt
530
);
531
532
/* for Common(UART/CSIO/LIN) */
533
/* Data Transfer */
534
extern
en_result_t
Mfs_Hl_Read
(
volatile
stc_mfsn_t
* pstcMfs,
535
uint8_t* pu8Data,
536
uint16_t* pu16DataCnt,
537
uint16_t u16ReadCnt,
538
boolean_t
bBlocking
539
);
540
541
extern
en_result_t
Mfs_Hl_Write
(
volatile
stc_mfsn_t
* pstcMfs,
542
uint8_t* pu8Data,
543
uint16_t u16WriteCnt,
544
boolean_t
bBlocking,
545
boolean_t
bCsHolding
546
);
547
/* Get the RX/TX buffer pointer */
548
extern
en_result_t
Mfs_Hl_GetBufferPointer
(
volatile
stc_mfsn_t
* pstcMfs,
549
en_mfs_hl_buffer_t
enBufIndex,
550
stc_mfs_hl_buffer_t
** ppstcBuffer);
551
553
554
#ifdef __cplusplus
555
}
556
#endif
557
558
#endif
/* #if (defined(PDL_PERIPHERAL_MFS_ACTIVE)) */
559
560
#endif
/* __MFS_H__ */
561
/******************************************************************************/
562
/* EOF (not truncated) */
563
/******************************************************************************/
PDL_1_2
library
highlevel
mfs
mfs_hl.h
Generated on Wed May 28 2014 09:28:11 for PDL for FM4 by
1.8.3.1