PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
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 
194 {
198 
203 typedef enum en_mfs_hl_exec
204 {
210 
215 typedef enum en_mfs_hl_mfs_mode
216 {
217  MfsHlModeStby = 0x00,
235 
241 {
245 
251 {
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;
276 
284 {
285  uint32_t u32DataRate;
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;
302 
309 typedef struct stc_mfs_hl_spi_config
310 {
314  uint16_t u16CsDeSelect;
315  uint8_t u8CsSetDelay;
316  uint8_t u8CsHoldDelay;
317  uint8_t u8CsDivision;
319 
327 {
329  uint16_t u16SerialTimer;
330  uint8_t u8TimerDivision;
331  uint8_t u8TxByte;
333 
341 {
342  uint32_t u32DataRate;
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;
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;
378 
388 typedef struct stc_mfs_hl_lin_config
389 {
390  uint32_t u32DataRate;
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;
401  uint8_t u8FifoUsage;
406 
413 typedef enum en_mfs_hl_buffer
414 {
417 
419 
420 /******************************************************************************/
421 /* Local type definitions ('typedef') */
422 /******************************************************************************/
425 {
432  uint32_t u32I2cProcCnt;
434  uint8_t u8FifoUsage;
435  uint8_t u8MfsMode;
436  uint8_t u8Exec;
437  uint8_t u8DataWidth;
439 
442 {
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 /******************************************************************************/