Import Mbed OS hard-float snapshot
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_adc.h
|
||||
* @brief This file provides all the functions prototypes for ADC driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/11
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_ADC_H
|
||||
#define __TMPM46B_ADC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
#define IS_ADC_UNIT(param) (((param) == TSB_AD))
|
||||
|
||||
#define ADC_CONVERSION_CLK_10 ((uint32_t)0x00000000)
|
||||
#define ADC_CONVERSION_CLK_20 ((uint32_t)0x00000010)
|
||||
#define ADC_CONVERSION_CLK_30 ((uint32_t)0x00000020)
|
||||
#define ADC_CONVERSION_CLK_40 ((uint32_t)0x00000030)
|
||||
#define ADC_CONVERSION_CLK_80 ((uint32_t)0x00000040)
|
||||
#define ADC_CONVERSION_CLK_160 ((uint32_t)0x00000050)
|
||||
#define ADC_CONVERSION_CLK_320 ((uint32_t)0x00000060)
|
||||
#define IS_ADC_HOLD_TIME(param) (((param) == ADC_CONVERSION_CLK_10) || \
|
||||
((param) == ADC_CONVERSION_CLK_20) || \
|
||||
((param) == ADC_CONVERSION_CLK_30) || \
|
||||
((param) == ADC_CONVERSION_CLK_40) || \
|
||||
((param) == ADC_CONVERSION_CLK_80) || \
|
||||
((param) == ADC_CONVERSION_CLK_160)|| \
|
||||
((param) == ADC_CONVERSION_CLK_320))
|
||||
|
||||
#define ADC_FC_DIVIDE_LEVEL_1 ((uint32_t)0x00000000)
|
||||
#define ADC_FC_DIVIDE_LEVEL_2 ((uint32_t)0x00000001)
|
||||
#define ADC_FC_DIVIDE_LEVEL_4 ((uint32_t)0x00000002)
|
||||
#define ADC_FC_DIVIDE_LEVEL_8 ((uint32_t)0x00000003)
|
||||
#define ADC_FC_DIVIDE_LEVEL_16 ((uint32_t)0x00000004)
|
||||
#define IS_ADC_PRESCALER(param) ((param) <= ADC_FC_DIVIDE_LEVEL_16)
|
||||
|
||||
/* Interrupt generation timing in fixed channel mode */
|
||||
#define ADC_INT_SINGLE ((uint32_t)0x00000000)
|
||||
#define ADC_INT_CONVERSION_2 ((uint32_t)0x00000010)
|
||||
#define ADC_INT_CONVERSION_3 ((uint32_t)0x00000020)
|
||||
#define ADC_INT_CONVERSION_4 ((uint32_t)0x00000030)
|
||||
#define ADC_INT_CONVERSION_5 ((uint32_t)0x00000040)
|
||||
#define ADC_INT_CONVERSION_6 ((uint32_t)0x00000050)
|
||||
#define ADC_INT_CONVERSION_7 ((uint32_t)0x00000060)
|
||||
#define ADC_INT_CONVERSION_8 ((uint32_t)0x00000070)
|
||||
#define IS_ADC_INT_MODE(param) (((param) == ADC_INT_SINGLE) || \
|
||||
((param) == ADC_INT_CONVERSION_2) || \
|
||||
((param) == ADC_INT_CONVERSION_3) || \
|
||||
((param) == ADC_INT_CONVERSION_4) || \
|
||||
((param) == ADC_INT_CONVERSION_5) || \
|
||||
((param) == ADC_INT_CONVERSION_6) || \
|
||||
((param) == ADC_INT_CONVERSION_7) || \
|
||||
((param) == ADC_INT_CONVERSION_8))
|
||||
|
||||
typedef enum {
|
||||
ADC_AN_00 = 0U, /*!< define for Analog Input channel */
|
||||
ADC_AN_01 = 1U,
|
||||
ADC_AN_02 = 2U,
|
||||
ADC_AN_03 = 3U,
|
||||
ADC_AN_04 = 4U,
|
||||
ADC_AN_05 = 5U,
|
||||
ADC_AN_06 = 6U,
|
||||
ADC_AN_07 = 7U,
|
||||
} ADC_AINx;
|
||||
#define IS_ADC_INPUT_CHANNEL(param) ((param) <= ADC_AN_07)
|
||||
#define IS_ADC_SCAN_CHANNEL(start, range) (((start) <= ADC_AN_07) && \
|
||||
((range) >= 1U) && \
|
||||
(((start) + (range)) <= 8U))
|
||||
|
||||
|
||||
typedef enum {
|
||||
ADC_REG_00 = 0U,
|
||||
ADC_REG_01 = 1U,
|
||||
ADC_REG_02 = 2U,
|
||||
ADC_REG_03 = 3U,
|
||||
ADC_REG_04 = 4U,
|
||||
ADC_REG_05 = 5U,
|
||||
ADC_REG_06 = 6U,
|
||||
ADC_REG_07 = 7U,
|
||||
ADC_REG_SP = 8U
|
||||
} ADC_REGx;
|
||||
#define IS_ADC_REG(param) ((param) <= ADC_REG_SP)
|
||||
|
||||
#define ADC_APPLY_VREF_IN_CONVERSION ((uint32_t)0x00000000)
|
||||
#define ADC_APPLY_VREF_AT_ANY_TIME ((uint32_t)0x00000001)
|
||||
#define IS_ADC_VREF_CTRL(param) (((param) == ADC_APPLY_VREF_IN_CONVERSION) || \
|
||||
((param) == ADC_APPLY_VREF_AT_ANY_TIME))
|
||||
|
||||
typedef enum {
|
||||
ADC_CMPCR_0 = 0U,
|
||||
ADC_CMPCR_1 = 1U
|
||||
} ADC_CMPCRx;
|
||||
#define IS_ADC_CMPCRx(param) ((param) <= ADC_CMPCR_1)
|
||||
|
||||
#define ADC_EXTERADTRG ((uint32_t)0x00000000)
|
||||
#define ADC_INTERTRIGGER ((uint32_t)0x00000001)
|
||||
#define IS_ADC_EXTERADTRG(param) (((param) == ADC_EXTERADTRG)|| \
|
||||
((param) == ADC_INTERTRIGGER))
|
||||
|
||||
#define IS_ADC_EXTERADTRG_TOP(param) (((param) == ADC_EXTERADTRG)|| \
|
||||
((param) == ADC_INTERTRIGGER))
|
||||
|
||||
|
||||
typedef enum {
|
||||
ADC_LARGER_THAN_CMP_REG = 0U,
|
||||
ADC_SMALLER_THAN_CMP_REG = 1U
|
||||
} ADC_CmpCondition;
|
||||
#define IS_ADC_CMPCONDITION(param) ((param) <= ADC_SMALLER_THAN_CMP_REG)
|
||||
|
||||
typedef enum {
|
||||
ADC_SEQUENCE_CMP_MODE = 0U,
|
||||
ADC_CUMULATION_CMP_MODE = 1U
|
||||
} ADC_CmpCntMode;
|
||||
#define IS_ADC_CMPMODE(param) ((param) <= ADC_CUMULATION_CMP_MODE)
|
||||
|
||||
typedef enum {
|
||||
ADC_TRG_00 = 0U,
|
||||
ADC_TRG_01 = 1U,
|
||||
ADC_TRG_02 = 2U,
|
||||
ADC_TRG_03 = 3U,
|
||||
ADC_TRG_04 = 4U,
|
||||
ADC_TRG_05 = 5U,
|
||||
ADC_TRG_06 = 6U,
|
||||
ADC_TRG_07 = 7U,
|
||||
ADC_TRG_08 = 8U,
|
||||
ADC_TRG_09 = 9U
|
||||
} ADC_TRGx;
|
||||
#define IS_ADC_TRG(param) ((param) <= ADC_TRG_09)
|
||||
|
||||
/**
|
||||
* @brief ADC Monitor Configuration Structure definition
|
||||
*/
|
||||
typedef struct {
|
||||
ADC_AINx CmpChannel; /*!< Select which ADC channel will be used */
|
||||
uint32_t CmpCnt; /*!< How many times will valid comparisons be counted, range from 1 to 16 */
|
||||
ADC_CmpCondition Condition; /*!< Condition to compare ADC channel with Compare Register */
|
||||
ADC_CmpCntMode CntMode; /*!< Mode to compare ADC channel with Compare Register */
|
||||
uint32_t CmpValue; /*!< Comparison value to be set in Compare Register, max value is 4095 */
|
||||
} ADC_MonitorTypeDef;
|
||||
|
||||
#define IS_ADC_CMPCNT(param) (((param) >= 1U) && ((param) <= 16U))
|
||||
#define IS_ADC_CMPVALUE_12BIT(param) ((param) <= 4095U)
|
||||
|
||||
/**
|
||||
* @brief Union to store ADC state
|
||||
*/
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t NormalBusy:1; /*!< bit0, Normal A/D conversion busy flag (ADBF) */
|
||||
uint32_t NormalComplete:1; /*!< bit1, Normal AD conversion complete flag (EOCF) */
|
||||
uint32_t TopBusy:1; /*!< bit2, Top-priority A/D conversion busy flag (HPADBF) */
|
||||
uint32_t TopComplete:1; /*!< bit3, Top-priority AD conversion complete flag (HPEOCF) */
|
||||
uint32_t Reserved:28; /*!< bit4 to bit 31, reserved */
|
||||
} Bit;
|
||||
} ADC_State;
|
||||
|
||||
/**
|
||||
* @brief Union to store ADC result
|
||||
*/
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t ADResult:12; /*!< bit0 to bit11, store AD result */
|
||||
uint32_t Stored:1; /*!< bit12, AD result has been stored */
|
||||
uint32_t OverRun:1; /*!< bit13, new AD result is stored before the old one is read */
|
||||
uint32_t Reserved:18; /*!< bit14 to bit31, reserved */
|
||||
} Bit;
|
||||
} ADC_Result;
|
||||
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Exported_Types */
|
||||
|
||||
/** @defgroup ADC_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void ADC_SWReset(TSB_AD_TypeDef * ADx);
|
||||
void ADC_SetClk(TSB_AD_TypeDef * ADx, uint32_t Sample_HoldTime, uint32_t Prescaler_Output);
|
||||
void ADC_Start(TSB_AD_TypeDef * ADx);
|
||||
void ADC_SetScanMode(TSB_AD_TypeDef * ADx, FunctionalState NewState);
|
||||
void ADC_SetRepeatMode(TSB_AD_TypeDef * ADx, FunctionalState NewState);
|
||||
void ADC_SetINTMode(TSB_AD_TypeDef * ADx, uint32_t INTMode);
|
||||
void ADC_SetInputChannel(TSB_AD_TypeDef * ADx, ADC_AINx InputChannel);
|
||||
void ADC_SetScanChannel(TSB_AD_TypeDef * ADx, ADC_AINx StartChannel, uint32_t Range);
|
||||
void ADC_SetVrefCut(TSB_AD_TypeDef * ADx, uint32_t VrefCtrl);
|
||||
void ADC_SetIdleMode(TSB_AD_TypeDef * ADx, FunctionalState NewState);
|
||||
void ADC_SetVref(TSB_AD_TypeDef * ADx, FunctionalState NewState);
|
||||
void ADC_SetInputChannelTop(TSB_AD_TypeDef * ADx, ADC_AINx TopInputChannel);
|
||||
void ADC_StartTopConvert(TSB_AD_TypeDef * ADx);
|
||||
void ADC_SetMonitor(TSB_AD_TypeDef * ADx, ADC_CMPCRx ADCMPx, FunctionalState NewState);
|
||||
void ADC_ConfigMonitor(TSB_AD_TypeDef * ADx, ADC_CMPCRx ADCMPx, ADC_MonitorTypeDef * Monitor);
|
||||
void ADC_SetHWTrg(TSB_AD_TypeDef * ADx, uint32_t HWSrc, FunctionalState NewState);
|
||||
void ADC_SetHWTrgTop(TSB_AD_TypeDef * ADx, uint32_t HWSrc, FunctionalState NewState);
|
||||
ADC_State ADC_GetConvertState(TSB_AD_TypeDef * ADx);
|
||||
ADC_Result ADC_GetConvertResult(TSB_AD_TypeDef * ADx, ADC_REGx ADREGx);
|
||||
void ADC_EnableTrigger(void);
|
||||
void ADC_DisableTrigger(void);
|
||||
void ADC_SetTriggerStartup(ADC_TRGx TriggerStartup);
|
||||
void ADC_SetTriggerStartupTop(ADC_TRGx TopTriggerStartup);
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Exported_FunctionPrototypes */
|
||||
/** @} */
|
||||
/* End of group ADC */
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_ADC_H */
|
||||
@@ -0,0 +1,342 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_cg.h
|
||||
* @brief This file provides all the functions prototypes for CG driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/26
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_CG_H
|
||||
#define __TMPM46B_CG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CG_Exported_types
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
CG_DIVIDE_1 = 0U,
|
||||
CG_DIVIDE_2 = 1U,
|
||||
CG_DIVIDE_4 = 2U,
|
||||
CG_DIVIDE_8 = 3U,
|
||||
CG_DIVIDE_16 = 4U,
|
||||
CG_DIVIDE_32 = 5U,
|
||||
CG_DIVIDE_64 = 6U,
|
||||
CG_DIVIDE_128 = 7U,
|
||||
CG_DIVIDE_256 = 8U,
|
||||
CG_DIVIDE_512 = 9U,
|
||||
CG_DIVIDE_UNKNOWN = 10U,
|
||||
CG_DIVIDE_MAX = 11U
|
||||
} CG_DivideLevel;
|
||||
#define IS_CG_GEAR_DIVIDE_LEVEL(param) (((param) == CG_DIVIDE_1) || \
|
||||
((param) == CG_DIVIDE_2) || \
|
||||
((param) == CG_DIVIDE_4) || \
|
||||
((param) == CG_DIVIDE_8) || \
|
||||
((param) == CG_DIVIDE_16))
|
||||
|
||||
#define IS_CG_FC_DIVIDE_LEVEL(param) (((param) == CG_DIVIDE_1) || \
|
||||
((param) == CG_DIVIDE_2) || \
|
||||
((param) == CG_DIVIDE_4) || \
|
||||
((param) == CG_DIVIDE_8) || \
|
||||
((param) == CG_DIVIDE_16)|| \
|
||||
((param) == CG_DIVIDE_32))
|
||||
|
||||
#define IS_CG_DIVIDE_FC_LEVEL(param) (((param) == CG_DIVIDE_1) || \
|
||||
((param) == CG_DIVIDE_2) || \
|
||||
((param) == CG_DIVIDE_4) || \
|
||||
((param) == CG_DIVIDE_8) || \
|
||||
((param) == CG_DIVIDE_16) || \
|
||||
((param) == CG_DIVIDE_32) || \
|
||||
((param) == CG_DIVIDE_64)|| \
|
||||
((param) == CG_DIVIDE_128) || \
|
||||
((param) == CG_DIVIDE_256) || \
|
||||
((param) == CG_DIVIDE_512))
|
||||
|
||||
typedef enum {
|
||||
CG_FOSC_OSC_EXT = 0U,
|
||||
CG_FOSC_OSC_INT = 1U,
|
||||
CG_FOSC_CLKIN_EXT = 2U
|
||||
} CG_FoscSrc;
|
||||
#define IS_CG_FOSC_SRC(param) (((param) == CG_FOSC_OSC_EXT) || \
|
||||
((param) == CG_FOSC_OSC_INT) || \
|
||||
((param) == CG_FOSC_CLKIN_EXT))
|
||||
|
||||
#define IS_CG_FOSC_STATE(param) (((param) == CG_FOSC_OSC_EXT) || \
|
||||
((param) == CG_FOSC_OSC_INT) )
|
||||
|
||||
typedef enum {
|
||||
CG_SCOUT_SRC_FS = 0U,
|
||||
CG_SCOUT_SRC_FSYS_DIVIDE_8 = 1U,
|
||||
CG_SCOUT_SRC_FSYS_DIVIDE_4 = 2U,
|
||||
CG_SCOUT_SRC_FOSC = 3U
|
||||
} CG_SCOUTSrc;
|
||||
#define IS_CG_SCOUT_SRC(param) (((param) == CG_SCOUT_SRC_FS) || \
|
||||
((param) == CG_SCOUT_SRC_FSYS_DIVIDE_8) || \
|
||||
((param) == CG_SCOUT_SRC_FSYS_DIVIDE_4) || \
|
||||
((param) == CG_SCOUT_SRC_FOSC))
|
||||
|
||||
typedef enum {
|
||||
CG_WARM_UP_SRC_OSC_INT_HIGH = 0U,
|
||||
CG_WARM_UP_SRC_OSC_EXT_HIGH = 1U,
|
||||
CG_WARM_UP_SRC_OSC_EXT_LOW = 2U
|
||||
} CG_WarmUpSrc;
|
||||
#define IS_CG_WARM_UP_SRC(param) (((param) == CG_WARM_UP_SRC_OSC_INT_HIGH) || \
|
||||
((param) == CG_WARM_UP_SRC_OSC_EXT_HIGH) || \
|
||||
((param) == CG_WARM_UP_SRC_OSC_EXT_LOW))
|
||||
|
||||
typedef enum {
|
||||
CG_FC_SRC_FOSC = 0U,
|
||||
CG_FC_SRC_FPLL = 1U
|
||||
} CG_FcSrc;
|
||||
#define IS_CG_FC_SRC(param) (((param) == CG_FC_SRC_FOSC) || \
|
||||
((param) == CG_FC_SRC_FPLL))
|
||||
|
||||
#define CG_8M_MUL_4_FPLL (0x00006A0FUL<<1U) /* 4 fold, input 8MHz, output 32MHz */
|
||||
#define CG_8M_MUL_5_FPLL (0x00006A13UL<<1U) /* 5 fold, input 8MHz, output 40MHz */
|
||||
#define CG_8M_MUL_6_FPLL (0x00006917UL<<1U) /* 6 fold, input 8MHz, output 48MHz */
|
||||
#define CG_8M_MUL_8_FPLL (0x0000691FUL<<1U) /* 8 fold, input 8MHz, output 64MHz */
|
||||
#define CG_8M_MUL_10_FPLL (0x00006A26UL<<1U) /* 10 fold, input 8MHz, output 80MHz */
|
||||
#define CG_8M_MUL_12_FPLL (0x0000692EUL<<1U) /* 12 fold, input 8MHz, output 96MHz */
|
||||
#define CG_10M_MUL_4_FPLL (0x00006A0FUL<<1U) /* 4 fold, input 10MHz, output 40MHz */
|
||||
#define CG_10M_MUL_5_FPLL (0x00006A13UL<<1U) /* 5 fold, input 10MHz, output 50MHz */
|
||||
#define CG_10M_MUL_6_FPLL (0x00006917UL<<1U) /* 6 fold, input 10MHz, output 60MHz */
|
||||
#define CG_10M_MUL_8_FPLL (0x0000691FUL<<1U) /* 8 fold, input 10MHz, output 80MHz */
|
||||
#define CG_10M_MUL_10_FPLL (0x00006A26UL<<1U) /* 10 fold, input 10MHz, output 100MHz */
|
||||
#define CG_10M_MUL_12_FPLL (0x0000692EUL<<1U) /* 12 fold, input 10MHz, output 120MHz */
|
||||
#define CG_12M_MUL_4_FPLL (0x00006A0FUL<<1U) /* 4 fold, input 12MHz, output 48MHz */
|
||||
#define CG_12M_MUL_5_FPLL (0x00006A13UL<<1U) /* 5 fold, input 12MHz, output 60MHz */
|
||||
#define CG_12M_MUL_6_FPLL (0x00006917UL<<1U) /* 6 fold, input 12MHz, output 72MHz */
|
||||
#define CG_12M_MUL_8_FPLL (0x0000691FUL<<1U) /* 8 fold, input 12MHz, output 96MHz */
|
||||
#define CG_12M_MUL_10_FPLL (0x00006A26UL<<1U) /* 10 fold, input 12MHz, output 120MHz */
|
||||
#define CG_16M_MUL_4_FPLL (0x00006A0FUL<<1U) /* 4 fold, input 16MHz, output 64MHz */
|
||||
#define CG_16M_MUL_5_FPLL (0x00006A13UL<<1U) /* 5 fold, input 16MHz, output 80MHz */
|
||||
#define IS_CG_FPLL_VALUE(param) (((param) == CG_8M_MUL_4_FPLL) || \
|
||||
((param) == CG_8M_MUL_5_FPLL) || \
|
||||
((param) == CG_8M_MUL_6_FPLL) || \
|
||||
((param) == CG_8M_MUL_8_FPLL) || \
|
||||
((param) == CG_8M_MUL_10_FPLL) || \
|
||||
((param) == CG_8M_MUL_12_FPLL) || \
|
||||
((param) == CG_10M_MUL_4_FPLL) || \
|
||||
((param) == CG_10M_MUL_5_FPLL) || \
|
||||
((param) == CG_10M_MUL_6_FPLL) || \
|
||||
((param) == CG_10M_MUL_8_FPLL) || \
|
||||
((param) == CG_10M_MUL_10_FPLL) || \
|
||||
((param) == CG_10M_MUL_12_FPLL) || \
|
||||
((param) == CG_12M_MUL_4_FPLL) || \
|
||||
((param) == CG_12M_MUL_5_FPLL) || \
|
||||
((param) == CG_12M_MUL_6_FPLL) || \
|
||||
((param) == CG_12M_MUL_8_FPLL) || \
|
||||
((param) == CG_12M_MUL_10_FPLL) || \
|
||||
((param) == CG_16M_MUL_4_FPLL) || \
|
||||
((param) == CG_16M_MUL_5_FPLL))
|
||||
|
||||
typedef enum {
|
||||
CG_STBY_MODE_UNKNOWN = 0U,
|
||||
CG_STBY_MODE_STOP1 = 1U,
|
||||
CG_STBY_MODE_IDLE = 3U,
|
||||
CG_STBY_MODE_STOP2 = 5U,
|
||||
CG_STBY_MODE_MAX = 8U
|
||||
} CG_STBYMode;
|
||||
#define IS_CG_STBY_MODE(param) (((param) == CG_STBY_MODE_STOP1) || \
|
||||
((param) == CG_STBY_MODE_IDLE)|| \
|
||||
((param) == CG_STBY_MODE_STOP2))
|
||||
|
||||
typedef enum {
|
||||
CG_PHIT0_SRC_FGEAR = 0U,
|
||||
CG_PHIT0_SRC_FC = 1U,
|
||||
CG_PHIT0_SRC_MAX = 2U
|
||||
} CG_PhiT0Src;
|
||||
#define IS_CG_PHIT0_SRC(param) (((param) == CG_PHIT0_SRC_FGEAR) || \
|
||||
((param) == CG_PHIT0_SRC_FC))
|
||||
|
||||
typedef enum {
|
||||
CG_INT_SRC_1 = 0U,
|
||||
CG_INT_SRC_2 = 1U,
|
||||
CG_INT_SRC_7 = 2U,
|
||||
CG_INT_SRC_8 = 3U,
|
||||
CG_INT_SRC_D = 4U,
|
||||
CG_INT_SRC_E = 5U,
|
||||
CG_INT_SRC_F = 6U,
|
||||
CG_INT_SRC_RTC = 7U
|
||||
} CG_INTSrc;
|
||||
|
||||
#define IS_CG_INT_SRC(param) (((param) == CG_INT_SRC_1) || \
|
||||
((param) == CG_INT_SRC_2) || \
|
||||
((param) == CG_INT_SRC_7) || \
|
||||
((param) == CG_INT_SRC_8) || \
|
||||
((param) == CG_INT_SRC_D) || \
|
||||
((param) == CG_INT_SRC_E) || \
|
||||
((param) == CG_INT_SRC_F) || \
|
||||
((param) == CG_INT_SRC_RTC))
|
||||
|
||||
typedef enum {
|
||||
CG_INT_ACTIVE_STATE_L = 0x00U,
|
||||
CG_INT_ACTIVE_STATE_H = 0x10U,
|
||||
CG_INT_ACTIVE_STATE_FALLING = 0x20U,
|
||||
CG_INT_ACTIVE_STATE_RISING = 0x30U,
|
||||
CG_INT_ACTIVE_STATE_BOTH_EDGES = 0x40U,
|
||||
CG_INT_ACTIVE_STATE_INVALID = 0x50U
|
||||
} CG_INTActiveState;
|
||||
#define IS_CG_INT_ACTIVE_STATE(param) (((param) == CG_INT_ACTIVE_STATE_L) || \
|
||||
((param) == CG_INT_ACTIVE_STATE_H) || \
|
||||
((param) == CG_INT_ACTIVE_STATE_FALLING) || \
|
||||
((param) == CG_INT_ACTIVE_STATE_RISING) || \
|
||||
((param) == CG_INT_ACTIVE_STATE_BOTH_EDGES))
|
||||
|
||||
#define IS_CG_INT_RTC_ACTIVE_STATE(param) ((param) == CG_INT_ACTIVE_STATE_FALLING)
|
||||
|
||||
#define CG_FC_PERIPH_PORTA (0x00000001U << 0U)
|
||||
#define CG_FC_PERIPH_PORTB (0x00000001U << 1U)
|
||||
#define CG_FC_PERIPH_PORTC (0x00000001U << 2U)
|
||||
#define CG_FC_PERIPH_PORTD (0x00000001U << 3U)
|
||||
#define CG_FC_PERIPH_PORTE (0x00000001U << 4U)
|
||||
#define CG_FC_PERIPH_PORTF (0x00000001U << 5U)
|
||||
#define CG_FC_PERIPH_PORTG (0x00000001U << 6U)
|
||||
#define CG_FC_PERIPH_PORTH (0x00000001U << 7U)
|
||||
#define CG_FC_PERIPH_PORTJ (0x00000001U << 8U)
|
||||
#define CG_FC_PERIPH_PORTK (0x00000001U << 9U)
|
||||
#define CG_FC_PERIPH_PORTL (0x00000001U << 10U)
|
||||
#define CG_FC_PERIPH_TMRB0 (0x00000001U << 13U)
|
||||
#define CG_FC_PERIPH_TMRB1 (0x00000001U << 14U)
|
||||
#define CG_FC_PERIPH_TMRB2 (0x00000001U << 15U)
|
||||
#define CG_FC_PERIPH_TMRB3 (0x00000001U << 16U)
|
||||
#define CG_FC_PERIPH_TMRB4 (0x00000001U << 17U)
|
||||
#define CG_FC_PERIPH_TMRB5 (0x00000001U << 18U)
|
||||
#define CG_FC_PERIPH_TMRB6 (0x00000001U << 19U)
|
||||
#define CG_FC_PERIPH_TMRB7 (0x00000001U << 20U)
|
||||
#define CG_FC_PERIPH_MPT0 (0x00000001U << 27U)
|
||||
#define CG_FC_PERIPH_MPT1 (0x00000001U << 28U)
|
||||
#define CG_FC_PERIPH_MPT2 (0x00000001U << 29U)
|
||||
#define CG_FC_PERIPH_MPT3 (0x00000001U << 30U)
|
||||
#define CG_FC_PERIPH_TRACE (0x00000001U << 31U)
|
||||
#define CG_FC_PERIPHA_ALL (0xF81FE7FFU)
|
||||
#define IS_CG_FC_PERIPHA(param) ((param) > 0U)
|
||||
|
||||
#define CG_FC_PERIPH_SIO_UART0 (0x00000001U << 0U)
|
||||
#define CG_FC_PERIPH_SIO_UART1 (0x00000001U << 1U)
|
||||
#define CG_FC_PERIPH_SIO_UART2 (0x00000001U << 2U)
|
||||
#define CG_FC_PERIPH_SIO_UART3 (0x00000001U << 3U)
|
||||
#define CG_FC_PERIPH_UART0 (0x00000001U << 10U)
|
||||
#define CG_FC_PERIPH_UART1 (0x00000001U << 11U)
|
||||
#define CG_FC_PERIPH_I2C0 (0x00000001U << 12U)
|
||||
#define CG_FC_PERIPH_I2C1 (0x00000001U << 13U)
|
||||
#define CG_FC_PERIPH_I2C2 (0x00000001U << 14U)
|
||||
#define CG_FC_PERIPH_SSP0 (0x00000001U << 17U)
|
||||
#define CG_FC_PERIPH_SSP1 (0x00000001U << 18U)
|
||||
#define CG_FC_PERIPH_SSP2 (0x00000001U << 19U)
|
||||
#define CG_FC_PERIPH_EBIF (0x00000001U << 20U)
|
||||
#define CG_FC_PERIPH_DMACA (0x00000001U << 21U)
|
||||
#define CG_FC_PERIPH_DMACB (0x00000001U << 22U)
|
||||
#define CG_FC_PERIPH_DMACC (0x00000001U << 23U)
|
||||
#define CG_FC_PERIPH_DMAIF (0x00000001U << 24U)
|
||||
#define CG_FC_PERIPH_ADC (0x00000001U << 25U)
|
||||
#define CG_FC_PERIPH_WDT (0x00000001U << 26U)
|
||||
#define CG_FC_PERIPH_MLA (0x00000001U << 28U)
|
||||
#define CG_FC_PERIPH_ESG (0x00000001U << 29U)
|
||||
#define CG_FC_PERIPH_SHA (0x00000001U << 30U)
|
||||
#define CG_FC_PERIPH_AES (0x00000001U << 31U)
|
||||
#define CG_FC_PERIPHB_ALL (0xF7FE7C0FU)
|
||||
#define IS_CG_FC_PERIPHB(param) (((param) > 0U) && ((param) <= CG_FC_PERIPHB_ALL))
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t WDT:1;
|
||||
uint32_t Reserved0:1;
|
||||
uint32_t DetectLowVoltage:1;
|
||||
uint32_t Reserved1:29;
|
||||
} Bit;
|
||||
} CG_NMIFactor;
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t PinReset:1;
|
||||
uint32_t OSCFLF:1;
|
||||
uint32_t WDTReset:1;
|
||||
uint32_t STOP2Reset:1;
|
||||
uint32_t DebugReset:1;
|
||||
uint32_t Reserved0:1;
|
||||
uint32_t LVDReset:1;
|
||||
uint32_t Reserved1:25;
|
||||
} Bit;
|
||||
} CG_ResetFlag;
|
||||
|
||||
/** @} */
|
||||
/* End of group CG_Exported_types */
|
||||
|
||||
/** @defgroup CG_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
void CG_SetFgearLevel(CG_DivideLevel DivideFgearFromFc);
|
||||
CG_DivideLevel CG_GetFgearLevel(void);
|
||||
void CG_SetPhiT0Src(CG_PhiT0Src PhiT0Src);
|
||||
CG_PhiT0Src CG_GetPhiT0Src(void);
|
||||
Result CG_SetPhiT0Level(CG_DivideLevel DividePhiT0FromFc);
|
||||
CG_DivideLevel CG_GetPhiT0Level(void);
|
||||
void CG_SetSCOUTSrc(CG_SCOUTSrc Source);
|
||||
CG_SCOUTSrc CG_GetSCOUTSrc(void);
|
||||
void CG_SetWarmUpTime(CG_WarmUpSrc Source, uint16_t Time);
|
||||
void CG_StartWarmUp(void);
|
||||
WorkState CG_GetWarmUpState(void);
|
||||
Result CG_SetFPLLValue(uint32_t NewValue);
|
||||
uint32_t CG_GetFPLLValue(void);
|
||||
Result CG_SetPLL(FunctionalState NewState);
|
||||
FunctionalState CG_GetPLLState(void);
|
||||
Result CG_SetFosc(CG_FoscSrc Source, FunctionalState NewState);
|
||||
void CG_SetFoscSrc(CG_FoscSrc Source);
|
||||
CG_FoscSrc CG_GetFoscSrc(void);
|
||||
FunctionalState CG_GetFoscState(CG_FoscSrc Source);
|
||||
void CG_SetSTBYMode(CG_STBYMode Mode);
|
||||
CG_STBYMode CG_GetSTBYMode(void);
|
||||
void CG_SetPortKeepInStop2Mode(FunctionalState NewState);
|
||||
FunctionalState CG_GetPortKeepInStop2Mode(void);
|
||||
Result CG_SetFcSrc(CG_FcSrc Source);
|
||||
CG_FcSrc CG_GetFcSrc(void);
|
||||
void CG_SetProtectCtrl(FunctionalState NewState);
|
||||
void CG_SetSTBYReleaseINTSrc(CG_INTSrc INTSource,
|
||||
CG_INTActiveState ActiveState, FunctionalState NewState);
|
||||
CG_INTActiveState CG_GetSTBYReleaseINTState(CG_INTSrc INTSource);
|
||||
void CG_ClearINTReq(CG_INTSrc INTSource);
|
||||
CG_NMIFactor CG_GetNMIFlag(void);
|
||||
FunctionalState CG_GetIOSCFlashFlag(void);
|
||||
CG_ResetFlag CG_GetResetFlag(void);
|
||||
void CG_SetADCClkSupply(FunctionalState NewState);
|
||||
void CG_SetFcPeriphA(uint32_t Periph, FunctionalState NewState);
|
||||
void CG_SetFcPeriphB(uint32_t Periph, FunctionalState NewState);
|
||||
void CG_SetFs(FunctionalState NewState);
|
||||
|
||||
/** @} */
|
||||
/* End of group CG_Exported_FunctionPrototype */
|
||||
|
||||
/** @} */
|
||||
/* End of group CG */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_CG_H */
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_esg.h
|
||||
* @brief This file provides all the functions prototypes for ESG driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/04
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_ESG_H
|
||||
#define __TMPM46B_ESG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ESG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ESG_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of ESG_Exported_Constants */
|
||||
|
||||
/** @defgroup ESG_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
ESG_CALCULATION_COMPLETE = 0U,
|
||||
ESG_CALCULATION_PROCESS = 1U
|
||||
} ESG_CalculationStatus;
|
||||
|
||||
typedef enum {
|
||||
ESG_LATCH_TIMING_1 = 0U,
|
||||
ESG_LATCH_TIMING_2 = 1U,
|
||||
ESG_LATCH_TIMING_3 = 2U,
|
||||
ESG_LATCH_TIMING_4 = 3U,
|
||||
ESG_LATCH_TIMING_5 = 4U,
|
||||
ESG_LATCH_TIMING_6 = 5U,
|
||||
ESG_LATCH_TIMING_7 = 6U,
|
||||
ESG_LATCH_TIMING_8 = 7U,
|
||||
ESG_LATCH_TIMING_9 = 8U,
|
||||
ESG_LATCH_TIMING_10 = 9U,
|
||||
ESG_LATCH_TIMING_11 = 10U,
|
||||
ESG_LATCH_TIMING_12 = 11U,
|
||||
ESG_LATCH_TIMING_13 = 12U,
|
||||
ESG_LATCH_TIMING_14 = 13U,
|
||||
ESG_LATCH_TIMING_15 = 14U,
|
||||
ESG_LATCH_TIMING_16 = 15U
|
||||
} ESG_LatchTiming;
|
||||
#define IS_ESG_LATCH_TIMING(param) ((param) <= ESG_LATCH_TIMING_16)
|
||||
|
||||
/** @} */
|
||||
/* End of ESG_Exported_types */
|
||||
|
||||
/** @addtogroup ESG_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ESG Init Structure definition
|
||||
*/
|
||||
/** @} */
|
||||
/* End of group ESG_Exported_Types */
|
||||
|
||||
/** @defgroup ESG_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
Result ESG_Startup(void);
|
||||
Result ESG_SetLatchTiming(ESG_LatchTiming Value);
|
||||
uint32_t ESG_GetLatchTiming(void);
|
||||
Result ESG_SetFintiming(uint16_t Fintming);
|
||||
uint16_t ESG_GetFintiming(void);
|
||||
Result ESG_ClrInt(void);
|
||||
FunctionalState ESG_GetIntStatus(void);
|
||||
void ESG_IPReset(void);
|
||||
ESG_CalculationStatus ESG_GetCalculationStatus(void);
|
||||
void ESG_GetResult(uint32_t Seed[16U]);
|
||||
|
||||
/** @} */
|
||||
/* End of ESG_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __TMPM46B_ESG_H */
|
||||
@@ -0,0 +1,256 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_fc.h
|
||||
* @brief This file provides all the functions prototypes for FC driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/27
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_FC_H
|
||||
#define __TMPM46B_FC_H
|
||||
|
||||
|
||||
/* #define SINGLE_BOOT_MODE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup FC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FC_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
FC_SUCCESS = 0U,
|
||||
FC_ERROR_PROTECTED = 1U,
|
||||
FC_ERROR_OVER_TIME = 2U
|
||||
} FC_Result;
|
||||
|
||||
/** @} */
|
||||
/* End of group FC_Exported_Types */
|
||||
|
||||
/** @defgroup FC_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FLASH_PAGE_SIZE ((uint32_t)0x00001000) /* Page Size 4096 Bytes/1024 words */
|
||||
#define PROGRAM_UNIT 4U /* Page program could be written 16 bytes/4 words once */
|
||||
|
||||
#define FC_PAGE_0 ((uint8_t)0x00)
|
||||
#define FC_PAGE_1 ((uint8_t)0x01)
|
||||
#define FC_PAGE_2 ((uint8_t)0x02)
|
||||
#define FC_PAGE_3 ((uint8_t)0x03)
|
||||
#define FC_PAGE_4 ((uint8_t)0x04)
|
||||
#define FC_PAGE_5 ((uint8_t)0x05)
|
||||
#define FC_PAGE_6 ((uint8_t)0x06)
|
||||
#define FC_PAGE_7 ((uint8_t)0x07)
|
||||
|
||||
#define FC_PAGE_MAX FC_PAGE_7
|
||||
#define IS_FC_PAGE_NUM(param) ((param) <= FC_PAGE_MAX)
|
||||
|
||||
#define FC_BLOCK_0 ((uint8_t)0x00)
|
||||
#define FC_BLOCK_1 ((uint8_t)0x01)
|
||||
#define FC_BLOCK_2 ((uint8_t)0x02)
|
||||
#define FC_BLOCK_3 ((uint8_t)0x03)
|
||||
#define FC_BLOCK_4 ((uint8_t)0x04)
|
||||
#define FC_BLOCK_5 ((uint8_t)0x05)
|
||||
#define FC_BLOCK_6 ((uint8_t)0x06)
|
||||
#define FC_BLOCK_7 ((uint8_t)0x07)
|
||||
#define FC_BLOCK_8 ((uint8_t)0x08)
|
||||
#define FC_BLOCK_9 ((uint8_t)0x09)
|
||||
#define FC_BLOCK_10 ((uint8_t)0x0A)
|
||||
#define FC_BLOCK_11 ((uint8_t)0x0B)
|
||||
#define FC_BLOCK_12 ((uint8_t)0x0C)
|
||||
#define FC_BLOCK_13 ((uint8_t)0x0D)
|
||||
#define FC_BLOCK_14 ((uint8_t)0x0E)
|
||||
#define FC_BLOCK_15 ((uint8_t)0x0F)
|
||||
#define FC_BLOCK_16 ((uint8_t)0x10)
|
||||
#define FC_BLOCK_17 ((uint8_t)0x11)
|
||||
#define FC_BLOCK_18 ((uint8_t)0x12)
|
||||
#define FC_BLOCK_19 ((uint8_t)0x13)
|
||||
#define FC_BLOCK_20 ((uint8_t)0x14)
|
||||
#define FC_BLOCK_21 ((uint8_t)0x15)
|
||||
#define FC_BLOCK_22 ((uint8_t)0x16)
|
||||
#define FC_BLOCK_23 ((uint8_t)0x17)
|
||||
#define FC_BLOCK_24 ((uint8_t)0x18)
|
||||
#define FC_BLOCK_25 ((uint8_t)0x19)
|
||||
#define FC_BLOCK_26 ((uint8_t)0x1A)
|
||||
#define FC_BLOCK_27 ((uint8_t)0x1B)
|
||||
#define FC_BLOCK_28 ((uint8_t)0x1C)
|
||||
#define FC_BLOCK_29 ((uint8_t)0x1D)
|
||||
#define FC_BLOCK_30 ((uint8_t)0x1E)
|
||||
#define FC_BLOCK_31 ((uint8_t)0x1F)
|
||||
|
||||
#define FLASH_CHIP_SIZE ((uint32_t)0x00100000) /* Flash chip size is 1024KByte */
|
||||
#define FC_BLOCK_MAX FC_BLOCK_31
|
||||
|
||||
#define IS_FC_BLOCK_NUM(param) (((param) <= FC_BLOCK_MAX) && ((param) >= FC_BLOCK_1))
|
||||
|
||||
#define FC_AREA_ALL ((uint8_t)0x00)
|
||||
#define FC_AREA_0 ((uint8_t)0x01)
|
||||
#define FC_AREA_1 ((uint8_t)0x02)
|
||||
|
||||
#define IS_FC_AREA(param) ((param) <= FC_AREA_1)
|
||||
|
||||
#define FC_SWAP_SIZE_4K ((uint32_t)0x00000000)
|
||||
#define FC_SWAP_SIZE_8K ((uint32_t)0x00000001)
|
||||
#define FC_SWAP_SIZE_16K ((uint32_t)0x00000002)
|
||||
#define FC_SWAP_SIZE_32K ((uint32_t)0x00000003)
|
||||
#define FC_SWAP_SIZE_512K ((uint32_t)0x00000004)
|
||||
|
||||
#define FC_SWAP_INITIAL ((uint32_t)0x00000000)
|
||||
#define FC_SWAPPING ((uint32_t)0x00000001)
|
||||
#define FC_SWAP_PROHIBIT ((uint32_t)0x00000002)
|
||||
#define FC_SWAP_RELEASE ((uint32_t)0x00000003)
|
||||
|
||||
#define FC_Clk_Div_1 ((uint8_t) 0x00)
|
||||
#define FC_Clk_Div_2 ((uint8_t) 0x01)
|
||||
#define FC_Clk_Div_3 ((uint8_t) 0x02)
|
||||
#define FC_Clk_Div_4 ((uint8_t) 0x03)
|
||||
#define FC_Clk_Div_5 ((uint8_t) 0x04)
|
||||
#define FC_Clk_Div_6 ((uint8_t) 0x05)
|
||||
#define FC_Clk_Div_7 ((uint8_t) 0x06)
|
||||
#define FC_Clk_Div_8 ((uint8_t) 0x07)
|
||||
#define FC_Clk_Div_9 ((uint8_t) 0x08)
|
||||
#define FC_Clk_Div_10 ((uint8_t) 0x09)
|
||||
#define FC_Clk_Div_11 ((uint8_t) 0x0A)
|
||||
#define FC_Clk_Div_12 ((uint8_t) 0x0B)
|
||||
#define FC_Clk_Div_13 ((uint8_t) 0x0C)
|
||||
#define FC_Clk_Div_14 ((uint8_t) 0x0D)
|
||||
#define FC_Clk_Div_15 ((uint8_t) 0x0E)
|
||||
#define FC_Clk_Div_16 ((uint8_t) 0x0F)
|
||||
#define FC_Clk_Div_17 ((uint8_t) 0x10)
|
||||
#define FC_Clk_Div_18 ((uint8_t) 0x11)
|
||||
#define FC_Clk_Div_19 ((uint8_t) 0x12)
|
||||
#define FC_Clk_Div_20 ((uint8_t) 0x13)
|
||||
#define FC_Clk_Div_21 ((uint8_t) 0x14)
|
||||
#define FC_Clk_Div_22 ((uint8_t) 0x15)
|
||||
#define FC_Clk_Div_23 ((uint8_t) 0x16)
|
||||
#define FC_Clk_Div_24 ((uint8_t) 0x17)
|
||||
#define FC_Clk_Div_25 ((uint8_t) 0x18)
|
||||
#define FC_Clk_Div_26 ((uint8_t) 0x19)
|
||||
#define FC_Clk_Div_27 ((uint8_t) 0x1A)
|
||||
#define FC_Clk_Div_28 ((uint8_t) 0x1B)
|
||||
#define FC_Clk_Div_29 ((uint8_t) 0x1C)
|
||||
#define FC_Clk_Div_30 ((uint8_t) 0x1D)
|
||||
#define FC_Clk_Div_31 ((uint8_t) 0x1E)
|
||||
#define FC_Clk_Div_32 ((uint8_t) 0x1F)
|
||||
#define IS_FC_WCLK_DIV(param) ((param) <= FC_Clk_Div_32)
|
||||
|
||||
#define FC_PROG_CNT_250 ((uint8_t) 0x00)
|
||||
#define FC_PROG_CNT_300 ((uint8_t) 0x01)
|
||||
#define FC_PROG_CNT_350 ((uint8_t) 0x02)
|
||||
#define IS_FC_PROG_CNT(param) ((param) <= (FC_PROG_CNT_350))
|
||||
|
||||
#define FC_ERAS_CNT_85 ((uint8_t) 0x00)
|
||||
#define FC_ERAS_CNT_90 ((uint8_t) 0x01)
|
||||
#define FC_ERAS_CNT_95 ((uint8_t) 0x02)
|
||||
#define FC_ERAS_CNT_100 ((uint8_t) 0x03)
|
||||
#define FC_ERAS_CNT_105 ((uint8_t) 0x04)
|
||||
#define FC_ERAS_CNT_110 ((uint8_t) 0x05)
|
||||
#define FC_ERAS_CNT_115 ((uint8_t) 0x06)
|
||||
#define FC_ERAS_CNT_120 ((uint8_t) 0x07)
|
||||
#define FC_ERAS_CNT_125 ((uint8_t) 0x08)
|
||||
#define FC_ERAS_CNT_130 ((uint8_t) 0x09)
|
||||
#define FC_ERAS_CNT_135 ((uint8_t) 0x0A)
|
||||
#define FC_ERAS_CNT_140 ((uint8_t) 0x0B)
|
||||
#define IS_FC_ERASE_CNT(param) ((param) <= FC_ERAS_CNT_140)
|
||||
|
||||
#define FC_SWPSR_BIT_0 ((uint8_t) 0x00)
|
||||
#define FC_SWPSR_BIT_1 ((uint8_t) 0x01)
|
||||
#define FC_SWPSR_BIT_2 ((uint8_t) 0x02)
|
||||
#define FC_SWPSR_BIT_3 ((uint8_t) 0x03)
|
||||
#define FC_SWPSR_BIT_4 ((uint8_t) 0x04)
|
||||
#define FC_SWPSR_BIT_5 ((uint8_t) 0x05)
|
||||
#define FC_SWPSR_BIT_6 ((uint8_t) 0x06)
|
||||
#define FC_SWPSR_BIT_7 ((uint8_t) 0x07)
|
||||
#define FC_SWPSR_BIT_8 ((uint8_t) 0x08)
|
||||
#define FC_SWPSR_BIT_9 ((uint8_t) 0x09)
|
||||
#define FC_SWPSR_BIT_10 ((uint8_t) 0x0A)
|
||||
#define IS_FC_SWPSR_BIT_NUM(param) ((param) <= FC_SWPSR_BIT_10)
|
||||
|
||||
#define FC_BIT_VALUE_0 ((uint32_t)0x00000000)
|
||||
#define FC_BIT_VALUE_1 ((uint32_t)0x00000001)
|
||||
|
||||
#ifdef SINGLE_BOOT_MODE
|
||||
#define FLASH_START_ADDR ((uint32_t)0x5E000000) /* SINGLE_BOOT_MODE */
|
||||
#else
|
||||
#define FLASH_START_ADDR ((uint32_t)0x00000000) /* User Boot Mode As Default */
|
||||
#endif
|
||||
|
||||
#define FLASH_END_ADDR (FLASH_START_ADDR + FLASH_CHIP_SIZE - 1U)
|
||||
|
||||
#ifdef SINGLE_BOOT_MODE
|
||||
#define IS_FC_ADDR(param) (((param) >= FLASH_START_ADDR) && \
|
||||
((param) <= FLASH_END_ADDR))
|
||||
#else
|
||||
#define IS_FC_ADDR(param) ((param) <= FLASH_END_ADDR)
|
||||
#endif
|
||||
|
||||
#define IS_FC_PAGE_ADDR(param) ((((param) > FLASH_START_ADDR) || ((param) == FLASH_START_ADDR)) && \
|
||||
((param) <= (FLASH_END_ADDR - PROGRAM_UNIT)))
|
||||
|
||||
|
||||
/** @} */
|
||||
/* End of group FC_Exported_Constants */
|
||||
|
||||
|
||||
/** @defgroup FC_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void FC_SetSecurityBit(FunctionalState NewState);
|
||||
FunctionalState FC_GetSecurityBit(void);
|
||||
WorkState FC_GetBusyState(void);
|
||||
FunctionalState FC_GetBlockProtectState(uint8_t BlockNum);
|
||||
FunctionalState FC_GetPageProtectState(uint8_t PageNum);
|
||||
FunctionalState FC_GetAbortState(void);
|
||||
uint32_t FC_GetSwapSize(void);
|
||||
uint32_t FC_GetSwapState(void);
|
||||
void FC_SelectArea(uint8_t AreaNum, FunctionalState NewState);
|
||||
void FC_SetAbortion(void);
|
||||
void FC_ClearAbortion(void);
|
||||
void FC_SetClkDiv(uint8_t ClkDiv);
|
||||
void FC_SetProgramCount(uint8_t ProgramCount);
|
||||
void FC_SetEraseCounter(uint8_t EraseCounter);
|
||||
FC_Result FC_ProgramBlockProtectState(uint8_t BlockNum);
|
||||
FC_Result FC_ProgramPageProtectState(uint8_t PageNum);
|
||||
FC_Result FC_EraseProtectState(void);
|
||||
FC_Result FC_WritePage(uint32_t PageAddr, uint32_t * Data);
|
||||
FC_Result FC_EraseBlock(uint32_t BlockAddr);
|
||||
FC_Result FC_EraseArea(uint32_t AreaAddr);
|
||||
FC_Result FC_ErasePage(uint32_t PageAddr);
|
||||
FC_Result FC_EraseChip(void);
|
||||
FC_Result FC_SetSwpsrBit(uint8_t BitNum);
|
||||
uint32_t FC_GetSwpsrBitValue(uint8_t BitNum);
|
||||
|
||||
/** @} */
|
||||
/* End of group FC_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group FC */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_FC_H */
|
||||
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_fuart.h
|
||||
* @brief This file provides all the functions prototypes for Full UART driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/26
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_FUART_H
|
||||
#define __TMPM46B_FUART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup FUART
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FUART_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FUART Init Structure definition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t BaudRate; /*!< This member configures the Full UART communication
|
||||
baud rate. */
|
||||
uint32_t DataBits; /*!< Specifies FUART transfer mode, which could be
|
||||
5-bit mode, 6-bit mode, 7-bit mode or 8-bit mode. */
|
||||
uint32_t StopBits; /*!< Specifies the length of stop bit transmission
|
||||
in Full UART. */
|
||||
uint32_t Parity; /*!< Specifies the parity mode which could be 0 parity,
|
||||
1 parity, odd parity, even parity or no parity. */
|
||||
uint32_t Mode; /*!< Enables or disables Receive, Transmit or
|
||||
both. */
|
||||
uint32_t FlowCtrl; /*!< Specifies the hardware flow control mode, which can be
|
||||
CTS flow control, RTS flow control or none flow control. */
|
||||
} FUART_InitTypeDef;
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Exported_Types */
|
||||
|
||||
/** @defgroup FUART_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
#define FUART0 TSB_UART0
|
||||
#define FUART1 TSB_UART1
|
||||
#define TSB_FUART_TypeDef TSB_UART_TypeDef
|
||||
|
||||
#define IS_FUART_PERIPH(param) (((param) == FUART0) || \
|
||||
((param) == FUART1))
|
||||
|
||||
#define IS_FUART_BAUDRATE(param) (((param) != 0U) && \
|
||||
((param) <= 2950000U))
|
||||
|
||||
#define FUART_DATA_BITS_5 ((uint32_t)0x00000000)
|
||||
#define FUART_DATA_BITS_6 ((uint32_t)0x00000020)
|
||||
#define FUART_DATA_BITS_7 ((uint32_t)0x00000040)
|
||||
#define FUART_DATA_BITS_8 ((uint32_t)0x00000060)
|
||||
|
||||
#define IS_FUART_DATA_BITS(param) (((param) == FUART_DATA_BITS_5) || \
|
||||
((param) == FUART_DATA_BITS_6) || \
|
||||
((param) == FUART_DATA_BITS_7) || \
|
||||
((param) == FUART_DATA_BITS_8))
|
||||
|
||||
#define FUART_STOP_BITS_1 ((uint32_t)0x00000000)
|
||||
#define FUART_STOP_BITS_2 ((uint32_t)0x00000008)
|
||||
#define IS_FUART_STOPBITS(param) (((param) == FUART_STOP_BITS_1) || \
|
||||
((param) == FUART_STOP_BITS_2))
|
||||
|
||||
#define FUART_NO_PARITY ((uint32_t)0x00000000)
|
||||
#define FUART_0_PARITY ((uint32_t)0x00000086)
|
||||
#define FUART_1_PARITY ((uint32_t)0x00000082)
|
||||
#define FUART_EVEN_PARITY ((uint32_t)0x00000006)
|
||||
#define FUART_ODD_PARITY ((uint32_t)0x00000002)
|
||||
#define IS_FUART_PARITY(param) (((param) == FUART_NO_PARITY) || \
|
||||
((param) == FUART_0_PARITY) || \
|
||||
((param) == FUART_1_PARITY) || \
|
||||
((param) == FUART_EVEN_PARITY) || \
|
||||
((param) == FUART_ODD_PARITY))
|
||||
|
||||
#define FUART_ENABLE_RX ((uint32_t)0x00000200)
|
||||
#define FUART_ENABLE_TX ((uint32_t)0x00000100)
|
||||
#define IS_FUART_MODE(param) (((param) == FUART_ENABLE_RX) || \
|
||||
((param) == FUART_ENABLE_TX) || \
|
||||
((param) == (FUART_ENABLE_TX | FUART_ENABLE_RX)))
|
||||
|
||||
#define FUART_NONE_FLOW_CTRL ((uint32_t)0x00000000)
|
||||
#define FUART_CTS_FLOW_CTRL ((uint32_t)0x00008000)
|
||||
#define FUART_RTS_FLOW_CTRL ((uint32_t)0x00004000)
|
||||
#define IS_FUART_FLOW_CTRL(param) (((param) == FUART_NONE_FLOW_CTRL) || \
|
||||
((param) == FUART_CTS_FLOW_CTRL) || \
|
||||
((param) == FUART_RTS_FLOW_CTRL) || \
|
||||
((param) == (FUART_CTS_FLOW_CTRL | FUART_RTS_FLOW_CTRL)))
|
||||
|
||||
#define FUART_IRDA_3_16_BIT_PERIOD_MODE ((uint32_t)0x00000000)
|
||||
#define FUART_IRDA_3_TIMES_IRLPBAUD16_MODE ((uint32_t)0x00000004)
|
||||
#define IS_IRDA_ENCODE_MODE(param) (((param) == FUART_IRDA_3_16_BIT_PERIOD_MODE) || \
|
||||
((param) == FUART_IRDA_3_TIMES_IRLPBAUD16_MODE))
|
||||
|
||||
#define FUART_RX_FIFO_LEVEL_4 ((uint32_t)0x00000000)
|
||||
#define FUART_RX_FIFO_LEVEL_8 ((uint32_t)0x00000008)
|
||||
#define FUART_RX_FIFO_LEVEL_16 ((uint32_t)0x00000010)
|
||||
#define FUART_RX_FIFO_LEVEL_24 ((uint32_t)0x00000018)
|
||||
#define FUART_RX_FIFO_LEVEL_28 ((uint32_t)0x00000020)
|
||||
#define IS_FUART_RX_FIFO_LEVEL(param) (((param) == FUART_RX_FIFO_LEVEL_4) || \
|
||||
((param) == FUART_RX_FIFO_LEVEL_8) || \
|
||||
((param) == FUART_RX_FIFO_LEVEL_16) || \
|
||||
((param) == FUART_RX_FIFO_LEVEL_24) || \
|
||||
((param) == FUART_RX_FIFO_LEVEL_28))
|
||||
|
||||
#define FUART_TX_FIFO_LEVEL_4 ((uint32_t)0x00000000)
|
||||
#define FUART_TX_FIFO_LEVEL_8 ((uint32_t)0x00000001)
|
||||
#define FUART_TX_FIFO_LEVEL_16 ((uint32_t)0x00000002)
|
||||
#define FUART_TX_FIFO_LEVEL_24 ((uint32_t)0x00000003)
|
||||
#define FUART_TX_FIFO_LEVEL_28 ((uint32_t)0x00000004)
|
||||
#define IS_FUART_TX_FIFO_LEVEL(param) (((param) == FUART_TX_FIFO_LEVEL_4) || \
|
||||
((param) == FUART_TX_FIFO_LEVEL_8) || \
|
||||
((param) == FUART_TX_FIFO_LEVEL_16) || \
|
||||
((param) == FUART_TX_FIFO_LEVEL_24) || \
|
||||
((param) == FUART_TX_FIFO_LEVEL_28))
|
||||
|
||||
|
||||
#define FUART_NONE_INT_MASK ((uint32_t)0x00000000)
|
||||
#define FUART_RIN_MODEM_INT_MASK ((uint32_t)0x00000001)
|
||||
#define FUART_CTS_MODEM_INT_MASK ((uint32_t)0x00000002)
|
||||
#define FUART_DCD_MODEM_INT_MASK ((uint32_t)0x00000004)
|
||||
#define FUART_DSR_MODEM_INT_MASK ((uint32_t)0x00000008)
|
||||
#define FUART_RX_FIFO_INT_MASK ((uint32_t)0x00000010)
|
||||
#define FUART_TX_FIFO_INT_MASK ((uint32_t)0x00000020)
|
||||
#define FUART_RX_TIMEOUT_INT_MASK ((uint32_t)0x00000040)
|
||||
#define FUART_FRAMING_ERR_INT_MASK ((uint32_t)0x00000080)
|
||||
#define FUART_PARITY_ERR_INT_MASK ((uint32_t)0x00000100)
|
||||
#define FUART_BREAK_ERR_INT_MASK ((uint32_t)0x00000200)
|
||||
#define FUART_OVERRUN_ERR_INT_MASK ((uint32_t)0x00000400)
|
||||
#define FUART_ALL_INT_MASK ((uint32_t)0x000007FF)
|
||||
|
||||
#define IS_INT_MASK_SRC(param) ((param) <= FUART_ALL_INT_MASK)
|
||||
|
||||
#define IS_FUART_DATA(param) ((param) <= (uint32_t)0x000000FF)
|
||||
|
||||
#define IS_FUART_IRDA_DIVISOR(param) (((param) != (uint32_t)0x00000000) && \
|
||||
((param) <= (uint32_t)0x000000FF))
|
||||
/** @} */
|
||||
/* End of group FUART_Exported_Constants */
|
||||
|
||||
/** @addtogroup FUART_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
FUART_STORAGE_EMPTY = 0U,
|
||||
FUART_STORAGE_NORMAL = 1U,
|
||||
FUART_STORAGE_INVALID = 2U,
|
||||
FUART_STORAGE_FULL = 3U
|
||||
} FUART_StorageStatus;
|
||||
|
||||
typedef enum {
|
||||
FUART_RX = 0U,
|
||||
FUART_TX = 1U
|
||||
} FUART_Direction;
|
||||
|
||||
#define IS_FUART_DIRECTION(param) (((param) == FUART_RX) || \
|
||||
((param) == FUART_TX))
|
||||
|
||||
typedef enum {
|
||||
FUART_NO_ERR = 0U,
|
||||
FUART_OVERRUN = 1U,
|
||||
FUART_PARITY_ERR = 2U,
|
||||
FUART_FRAMING_ERR = 3U,
|
||||
FUART_BREAK_ERR = 4U,
|
||||
FUART_ERRS = 5U
|
||||
} FUART_Err;
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t RIN:1; /* bit 0 */
|
||||
uint32_t CTS:1; /* bit 1 */
|
||||
uint32_t DCD:1; /* bit 2 */
|
||||
uint32_t DSR:1; /* bit 3 */
|
||||
uint32_t RxFIFO:1; /* bit 4 */
|
||||
uint32_t TxFIFO:1; /* bit 5 */
|
||||
uint32_t RxTimeout:1; /* bit 6 */
|
||||
uint32_t FramingErr:1; /* bit 7 */
|
||||
uint32_t ParityErr:1; /* bit 8 */
|
||||
uint32_t BreakErr:1; /* bit 9 */
|
||||
uint32_t OverrunErr:1; /* bit 10 */
|
||||
uint32_t Reserved:21; /* bit 11~31 */
|
||||
} Bit;
|
||||
} FUART_INTStatus;
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t CTS:1; /* bit 0 */
|
||||
uint32_t DSR:1; /* bit 1 */
|
||||
uint32_t DCD:1; /* bit 2 */
|
||||
uint32_t Reserved1:5; /* bit 3~7 */
|
||||
uint32_t RI:1; /* bit 8 */
|
||||
uint32_t Reserved2:1; /* bit 9 */
|
||||
uint32_t DTR:1; /* bit 10 */
|
||||
uint32_t RTS:1; /* bit 11 */
|
||||
uint32_t Reserved3:20; /* bit 12~31 */
|
||||
} Bit;
|
||||
} FUART_AllModemStatus;
|
||||
|
||||
typedef enum {
|
||||
FUART_MODEM_STATUS_1 = 0U,
|
||||
FUART_MODEM_STATUS_0 = 1U
|
||||
} FUART_ModemStatus;
|
||||
|
||||
#define IS_MODEM_STATUS(param) (((param) == FUART_MODEM_STATUS_1) || \
|
||||
((param) == FUART_MODEM_STATUS_0))
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Exported_Types */
|
||||
|
||||
/** @defgroup FUART_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void FUART_Enable(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_Disable(TSB_FUART_TypeDef * FUARTx);
|
||||
uint32_t FUART_GetRxData(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_SetTxData(TSB_FUART_TypeDef * FUARTx, uint32_t Data);
|
||||
FUART_Err FUART_GetErrStatus(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_ClearErrStatus(TSB_FUART_TypeDef * FUARTx);
|
||||
WorkState FUART_GetBusyState(TSB_FUART_TypeDef * FUARTx);
|
||||
FUART_StorageStatus FUART_GetStorageStatus(TSB_FUART_TypeDef * FUARTx,
|
||||
FUART_Direction Direction);
|
||||
void FUART_SetIrDADivisor(TSB_FUART_TypeDef * FUARTx, uint32_t Divisor);
|
||||
void FUART_Init(TSB_FUART_TypeDef * FUARTx, FUART_InitTypeDef * InitStruct);
|
||||
void FUART_EnableFIFO(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_DisableFIFO(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_SetSendBreak(TSB_FUART_TypeDef * FUARTx, FunctionalState NewState);
|
||||
void FUART_SetIrDAEncodeMode(TSB_FUART_TypeDef * FUARTx, uint32_t Mode);
|
||||
Result FUART_EnableIrDA(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_DisableIrDA(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_SetINTFIFOLevel(TSB_FUART_TypeDef * FUARTx, uint32_t RxLevel, uint32_t TxLevel);
|
||||
void FUART_SetINTMask(TSB_FUART_TypeDef * FUARTx, uint32_t IntMaskSrc);
|
||||
FUART_INTStatus FUART_GetINTMask(TSB_FUART_TypeDef * FUARTx);
|
||||
FUART_INTStatus FUART_GetRawINTStatus(TSB_FUART_TypeDef * FUARTx);
|
||||
FUART_INTStatus FUART_GetMaskedINTStatus(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_ClearINT(TSB_FUART_TypeDef * FUARTx, FUART_INTStatus INTStatus);
|
||||
void FUART_SetDMAOnErr(TSB_FUART_TypeDef * FUARTx, FunctionalState NewState);
|
||||
void FUART_SetFIFODMA(TSB_FUART_TypeDef * FUARTx, FUART_Direction Direction,
|
||||
FunctionalState NewState);
|
||||
FUART_AllModemStatus FUART_GetModemStatus(TSB_FUART_TypeDef * FUARTx);
|
||||
void FUART_SetRTSStatus(TSB_FUART_TypeDef * FUARTx, FUART_ModemStatus Status);
|
||||
void FUART_SetDTRStatus(TSB_FUART_TypeDef * FUARTx, FUART_ModemStatus Status);
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_FUART_H */
|
||||
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_gpio.h
|
||||
* @brief This file provides all the functions prototypes for GPIO driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/09
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_GPIO_H
|
||||
#define __TMPM46B_GPIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
/** @addtogroup GPIO
|
||||
* @{
|
||||
*/
|
||||
/** @addtogroup GPIO_Parameter_Definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief :The maximum number of the Function Register
|
||||
* Note for porting:
|
||||
* If function register 6 is the maximum number in
|
||||
* all the GPIO port,then define FRMAX (6U)
|
||||
*/
|
||||
#define FRMAX (6U) /* the max number of Port I/O function register is 6 */
|
||||
|
||||
/** @brief: define for function register
|
||||
* Note for porting:
|
||||
* If the maximum number of the function Register is 6,
|
||||
* then you need to define 6 GPIO_FUNC_REG_x ,
|
||||
* the value should be increased from 0 to 5
|
||||
*/
|
||||
#define GPIO_FUNC_REG_1 ((uint8_t)0x00)
|
||||
#define GPIO_FUNC_REG_2 ((uint8_t)0x01)
|
||||
#define GPIO_FUNC_REG_3 ((uint8_t)0x02)
|
||||
#define GPIO_FUNC_REG_4 ((uint8_t)0x03)
|
||||
#define GPIO_FUNC_REG_5 ((uint8_t)0x04)
|
||||
#define GPIO_FUNC_REG_6 ((uint8_t)0x05)
|
||||
|
||||
/** @brief :The GPIO_Port enum
|
||||
* Note for porting:
|
||||
* the port value order from low to high with '1' step
|
||||
* and begin with "0".
|
||||
*/
|
||||
typedef enum {
|
||||
GPIO_PA = 0U,
|
||||
GPIO_PB = 1U,
|
||||
GPIO_PC = 2U,
|
||||
GPIO_PD = 3U,
|
||||
GPIO_PE = 4U,
|
||||
GPIO_PF = 5U,
|
||||
GPIO_PG = 6U,
|
||||
GPIO_PH = 7U,
|
||||
GPIO_PJ = 8U,
|
||||
GPIO_PK = 9U,
|
||||
GPIO_PL = 10U
|
||||
} GPIO_Port;
|
||||
|
||||
#define IS_GPIO_PORT(param) ((param) <= GPIO_PL) /* parameter checking for port number */
|
||||
|
||||
#define RESER (8U-(FRMAX))
|
||||
|
||||
typedef struct {
|
||||
__IO uint32_t DATA;
|
||||
__IO uint32_t CR;
|
||||
__IO uint32_t FR[FRMAX];
|
||||
uint32_t RESERVED0[RESER];
|
||||
__IO uint32_t OD;
|
||||
__IO uint32_t PUP;
|
||||
__IO uint32_t PDN;
|
||||
uint32_t RESERVED1;
|
||||
__IO uint32_t IE;
|
||||
} TSB_Port_TypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint8_t PinDATA;
|
||||
uint8_t PinCR;
|
||||
uint8_t PinFR[FRMAX];
|
||||
uint8_t PinOD;
|
||||
uint8_t PinPUP;
|
||||
uint8_t PinPDN;
|
||||
uint8_t PinIE;
|
||||
} GPIO_RegTypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint8_t IOMode; /* Set the port input or output mode */
|
||||
uint8_t PullUp; /* Enable or disable Pull-up function */
|
||||
uint8_t OpenDrain; /* Enable or disable open drain function */
|
||||
uint8_t PullDown; /* Enable or disable Pull-down function */
|
||||
} GPIO_InitTypeDef;
|
||||
|
||||
#define GPIO_INPUT_MODE ((uint8_t)0x00)
|
||||
#define GPIO_OUTPUT_MODE ((uint8_t)0x01)
|
||||
#define GPIO_IO_MODE_NONE ((uint8_t)0x02)
|
||||
#define IS_GPIO_IO_MODE_STATE(param) (((param) == GPIO_INPUT_MODE) || \
|
||||
((param) == GPIO_OUTPUT_MODE) || \
|
||||
((param) == GPIO_IO_MODE_NONE))
|
||||
|
||||
#define GPIO_PULLUP_DISABLE ((uint8_t)0x00)
|
||||
#define GPIO_PULLUP_ENABLE ((uint8_t)0x01)
|
||||
#define GPIO_PULLUP_NONE ((uint8_t)0x02)
|
||||
#define IS_GPIO_PULLUP_STATE(param) (((param) == GPIO_PULLUP_ENABLE) || \
|
||||
((param) == GPIO_PULLUP_DISABLE) || \
|
||||
((param) == GPIO_PULLUP_NONE))
|
||||
|
||||
#define GPIO_PULLDOWN_DISABLE ((uint8_t)0x00)
|
||||
#define GPIO_PULLDOWN_ENABLE ((uint8_t)0x01)
|
||||
#define GPIO_PULLDOWN_NONE ((uint8_t)0x02)
|
||||
#define IS_GPIO_PULLDOWN_STATE(param) (((param) == GPIO_PULLDOWN_ENABLE) || \
|
||||
((param) == GPIO_PULLDOWN_DISABLE) || \
|
||||
((param) == GPIO_PULLDOWN_NONE))
|
||||
|
||||
#define GPIO_OPEN_DRAIN_DISABLE ((uint8_t)0x00)
|
||||
#define GPIO_OPEN_DRAIN_ENABLE ((uint8_t)0x01)
|
||||
#define GPIO_OPEN_DRAIN_NONE ((uint8_t)0x02)
|
||||
#define IS_GPIO_OPEN_DRAIN_STATE(param) (((param) == GPIO_OPEN_DRAIN_ENABLE) || \
|
||||
((param) == GPIO_OPEN_DRAIN_DISABLE) || \
|
||||
((param) == GPIO_OPEN_DRAIN_NONE))
|
||||
|
||||
#define GPIO_BIT_VALUE_1 ((uint8_t)0x01)
|
||||
#define GPIO_BIT_VALUE_0 ((uint8_t)0x00)
|
||||
|
||||
#define IS_GPIO_BIT_VALUE(BitValue) (((BitValue) == GPIO_BIT_VALUE_1)|| \
|
||||
((BitValue) == GPIO_BIT_VALUE_0))
|
||||
|
||||
#define GPIO_BIT_0 ((uint8_t)0x01)
|
||||
#define GPIO_BIT_1 ((uint8_t)0x02)
|
||||
#define GPIO_BIT_2 ((uint8_t)0x04)
|
||||
#define GPIO_BIT_3 ((uint8_t)0x08)
|
||||
#define GPIO_BIT_4 ((uint8_t)0x10)
|
||||
#define GPIO_BIT_5 ((uint8_t)0x20)
|
||||
#define GPIO_BIT_6 ((uint8_t)0x40)
|
||||
#define GPIO_BIT_7 ((uint8_t)0x80)
|
||||
#define GPIO_BIT_ALL ((uint8_t)0xFF)
|
||||
|
||||
#define IS_GPIO_WRITE(GPIO_x) (GPIO_SFRs[(GPIO_x)].PinCR)
|
||||
|
||||
#define IS_GPIO_BIT_DATA(GPIO_x,Bit_x) ((((GPIO_SFRs[(GPIO_x)].PinDATA) & (Bit_x))&&\
|
||||
(!((uint8_t)(~(GPIO_SFRs[(GPIO_x)].PinDATA))&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_OUT(GPIO_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinCR &(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinCR)&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_IN(GPIO_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinIE &(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinIE)&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_PUP(GPIO_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinPUP &(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinPUP)&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_PDN(GPIO_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinPDN &(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinPDN)&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_OD(GPIO_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinOD &(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinOD)&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_BIT_FR(GPIO_x,FuncReg_x,Bit_x) (((GPIO_SFRs[(GPIO_x)].PinFR[(FuncReg_x)]&(Bit_x))&&\
|
||||
(!((uint8_t)(~GPIO_SFRs[(GPIO_x)].PinFR[(FuncReg_x)])&(Bit_x)))))
|
||||
|
||||
#define IS_GPIO_FUNCTION_REG(param) ((param) < (FRMAX))
|
||||
|
||||
#define IS_GPIO_BIT(param) (((param) == GPIO_BIT_0)|| \
|
||||
((param) == GPIO_BIT_1)|| \
|
||||
((param) == GPIO_BIT_2)|| \
|
||||
((param) == GPIO_BIT_3)|| \
|
||||
((param) == GPIO_BIT_4)|| \
|
||||
((param) == GPIO_BIT_5)|| \
|
||||
((param) == GPIO_BIT_6)|| \
|
||||
((param) == GPIO_BIT_7))
|
||||
/** @} */
|
||||
/* End of group GPIO_Bit_Define */
|
||||
|
||||
/** @defgroup GPIO_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint8_t GPIO_ReadData(GPIO_Port GPIO_x);
|
||||
uint8_t GPIO_ReadDataBit(GPIO_Port GPIO_x, uint8_t Bit_x);
|
||||
void GPIO_WriteData(GPIO_Port GPIO_x, uint8_t Data);
|
||||
void GPIO_WriteDataBit(GPIO_Port GPIO_x, uint8_t Bit_x, uint8_t BitValue);
|
||||
void GPIO_Init(GPIO_Port GPIO_x, uint8_t Bit_x, GPIO_InitTypeDef * GPIO_InitStruct);
|
||||
void GPIO_SetOutput(GPIO_Port GPIO_x, uint8_t Bit_x);
|
||||
void GPIO_SetInput(GPIO_Port GPIO_x, uint8_t Bit_x);
|
||||
void GPIO_SetInputEnableReg(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState);
|
||||
void GPIO_SetOutputEnableReg(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState);
|
||||
void GPIO_SetPullUp(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState);
|
||||
void GPIO_SetPullDown(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState);
|
||||
void GPIO_SetOpenDrain(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState);
|
||||
void GPIO_EnableFuncReg(GPIO_Port GPIO_x, uint8_t FuncReg_x, uint8_t Bit_x);
|
||||
void GPIO_DisableFuncReg(GPIO_Port GPIO_x, uint8_t FuncReg_x, uint8_t Bit_x);
|
||||
|
||||
/** @} */
|
||||
/* End of group GPIO_Exported_FunctionPrototypes */
|
||||
/** @} */
|
||||
/* End of group GPIO */
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __TMPM46B_GPIO_H */
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_i2c.h
|
||||
* @brief This file provides all the functions prototypes for I2C driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/13
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_I2C_H
|
||||
#define __TMPM46B_I2C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup I2C
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t I2CSelfAddr; /*!< Specify self-address of the I2C channel in I2C mode */
|
||||
uint32_t I2CDataLen; /*!< Specify data length of the I2C channel in I2C mode */
|
||||
FunctionalState I2CACKState; /*!< Enable or disable the generation of ACK clock */
|
||||
uint32_t I2CClkDiv; /*!< Select the division of the prescaler clock for generating the serial clock */
|
||||
uint32_t PrescalerClkDiv; /*!< Select the division of fsys for generating the fprsck */
|
||||
} I2C_InitTypeDef;
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t LastRxBit:1;
|
||||
uint32_t GeneralCall:1;
|
||||
uint32_t SlaveAddrMatch:1;
|
||||
uint32_t ArbitrationLost:1;
|
||||
uint32_t INTReq:1;
|
||||
uint32_t BusState:1;
|
||||
uint32_t TRx:1;
|
||||
uint32_t MasterSlave:1;
|
||||
} Bit;
|
||||
} I2C_State;
|
||||
|
||||
#define I2C_CHANNEL_NUMBER 3U
|
||||
#define IS_I2C_PERIPH(param) (((param) == TSB_I2C0) || \
|
||||
((param) == TSB_I2C1) || \
|
||||
((param) == TSB_I2C2))
|
||||
|
||||
#define I2C_DATA_LEN_8 ((uint32_t)0x00000000)
|
||||
#define I2C_DATA_LEN_1 ((uint32_t)0x00000001)
|
||||
#define I2C_DATA_LEN_2 ((uint32_t)0x00000002)
|
||||
#define I2C_DATA_LEN_3 ((uint32_t)0x00000003)
|
||||
#define I2C_DATA_LEN_4 ((uint32_t)0x00000004)
|
||||
#define I2C_DATA_LEN_5 ((uint32_t)0x00000005)
|
||||
#define I2C_DATA_LEN_6 ((uint32_t)0x00000006)
|
||||
#define I2C_DATA_LEN_7 ((uint32_t)0x00000007)
|
||||
|
||||
#define I2C_SCK_CLK_DIV_20 ((uint32_t)0x00000000)
|
||||
#define I2C_SCK_CLK_DIV_24 ((uint32_t)0x00000001)
|
||||
#define I2C_SCK_CLK_DIV_32 ((uint32_t)0x00000002)
|
||||
#define I2C_SCK_CLK_DIV_48 ((uint32_t)0x00000003)
|
||||
#define I2C_SCK_CLK_DIV_80 ((uint32_t)0x00000004)
|
||||
#define I2C_SCK_CLK_DIV_144 ((uint32_t)0x00000005)
|
||||
#define I2C_SCK_CLK_DIV_272 ((uint32_t)0x00000006)
|
||||
#define I2C_SCK_CLK_DIV_528 ((uint32_t)0x00000007)
|
||||
#define IS_I2C_SCK_CLK_DIV(param) (((param) == I2C_SCK_CLK_DIV_20) || \
|
||||
((param) == I2C_SCK_CLK_DIV_24) || \
|
||||
((param) == I2C_SCK_CLK_DIV_32) || \
|
||||
((param) == I2C_SCK_CLK_DIV_48) || \
|
||||
((param) == I2C_SCK_CLK_DIV_80) || \
|
||||
((param) == I2C_SCK_CLK_DIV_144) || \
|
||||
((param) == I2C_SCK_CLK_DIV_272) || \
|
||||
((param) == I2C_SCK_CLK_DIV_528))
|
||||
|
||||
#define I2C_PRESCALER_DIV_1 ((uint32_t)0x00000001)
|
||||
#define I2C_PRESCALER_DIV_2 ((uint32_t)0x00000002)
|
||||
#define I2C_PRESCALER_DIV_3 ((uint32_t)0x00000003)
|
||||
#define I2C_PRESCALER_DIV_4 ((uint32_t)0x00000004)
|
||||
#define I2C_PRESCALER_DIV_5 ((uint32_t)0x00000005)
|
||||
#define I2C_PRESCALER_DIV_6 ((uint32_t)0x00000006)
|
||||
#define I2C_PRESCALER_DIV_7 ((uint32_t)0x00000007)
|
||||
#define I2C_PRESCALER_DIV_8 ((uint32_t)0x00000008)
|
||||
#define I2C_PRESCALER_DIV_9 ((uint32_t)0x00000009)
|
||||
#define I2C_PRESCALER_DIV_10 ((uint32_t)0x0000000A)
|
||||
#define I2C_PRESCALER_DIV_11 ((uint32_t)0x0000000B)
|
||||
#define I2C_PRESCALER_DIV_12 ((uint32_t)0x0000000C)
|
||||
#define I2C_PRESCALER_DIV_13 ((uint32_t)0x0000000D)
|
||||
#define I2C_PRESCALER_DIV_14 ((uint32_t)0x0000000E)
|
||||
#define I2C_PRESCALER_DIV_15 ((uint32_t)0x0000000F)
|
||||
#define I2C_PRESCALER_DIV_16 ((uint32_t)0x00000010)
|
||||
#define I2C_PRESCALER_DIV_17 ((uint32_t)0x00000011)
|
||||
#define I2C_PRESCALER_DIV_18 ((uint32_t)0x00000012)
|
||||
#define I2C_PRESCALER_DIV_19 ((uint32_t)0x00000013)
|
||||
#define I2C_PRESCALER_DIV_20 ((uint32_t)0x00000014)
|
||||
#define I2C_PRESCALER_DIV_21 ((uint32_t)0x00000015)
|
||||
#define I2C_PRESCALER_DIV_22 ((uint32_t)0x00000016)
|
||||
#define I2C_PRESCALER_DIV_23 ((uint32_t)0x00000017)
|
||||
#define I2C_PRESCALER_DIV_24 ((uint32_t)0x00000018)
|
||||
#define I2C_PRESCALER_DIV_25 ((uint32_t)0x00000019)
|
||||
#define I2C_PRESCALER_DIV_26 ((uint32_t)0x0000001A)
|
||||
#define I2C_PRESCALER_DIV_27 ((uint32_t)0x0000001B)
|
||||
#define I2C_PRESCALER_DIV_28 ((uint32_t)0x0000001C)
|
||||
#define I2C_PRESCALER_DIV_29 ((uint32_t)0x0000001D)
|
||||
#define I2C_PRESCALER_DIV_30 ((uint32_t)0x0000001E)
|
||||
#define I2C_PRESCALER_DIV_31 ((uint32_t)0x0000001F)
|
||||
#define I2C_PRESCALER_DIV_32 ((uint32_t)0x00000020)
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C_Exported_Types */
|
||||
|
||||
/** @defgroup I2C_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_PRESCALER_CLK_VALID(param1, param2) (((param1) >= I2C_PRESCALER_DIV_1) && \
|
||||
((param1) <= I2C_PRESCALER_DIV_32) && \
|
||||
(((param2) / (param1)) > 666666U) && \
|
||||
(((param2) / (param1)) < 20000000U))
|
||||
|
||||
#define IS_I2C_DATA(param) ((param) <= (uint32_t)0x000000FF)
|
||||
|
||||
#define IS_I2C_BIT_NUM(param) ((param) <= (uint32_t)0x00000007)
|
||||
|
||||
#define IS_I2C_ADDR(param) (((param) < (uint32_t)0x000000FF) && \
|
||||
(!((param) & (uint32_t)0x00000001)))
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C_Exported_Macros */
|
||||
|
||||
/** @defgroup I2C_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void I2C_SetACK(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState);
|
||||
void I2C_Init(TSB_I2C_TypeDef * I2Cx, I2C_InitTypeDef * InitI2CStruct);
|
||||
void I2C_SetBitNum(TSB_I2C_TypeDef * I2Cx, uint32_t I2CBitNum);
|
||||
void I2C_SWReset(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_ClearINTReq(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_GenerateStart(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_GenerateStop(TSB_I2C_TypeDef * I2Cx);
|
||||
I2C_State I2C_GetState(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_SetSendData(TSB_I2C_TypeDef * I2Cx, uint32_t Data);
|
||||
uint32_t I2C_GetReceiveData(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_SetFreeDataMode(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState);
|
||||
FunctionalState I2C_GetSlaveAddrMatchState(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_SetPrescalerClock(TSB_I2C_TypeDef * I2Cx, uint32_t PrescalerClock);
|
||||
void I2C_SetINTReq(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState);
|
||||
FunctionalState I2C_GetINTStatus(TSB_I2C_TypeDef * I2Cx);
|
||||
void I2C_ClearINTOutput(TSB_I2C_TypeDef * I2Cx);
|
||||
/** @} */
|
||||
/* End of group I2C_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_I2C_H */
|
||||
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_rtc.h
|
||||
* @brief This file provides all the functions prototypes for RTC driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/11
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_RTC_H
|
||||
#define __TMPM46B_RTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RTC Structure definition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t HourMode; /*!< Select RTC 12-Hour mode or 24-Hour mode */
|
||||
uint8_t Hour; /*!< Set RTC hour value */
|
||||
uint8_t AmPm; /*!< Select AM/PM mode in 12H mode */
|
||||
uint8_t Min; /*!< Set RTC minute value */
|
||||
uint8_t Sec; /*!< Set RTC second value */
|
||||
} RTC_TimeTypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint8_t LeapYear; /*!< Select RTC Leap-Year status */
|
||||
uint8_t Year; /*!< Set RTC year value */
|
||||
uint8_t Month; /*!< Set RTC month value */
|
||||
uint8_t Date; /*!< Set RTC date value */
|
||||
uint8_t Day; /*!< Set RTC day value */
|
||||
} RTC_DateTypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint8_t Date; /*!< Set alarm date value */
|
||||
uint8_t Day; /*!< Set alarm day value */
|
||||
uint8_t Hour; /*!< Set alarm hour value */
|
||||
uint8_t AmPm; /*!< Select AM/PM mode in 12H mode */
|
||||
uint8_t Min; /*!< Set alarm minute value */
|
||||
} RTC_AlarmTypeDef;
|
||||
|
||||
/** @} */
|
||||
/* End of group RTC_Exported_Types */
|
||||
|
||||
/** @defgroup RTC_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define RTC_24_HOUR_MODE ((uint8_t)0x01)
|
||||
#define RTC_12_HOUR_MODE ((uint8_t)0x00)
|
||||
#define IS_RTC_HOUR_MODE(param) (((param) == RTC_24_HOUR_MODE) || \
|
||||
((param) == RTC_12_HOUR_MODE))
|
||||
|
||||
#define RTC_AM_MODE ((uint8_t)0x00)
|
||||
#define RTC_PM_MODE ((uint8_t)0x01)
|
||||
#define RTC_AMPM_INVALID ((uint8_t)0x02)
|
||||
#define IS_RTC_AMPM_MODE(param) (((param) == RTC_AM_MODE) || \
|
||||
((param) == RTC_PM_MODE))
|
||||
|
||||
#define RTC_LEAP_YEAR_0 ((uint8_t)0x00)
|
||||
#define RTC_LEAP_YEAR_1 ((uint8_t)0x01)
|
||||
#define RTC_LEAP_YEAR_2 ((uint8_t)0x02)
|
||||
#define RTC_LEAP_YEAR_3 ((uint8_t)0x03)
|
||||
#define IS_RTC_LEAP_YEAR(param) (((param) == RTC_LEAP_YEAR_0) || \
|
||||
((param) == RTC_LEAP_YEAR_1) || \
|
||||
((param) == RTC_LEAP_YEAR_2) || \
|
||||
((param) == RTC_LEAP_YEAR_3))
|
||||
|
||||
#define RTC_SUN ((uint8_t)0x00)
|
||||
#define RTC_MON ((uint8_t)0x01)
|
||||
#define RTC_TUE ((uint8_t)0x02)
|
||||
#define RTC_WED ((uint8_t)0x03)
|
||||
#define RTC_THU ((uint8_t)0x04)
|
||||
#define RTC_FRI ((uint8_t)0x05)
|
||||
#define RTC_SAT ((uint8_t)0x06)
|
||||
#define IS_RTC_DAY(param) (((param) == RTC_SUN) || \
|
||||
((param) == RTC_MON) || \
|
||||
((param) == RTC_TUE) || \
|
||||
((param) == RTC_WED) || \
|
||||
((param) == RTC_THU) || \
|
||||
((param) == RTC_FRI) || \
|
||||
((param) == RTC_SAT))
|
||||
|
||||
#define RTC_LOW_LEVEL ((uint8_t)0x00)
|
||||
#define RTC_PULSE_1_HZ ((uint8_t)0x01)
|
||||
#define RTC_PULSE_16_HZ ((uint8_t)0x02)
|
||||
#define RTC_PULSE_2_HZ ((uint8_t)0x03)
|
||||
#define RTC_PULSE_4_HZ ((uint8_t)0x04)
|
||||
#define RTC_PULSE_8_HZ ((uint8_t)0x05)
|
||||
#define IS_RTC_ALARM_OUTPUT(param) (((param) == RTC_LOW_LEVEL) || \
|
||||
((param) == RTC_PULSE_1_HZ) || \
|
||||
((param) == RTC_PULSE_16_HZ)|| \
|
||||
((param) == RTC_PULSE_2_HZ) || \
|
||||
((param) == RTC_PULSE_4_HZ) || \
|
||||
((param) == RTC_PULSE_8_HZ))
|
||||
|
||||
#define IS_RTC_YEAR(param) ((param) <= 99U)
|
||||
|
||||
#define IS_RTC_MONTH(param) (((param) >= 1U)&&((param) <= 12U))
|
||||
|
||||
#define IS_RTC_DATE(param) (((param) >= 1U)&&((param) <= 31U))
|
||||
|
||||
#define IS_RTC_HOUR_24(param) ((param) <= 23U)
|
||||
|
||||
#define IS_RTC_HOUR_12(param) ((param) <= 11U)
|
||||
|
||||
#define IS_RTC_MINUTE(param) ((param) <= 59U)
|
||||
|
||||
#define IS_RTC_SECOND(param) ((param) <= 59U)
|
||||
|
||||
#define RTC_ADJ_TIME_1_SEC ((uint8_t)0x00)
|
||||
#define RTC_ADJ_TIME_10_SEC ((uint8_t)0x02)
|
||||
#define RTC_ADJ_TIME_20_SEC ((uint8_t)0x04)
|
||||
#define RTC_ADJ_TIME_30_SEC ((uint8_t)0x06)
|
||||
#define RTC_ADJ_TIME_1_MIN ((uint8_t)0x08)
|
||||
#define IS_RTC_ADJ_TIME(param) (((param) == RTC_ADJ_TIME_1_SEC) || \
|
||||
((param) == RTC_ADJ_TIME_10_SEC) || \
|
||||
((param) == RTC_ADJ_TIME_20_SEC) || \
|
||||
((param) == RTC_ADJ_TIME_30_SEC) || \
|
||||
((param) == RTC_ADJ_TIME_1_MIN))
|
||||
/** @} */
|
||||
/* End of group RTC_Exported_Constants */
|
||||
|
||||
/** @defgroup RTC_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
RTC_NO_REQ = 0U,
|
||||
RTC_REQ = 1U
|
||||
} RTC_ReqState;
|
||||
|
||||
typedef enum {
|
||||
RTC_CLOCK_MODE = 0U,
|
||||
RTC_ALARM_MODE = 1U
|
||||
} RTC_FuncMode;
|
||||
#define IS_RTC_FUNC_MODE(param) (((param) == RTC_CLOCK_MODE) || \
|
||||
((param) == RTC_ALARM_MODE))
|
||||
|
||||
typedef enum {
|
||||
RTC_CORRECTION_PLUS = 0U,
|
||||
RTC_CORRECTION_MINUS = 1U
|
||||
} RTC_CorrectionMode;
|
||||
#define IS_RTC_CORRECTION_MODE(param) (((param) == RTC_CORRECTION_PLUS) || \
|
||||
((param) == RTC_CORRECTION_MINUS))
|
||||
|
||||
#define IS_RTC_PLUS_VALUE(param) ((param) <= 255U)
|
||||
#define IS_RTC_MINUS_VALUE(param) (((param) >= 1U)&&((param) <= 256U))
|
||||
/** @} */
|
||||
/* End of group RTC_Exported_Types */
|
||||
|
||||
/** @defgroup RTC_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void RTC_SetSec(uint8_t Sec);
|
||||
uint8_t RTC_GetSec(void);
|
||||
void RTC_SetMin(RTC_FuncMode NewMode, uint8_t Min);
|
||||
uint8_t RTC_GetMin(RTC_FuncMode NewMode);
|
||||
uint8_t RTC_GetAMPM(RTC_FuncMode NewMode);
|
||||
void RTC_SetHour24(RTC_FuncMode NewMode, uint8_t Hour);
|
||||
void RTC_SetHour12(RTC_FuncMode NewMode, uint8_t Hour, uint8_t AmPm);
|
||||
uint8_t RTC_GetHour(RTC_FuncMode NewMode);
|
||||
void RTC_SetDay(RTC_FuncMode NewMode, uint8_t Day);
|
||||
uint8_t RTC_GetDay(RTC_FuncMode NewMode);
|
||||
void RTC_SetDate(RTC_FuncMode NewMode, uint8_t Date);
|
||||
uint8_t RTC_GetDate(RTC_FuncMode NewMode);
|
||||
void RTC_SetMonth(uint8_t Month);
|
||||
uint8_t RTC_GetMonth(void);
|
||||
void RTC_SetYear(uint8_t Year);
|
||||
uint8_t RTC_GetYear(void);
|
||||
void RTC_SetHourMode(uint8_t HourMode);
|
||||
uint8_t RTC_GetHourMode(void);
|
||||
void RTC_SetLeapYear(uint8_t LeapYear);
|
||||
uint8_t RTC_GetLeapYear(void);
|
||||
void RTC_SetTimeAdjustReq(void);
|
||||
RTC_ReqState RTC_GetTimeAdjustReq(void);
|
||||
void RTC_EnableClock(void);
|
||||
void RTC_DisableClock(void);
|
||||
void RTC_EnableAlarm(void);
|
||||
void RTC_DisableAlarm(void);
|
||||
void RTC_SetRTCINT(FunctionalState NewState);
|
||||
void RTC_SetAlarmOutput(uint8_t Output);
|
||||
void RTC_ResetAlarm(void);
|
||||
void RTC_ResetClockSec(void);
|
||||
RTC_ReqState RTC_GetResetClockSecReq(void);
|
||||
void RTC_SetDateValue(RTC_DateTypeDef * DateStruct);
|
||||
void RTC_GetDateValue(RTC_DateTypeDef * DateStruct);
|
||||
void RTC_SetTimeValue(RTC_TimeTypeDef * TimeStruct);
|
||||
void RTC_GetTimeValue(RTC_TimeTypeDef * TimeStruct);
|
||||
void RTC_SetClockValue(RTC_DateTypeDef * DateStruct, RTC_TimeTypeDef * TimeStruct);
|
||||
void RTC_GetClockValue(RTC_DateTypeDef * DateStruct, RTC_TimeTypeDef * TimeStruct);
|
||||
void RTC_SetAlarmValue(RTC_AlarmTypeDef * AlarmStruct);
|
||||
void RTC_GetAlarmValue(RTC_AlarmTypeDef * AlarmStruct);
|
||||
void RTC_SetProtectCtrl(FunctionalState NewState);
|
||||
void RTC_EnableCorrection(void);
|
||||
void RTC_DisableCorrection(void);
|
||||
void RTC_SetCorrectionTime(uint8_t Time);
|
||||
void RTC_SetCorrectionValue(RTC_CorrectionMode Mode, uint16_t Cnt);
|
||||
|
||||
/** @} */
|
||||
/* End of group RTC_Exported_FunctionPrototype */
|
||||
|
||||
/** @} */
|
||||
/* End of group RTC */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __TMPM46B_RTC_H */
|
||||
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_ssp.h
|
||||
* @brief This file provides all the functions prototypes for SSP driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/05
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_SSP_H
|
||||
#define __TMPM46B_SSP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SSP_Exported_types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IS_SSP_PERIPH(param) (((param) == TSB_SSP0) || \
|
||||
((param) == TSB_SSP1) || \
|
||||
((param) == TSB_SSP2) )
|
||||
|
||||
typedef enum {
|
||||
SSP_FORMAT_SPI = 0U,
|
||||
SSP_FORMAT_SSI = 1U,
|
||||
SSP_FORMAT_MICROWIRE = 2U
|
||||
} SSP_FrameFormat;
|
||||
#define IS_SSP_FRAME_FORMAT(param) (((param) == SSP_FORMAT_SPI) || \
|
||||
((param) == SSP_FORMAT_SSI) || \
|
||||
((param) == SSP_FORMAT_MICROWIRE))
|
||||
|
||||
typedef enum {
|
||||
SSP_POLARITY_LOW = 0U,
|
||||
SSP_POLARITY_HIGH = 1U
|
||||
} SSP_ClkPolarity;
|
||||
#define IS_SSP_CLK_POLARITY(param) (((param) == SSP_POLARITY_LOW) || \
|
||||
((param) == SSP_POLARITY_HIGH))
|
||||
|
||||
typedef enum {
|
||||
SSP_PHASE_FIRST_EDGE = 0U,
|
||||
SSP_PHASE_SECOND_EDGE = 1U
|
||||
} SSP_ClkPhase;
|
||||
#define IS_SSP_CLK_PHASE(param) (((param) == SSP_PHASE_FIRST_EDGE) || \
|
||||
((param) == SSP_PHASE_SECOND_EDGE))
|
||||
|
||||
typedef enum {
|
||||
SSP_MASTER = 0U,
|
||||
SSP_SLAVE = 1U
|
||||
} SSP_MS_Mode;
|
||||
#define IS_SSP_MS_MODE(param) (((param) == SSP_MASTER) || \
|
||||
((param) == SSP_SLAVE))
|
||||
|
||||
typedef enum {
|
||||
SSP_FIFO_EMPTY = 0U,
|
||||
SSP_FIFO_NORMAL = 1U,
|
||||
SSP_FIFO_INVALID = 2U,
|
||||
SSP_FIFO_FULL = 3U
|
||||
} SSP_FIFOState;
|
||||
|
||||
#define IS_SSP_PRE_SCALE(param) (((param)>=2U)&&((param)<=254U)&&(((param)%2U)==0U))
|
||||
#define IS_SSP_DATA_BIT_SIZE(param) (((param)>=4U)&&((param)<=16U))
|
||||
|
||||
typedef enum {
|
||||
SSP_RX = 0U,
|
||||
SSP_TX = 1U
|
||||
} SSP_Direction;
|
||||
#define IS_SSP_DIRECTION(param) (((param) == SSP_RX) || \
|
||||
((param) == SSP_TX))
|
||||
|
||||
typedef struct {
|
||||
SSP_FrameFormat FrameFormat;
|
||||
uint8_t PreScale;
|
||||
uint8_t ClkRate;
|
||||
SSP_ClkPolarity ClkPolarity;
|
||||
SSP_ClkPhase ClkPhase;
|
||||
uint8_t DataSize;
|
||||
SSP_MS_Mode Mode;
|
||||
} SSP_InitTypeDef;
|
||||
|
||||
/* Parameter to configure SSP interrupt enable/disable Register */
|
||||
#define SSP_INTCFG_NONE ((uint32_t)0x00000000)
|
||||
#define SSP_INTCFG_RX_OVERRUN ((uint32_t)0x00000001)
|
||||
#define SSP_INTCFG_RX_TIMEOUT ((uint32_t)0x00000002)
|
||||
#define SSP_INTCFG_RX ((uint32_t)0x00000004)
|
||||
#define SSP_INTCFG_TX ((uint32_t)0x00000008)
|
||||
#define SSP_INTCFG_ALL ((uint32_t)0x0000000F)
|
||||
|
||||
#define IS_SSP_INT_SRC(param) ((param) <= SSP_INTCFG_ALL )
|
||||
|
||||
#define IS_SSP_CLEAR_INT_SRC(param) (((param) == SSP_INTCFG_RX_OVERRUN) || \
|
||||
((param) == SSP_INTCFG_RX_TIMEOUT) || \
|
||||
((param) == SSP_INTCFG_ALL) )
|
||||
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t OverRun:1; /* Bit 0 , for TSB-M4 in IAR EWARM */
|
||||
uint32_t TimeOut:1;
|
||||
uint32_t Rx:1;
|
||||
uint32_t Tx:1;
|
||||
uint32_t Reserved:28; /* Bit 4 to 31 */
|
||||
} Bit;
|
||||
} SSP_INTState;
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP_Exported_types */
|
||||
|
||||
/** @defgroup SSP_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
void SSP_Enable(TSB_SSP_TypeDef * SSPx);
|
||||
void SSP_Disable(TSB_SSP_TypeDef * SSPx);
|
||||
void SSP_Init(TSB_SSP_TypeDef * SSPx, SSP_InitTypeDef * InitStruct);
|
||||
void SSP_SetClkPreScale(TSB_SSP_TypeDef * SSPx, uint8_t PreScale, uint8_t ClkRate);
|
||||
void SSP_SetFrameFormat(TSB_SSP_TypeDef * SSPx, SSP_FrameFormat FrameFormat);
|
||||
void SSP_SetClkPolarity(TSB_SSP_TypeDef * SSPx, SSP_ClkPolarity ClkPolarity);
|
||||
void SSP_SetClkPhase(TSB_SSP_TypeDef * SSPx, SSP_ClkPhase ClkPhase);
|
||||
void SSP_SetDataSize(TSB_SSP_TypeDef * SSPx, uint8_t DataSize);
|
||||
void SSP_SetSlaveOutputCtrl(TSB_SSP_TypeDef * SSPx, FunctionalState NewState);
|
||||
void SSP_SetMSMode(TSB_SSP_TypeDef * SSPx, SSP_MS_Mode Mode);
|
||||
void SSP_SetLoopBackMode(TSB_SSP_TypeDef * SSPx, FunctionalState NewState);
|
||||
void SSP_SetTxData(TSB_SSP_TypeDef * SSPx, uint16_t Data);
|
||||
uint16_t SSP_GetRxData(TSB_SSP_TypeDef * SSPx);
|
||||
WorkState SSP_GetWorkState(TSB_SSP_TypeDef * SSPx);
|
||||
SSP_FIFOState SSP_GetFIFOState(TSB_SSP_TypeDef * SSPx, SSP_Direction Direction);
|
||||
void SSP_SetINTConfig(TSB_SSP_TypeDef * SSPx, uint32_t IntSrc);
|
||||
SSP_INTState SSP_GetINTConfig(TSB_SSP_TypeDef * SSPx);
|
||||
SSP_INTState SSP_GetPreEnableINTState(TSB_SSP_TypeDef * SSPx);
|
||||
SSP_INTState SSP_GetPostEnableINTState(TSB_SSP_TypeDef * SSPx);
|
||||
void SSP_ClearINTFlag(TSB_SSP_TypeDef * SSPx, uint32_t IntSrc);
|
||||
void SSP_SetDMACtrl(TSB_SSP_TypeDef * SSPx, SSP_Direction Direction, FunctionalState NewState);
|
||||
/** @} */
|
||||
/* End of group SSP_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /*__TMPM46B_SSP_H */
|
||||
@@ -0,0 +1,283 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_tmrb.h
|
||||
* @brief This file provides all the functions prototypes for TMRB driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/27
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_TMRB_H
|
||||
#define __TMPM46B_TMRB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TMRB
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TMRB_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TMRB Init Structure definition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t Mode; /*!< Select TMRB mode between internal interval
|
||||
timer mode and external event counter */
|
||||
uint32_t ClkDiv; /*!< Select the division for TMRB source clock */
|
||||
uint32_t TrailingTiming; /*!< Specify the trailingTiming value to be written
|
||||
into TBnRG1 */
|
||||
uint32_t UpCntCtrl; /*!< Select up-counter work mode between
|
||||
freerun and auto-reload */
|
||||
uint32_t LeadingTiming; /*!< Specify the LeadingTiming value to be written
|
||||
into TBnRG0 */
|
||||
} TMRB_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TMRB Flip-flop Structure definition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t FlipflopCtrl; /*!< Select TMRB flip-flop output level */
|
||||
uint32_t FlipflopReverseTrg; /*!< Specify TMRB flip-flop reverse trigger */
|
||||
} TMRB_FFOutputTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TMRB Interrupt factor Union definition
|
||||
*/
|
||||
typedef union {
|
||||
uint32_t All;
|
||||
struct {
|
||||
uint32_t MatchLeadingTiming:1;
|
||||
uint32_t MatchTrailingTiming:1;
|
||||
uint32_t OverFlow:1;
|
||||
uint32_t Reserverd:29;
|
||||
} Bit;
|
||||
} TMRB_INTFactor;
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Exported_Types */
|
||||
|
||||
/** @defgroup TMRB_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
#define TSB_TB_MPT0 ((TSB_TB_TypeDef *)TSB_MT0)
|
||||
#define TSB_TB_MPT1 ((TSB_TB_TypeDef *)TSB_MT1)
|
||||
#define TSB_TB_MPT2 ((TSB_TB_TypeDef *)TSB_MT2)
|
||||
#define TSB_TB_MPT3 ((TSB_TB_TypeDef *)TSB_MT3)
|
||||
#define IS_TMRB_ALL_PERIPH(param) (((param) == TSB_TB0) || \
|
||||
((param) == TSB_TB1) || \
|
||||
((param) == TSB_TB2) || \
|
||||
((param) == TSB_TB3) || \
|
||||
((param) == TSB_TB4) || \
|
||||
((param) == TSB_TB5) || \
|
||||
((param) == TSB_TB6) || \
|
||||
((param) == TSB_TB7) || \
|
||||
((param) == TSB_TB_MPT0) || \
|
||||
((param) == TSB_TB_MPT1) || \
|
||||
((param) == TSB_TB_MPT2) || \
|
||||
((param) == TSB_TB_MPT3))
|
||||
|
||||
#define IS_TMRB_TMRB_PERIPH(param) (((param) == TSB_TB0) || \
|
||||
((param) == TSB_TB1) || \
|
||||
((param) == TSB_TB2) || \
|
||||
((param) == TSB_TB3) || \
|
||||
((param) == TSB_TB4) || \
|
||||
((param) == TSB_TB5) || \
|
||||
((param) == TSB_TB6) || \
|
||||
((param) == TSB_TB7))
|
||||
|
||||
#define IS_TMRB_MPT_PERIPH(param) (((param) == TSB_TB_MPT0) || \
|
||||
((param) == TSB_TB_MPT1) || \
|
||||
((param) == TSB_TB_MPT2) || \
|
||||
((param) == TSB_TB_MPT3))
|
||||
|
||||
#define IS_TMRB_SYNC_PERIPH(param) (((param) == TSB_TB1) || \
|
||||
((param) == TSB_TB2) || \
|
||||
((param) == TSB_TB3) || \
|
||||
((param) == TSB_TB5) || \
|
||||
((param) == TSB_TB6) || \
|
||||
((param) == TSB_TB7))
|
||||
|
||||
#define TMRB_INTERVAL_TIMER ((uint32_t)0x00000001)
|
||||
#define TMRB_EVENT_CNT ((uint32_t)0x00000000)
|
||||
#define IS_TMRB_MODE(param) (((param) == TMRB_INTERVAL_TIMER) || \
|
||||
((param) == TMRB_EVENT_CNT))
|
||||
|
||||
#define TMRB_CLK_DIV_2 ((uint32_t)0x00000001)
|
||||
#define TMRB_CLK_DIV_8 ((uint32_t)0x00000002)
|
||||
#define TMRB_CLK_DIV_32 ((uint32_t)0x00000003)
|
||||
#define TMRB_CLK_DIV_64 ((uint32_t)0x00000004)
|
||||
#define TMRB_CLK_DIV_128 ((uint32_t)0x00000005)
|
||||
#define TMRB_CLK_DIV_256 ((uint32_t)0x00000006)
|
||||
#define TMRB_CLK_DIV_512 ((uint32_t)0x00000007)
|
||||
#define IS_TMRB_CLK_DIV(param) (((param) == TMRB_CLK_DIV_2) || \
|
||||
((param) == TMRB_CLK_DIV_8) || \
|
||||
((param) == TMRB_CLK_DIV_32) || \
|
||||
((param) == TMRB_CLK_DIV_64) || \
|
||||
((param) == TMRB_CLK_DIV_128) || \
|
||||
((param) == TMRB_CLK_DIV_256) || \
|
||||
((param) == TMRB_CLK_DIV_512))
|
||||
|
||||
#define IS_MPT_CLK_DIV(param) (((param) == TMRB_CLK_DIV_2) || \
|
||||
((param) == TMRB_CLK_DIV_8) || \
|
||||
((param) == TMRB_CLK_DIV_32))
|
||||
|
||||
#define TMRB_FREE_RUN ((uint32_t)0x00000000)
|
||||
#define TMRB_AUTO_CLEAR ((uint32_t)0x00000008)
|
||||
#define IS_TMRB_UC_CTRL(param) (((param) == TMRB_FREE_RUN) || \
|
||||
((param) == TMRB_AUTO_CLEAR))
|
||||
|
||||
#define MPT_FREE_RUN ((uint32_t)0x00000000)
|
||||
#define MPT_AUTO_CLEAR ((uint32_t)0x00000004)
|
||||
#define IS_MPT_UC_CTRL(param) (((param) == MPT_FREE_RUN) || \
|
||||
((param) == MPT_AUTO_CLEAR))
|
||||
|
||||
#define TMRB_FLIPFLOP_INVERT ((uint32_t)0x00000000)
|
||||
#define TMRB_FLIPFLOP_SET ((uint32_t)0x00000001)
|
||||
#define TMRB_FLIPFLOP_CLEAR ((uint32_t)0x00000002)
|
||||
#define IS_TMRB_FLIPFLOP_CTRL(param) (((param) == TMRB_FLIPFLOP_INVERT) || \
|
||||
((param) == TMRB_FLIPFLOP_SET) || \
|
||||
((param) == TMRB_FLIPFLOP_CLEAR))
|
||||
|
||||
#define TMRB_DISABLE_FLIPFLOP ((uint32_t)0x00000000)
|
||||
#define TMRB_FLIPFLOP_TAKE_CAPTURE_0 ((uint32_t)0x00000010)
|
||||
#define TMRB_FLIPFLOP_TAKE_CAPTURE_1 ((uint32_t)0x00000020)
|
||||
#define TMRB_FLIPFLOP_MATCH_TRAILING ((uint32_t)0x00000008)
|
||||
#define TMRB_FLIPFLOP_MATCH_LEADING ((uint32_t)0x00000004)
|
||||
#define IS_TMRB_FLIPFLOP_TRG(param) (((param) == TMRB_DISABLE_FLIPFLOP) || \
|
||||
((param) == TMRB_FLIPFLOP_TAKE_CAPTURE_0) || \
|
||||
((param) == TMRB_FLIPFLOP_TAKE_CAPTURE_1) || \
|
||||
((param) == TMRB_FLIPFLOP_MATCH_TRAILING) || \
|
||||
((param) == TMRB_FLIPFLOP_MATCH_LEADING) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_TAKE_CAPTURE_1)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_MATCH_TRAILING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_TRAILING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_MATCH_TRAILING | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_TRAILING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_MATCH_TRAILING | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_TRAILING | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_LEADING)) || \
|
||||
((param) == (TMRB_FLIPFLOP_TAKE_CAPTURE_0 | TMRB_FLIPFLOP_TAKE_CAPTURE_1 | TMRB_FLIPFLOP_MATCH_TRAILING | TMRB_FLIPFLOP_MATCH_LEADING)))
|
||||
|
||||
#define TMRB_DISABLE_CAPTURE ((uint32_t)0x00000000)
|
||||
#define TMRB_CAPTURE_TBIN0_TBIN1_RISING ((uint32_t)0x00000100)
|
||||
#define TMRB_CAPTURE_TBIN0_RISING_FALLING ((uint32_t)0x00000200)
|
||||
#define TMRB_CAPTURE_TBFF0_EDGE ((uint32_t)0x00000300)
|
||||
#define TMRB_CLEAR_TBIN1_RISING ((uint32_t)0x00000400)
|
||||
#define TMRB_CAPTURE_TBIN0_RISING_CLEAR_TBIN1_RISING ((uint32_t)0x00000500)
|
||||
#define IS_TMRB_CAPTURE_TIMING_ALL(param) (((param) == TMRB_DISABLE_CAPTURE) || \
|
||||
((param) == TMRB_CAPTURE_TBIN0_TBIN1_RISING) || \
|
||||
((param) == TMRB_CAPTURE_TBIN0_RISING_FALLING) || \
|
||||
((param) == TMRB_CAPTURE_TBFF0_EDGE) || \
|
||||
((param) == TMRB_CLEAR_TBIN1_RISING) || \
|
||||
((param) == TMRB_CAPTURE_TBIN0_RISING_CLEAR_TBIN1_RISING))
|
||||
|
||||
#define IS_TMRB_CAPTURE_TIMING_NONE_TBIN1(param) (((param) == TMRB_DISABLE_CAPTURE) || \
|
||||
((param) == TMRB_CAPTURE_TBIN0_RISING_FALLING) || \
|
||||
((param) == TMRB_CAPTURE_TBFF0_EDGE))
|
||||
|
||||
#define MPT_DISABLE_CAPTURE ((uint32_t)0x00000000)
|
||||
#define MPT_CAPTURE_IN_RISING ((uint32_t)0x00000008)
|
||||
#define MPT_CAPTURE_IN_RISING_FALLING ((uint32_t)0x00000010)
|
||||
#define IS_MPT_CAPTURE_TIMING(param) (((param) == MPT_DISABLE_CAPTURE) || \
|
||||
((param) == MPT_CAPTURE_IN_RISING) || \
|
||||
((param) == MPT_CAPTURE_IN_RISING_FALLING))
|
||||
|
||||
#define TMRB_RUN ((uint32_t)0x00000005)
|
||||
#define TMRB_STOP ((uint32_t)0x00000000)
|
||||
#define IS_TMRB_CMD(param) (((param) == TMRB_RUN) || ((param) == TMRB_STOP))
|
||||
|
||||
#define TMRB_CAPTURE_0 ((uint8_t)0x00)
|
||||
#define TMRB_CAPTURE_1 ((uint8_t)0x01)
|
||||
#define IS_TMRB_CAPTURE_REG(param) (((param) == TMRB_CAPTURE_0) || ((param) == TMRB_CAPTURE_1))
|
||||
|
||||
#define TMRB_NO_INT_MASK ((uint32_t)0x00000000)
|
||||
#define TMRB_MASK_MATCH_LEADING_INT ((uint32_t)0x00000001)
|
||||
#define TMRB_MASK_MATCH_TRAILING_INT ((uint32_t)0x00000002)
|
||||
#define TMRB_MASK_OVERFLOW_INT ((uint32_t)0x00000004)
|
||||
#define IS_TMRB_INT_MASK(param) (((param) == TMRB_NO_INT_MASK) || \
|
||||
((param) == TMRB_MASK_MATCH_LEADING_INT) || \
|
||||
((param) == TMRB_MASK_MATCH_TRAILING_INT) || \
|
||||
((param) == TMRB_MASK_OVERFLOW_INT) || \
|
||||
((param) == (TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_MATCH_TRAILING_INT)) || \
|
||||
((param) == (TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_OVERFLOW_INT)) || \
|
||||
((param) == (TMRB_MASK_MATCH_TRAILING_INT | TMRB_MASK_OVERFLOW_INT)) || \
|
||||
((param) == (TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_MATCH_TRAILING_INT | TMRB_MASK_OVERFLOW_INT)))
|
||||
|
||||
#define TMRB_TRG_EDGE_RISING ((uint8_t)0x00)
|
||||
#define TMRB_TRG_EDGE_FALLING ((uint8_t)0x02)
|
||||
#define IS_TMRB_TRG_EDGE(param) (((param) == TMRB_TRG_EDGE_RISING) || \
|
||||
((param) == TMRB_TRG_EDGE_FALLING))
|
||||
|
||||
#define TMRB_WRITE_REG_SEPARATE ((uint8_t)0x00)
|
||||
#define TMRB_WRITE_REG_SIMULTANEOUS ((uint8_t)0x40)
|
||||
#define IS_TMRB_WRITE_REG_MODE(param) (((param) == TMRB_WRITE_REG_SEPARATE) || \
|
||||
((param) == TMRB_WRITE_REG_SIMULTANEOUS))
|
||||
|
||||
#define TMRB_RUNNING_IN_CORE_HALT ((uint8_t)0x00)
|
||||
#define TMRB_STOP_IN_CORE_HALT ((uint8_t)0x40)
|
||||
#define IS_TMRB_CLK_IN_CORE_HALT(param) (((param) == TMRB_RUNNING_IN_CORE_HALT) || \
|
||||
((param) == TMRB_STOP_IN_CORE_HALT))
|
||||
|
||||
#define TMRB_NO_INT ((uint32_t)0x00000000)
|
||||
#define IS_TMRB_VALUE(param) ((param) <= 0x0000FFFFU)
|
||||
#define IS_VALID_LEADING(param1, param2) ((param1) <= (param2))
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Exported_Constants */
|
||||
/** @defgroup TMRB_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
void TMRB_Enable(TSB_TB_TypeDef * TBx);
|
||||
void TMRB_Disable(TSB_TB_TypeDef * TBx);
|
||||
void TMRB_SetRunState(TSB_TB_TypeDef * TBx, uint32_t Cmd);
|
||||
void TMRB_Init(TSB_TB_TypeDef * TBx, TMRB_InitTypeDef * InitStruct);
|
||||
void TMRB_SetCaptureTiming(TSB_TB_TypeDef * TBx, uint32_t CaptureTiming);
|
||||
void TMRB_SetFlipFlop(TSB_TB_TypeDef * TBx, TMRB_FFOutputTypeDef * FFStruct);
|
||||
TMRB_INTFactor TMRB_GetINTFactor(TSB_TB_TypeDef * TBx);
|
||||
void TMRB_SetINTMask(TSB_TB_TypeDef * TBx, uint32_t INTMask);
|
||||
void TMRB_ChangeLeadingTiming(TSB_TB_TypeDef * TBx, uint32_t LeadingTiming);
|
||||
void TMRB_ChangeTrailingTiming(TSB_TB_TypeDef * TBx, uint32_t TrailingTiming);
|
||||
uint16_t TMRB_GetUpCntValue(TSB_TB_TypeDef * TBx);
|
||||
uint16_t TMRB_GetCaptureValue(TSB_TB_TypeDef * TBx, uint8_t CapReg);
|
||||
void TMRB_ExecuteSWCapture(TSB_TB_TypeDef * TBx);
|
||||
void TMRB_SetIdleMode(TSB_TB_TypeDef * TBx, FunctionalState NewState);
|
||||
void TMRB_SetSyncMode(TSB_TB_TypeDef * TBx, FunctionalState NewState);
|
||||
void TMRB_SetDoubleBuf(TSB_TB_TypeDef * TBx, FunctionalState NewState, uint8_t WriteRegMode);
|
||||
void TMRB_SetExtStartTrg(TSB_TB_TypeDef * TBx, FunctionalState NewState, uint8_t TrgMode);
|
||||
void TMRB_SetClkInCoreHalt(TSB_TB_TypeDef * TBx, uint8_t ClkState);
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __TMPM46B_TMRB_H */
|
||||
@@ -0,0 +1,390 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_uart.h
|
||||
* @brief This file provides all the functions prototypes for UART driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/26
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TMPM46B_UART_H
|
||||
#define __TMPM46B_UART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "TMPM46B.h"
|
||||
#include "tx04_common.h"
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup UART
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief UART Init Structure definition
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t BaudRate; /*!< This member configures the UART communication
|
||||
baud rate. */
|
||||
uint32_t DataBits; /*!< Specifies UART transfer mode, which could be
|
||||
7-bit mode, 8-bit mode or 9-bit mode. */
|
||||
uint32_t StopBits; /*!< Specifies the length of stop bit transmission
|
||||
in UART mode. */
|
||||
uint32_t Parity; /*!< Specifies the parity mode which could be odd
|
||||
parity, even parity or no parity. */
|
||||
uint32_t Mode; /*!< Enables or disables Receive, Transmit or
|
||||
both. */
|
||||
uint32_t FlowCtrl; /*!< Specifies whether the hardware flow control
|
||||
mode is enabled or disabled. */
|
||||
} UART_InitTypeDef;
|
||||
|
||||
typedef struct {
|
||||
uint32_t InputClkEdge; /*!< Select the input clock edge.on the SCLK output mode
|
||||
this bit only can set to be 0(SIO_SCLKS_TXDF_RXDR) */
|
||||
uint32_t TIDLE; /*!< The status of TXDx pin after output of the
|
||||
last bit */
|
||||
uint32_t TXDEMP; /*!< The status of TXDx pin when an under run error
|
||||
is occurred in SCLK input mode */
|
||||
uint32_t EHOLDTime; /*!< The last bit hold time of TXDx pin in SCLK
|
||||
input mode */
|
||||
uint32_t IntervalTime; /*!< Setting interval time of continuous transmission which
|
||||
could be None,1*SCLK,2*SCLK,4*SCLK,8*SCLK,16*SCLK,32*SCLK,64*SCLK.
|
||||
this bit is valid only for SCLK output mode and double
|
||||
buffer is enabled. */
|
||||
uint32_t TransferMode; /*!< Setting transfer mode which could be transfer prohibited,
|
||||
half duplex(Receive),half duplex(Transmit) or full duplex. */
|
||||
uint32_t TransferDir; /*!< Setting transfer direction which could be
|
||||
LSB_FRIST or MSB_FRIST. */
|
||||
uint32_t Mode; /*!< Enables or disables Receive, Transmit or both. */
|
||||
uint32_t DoubleBuffer; /*!< Double Buffer mode is enabled or disabled. */
|
||||
uint32_t BaudRateClock; /*!< Select the input clock for baud rate generator */
|
||||
uint32_t Divider; /*!< Division ratio "N" */
|
||||
} SIO_InitTypeDef;
|
||||
|
||||
/** @} */
|
||||
/* End of group UART_Exported_Types */
|
||||
|
||||
/** @defgroup UART_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define UART0 TSB_SC0
|
||||
#define UART1 TSB_SC1
|
||||
#define UART2 TSB_SC2
|
||||
#define UART3 TSB_SC3
|
||||
#define IS_UART_PERIPH(param) (((param) == UART0) || \
|
||||
((param) == UART1) || \
|
||||
((param) == UART2) || \
|
||||
((param) == UART3))
|
||||
|
||||
#define SIO0 TSB_SC0
|
||||
#define SIO1 TSB_SC1
|
||||
#define SIO2 TSB_SC2
|
||||
#define SIO3 TSB_SC3
|
||||
#define IS_SIO_PERIPH(param) (((param) == SIO0)|| \
|
||||
((param) == SIO1) || \
|
||||
((param) == SIO2) || \
|
||||
((param) == SIO3))
|
||||
|
||||
#define UART_DATA_BITS_7 ((uint32_t)0x00000004)
|
||||
#define UART_DATA_BITS_8 ((uint32_t)0x00000008)
|
||||
#define UART_DATA_BITS_9 ((uint32_t)0x0000000C)
|
||||
#define IS_UART_DATA_BITS(param) (((param) == UART_DATA_BITS_7) || \
|
||||
((param) == UART_DATA_BITS_8) || \
|
||||
((param) == UART_DATA_BITS_9))
|
||||
|
||||
#define UART_STOP_BITS_1 ((uint32_t)0x00000000)
|
||||
#define UART_STOP_BITS_2 ((uint32_t)0x00000010)
|
||||
#define IS_UART_STOPBITS(param) (((param) == UART_STOP_BITS_1) || \
|
||||
((param) == UART_STOP_BITS_2))
|
||||
|
||||
#define UART_NO_PARITY ((uint32_t)0x00000000)
|
||||
#define UART_EVEN_PARITY ((uint32_t)0x00000060)
|
||||
#define UART_ODD_PARITY ((uint32_t)0x00000020)
|
||||
#define IS_UART_PARITY(param) (((param) == UART_NO_PARITY) || \
|
||||
((param) == UART_EVEN_PARITY) || \
|
||||
((param) == UART_ODD_PARITY))
|
||||
|
||||
#define SIO_CLK_SCLKOUTPUT ((uint32_t)0x00000000)
|
||||
#define SIO_CLK_SCLKINPUT ((uint32_t)0x00000001)
|
||||
#define IS_SIO_CLK_SEL(param) (((param) == SIO_CLK_SCLKOUTPUT) || \
|
||||
((param) == SIO_CLK_SCLKINPUT))
|
||||
|
||||
#define SIO_SCLKS_TXDF_RXDR ((uint32_t)0x00000000)
|
||||
#define SIO_SCLKS_TXDR_RXDF ((uint32_t)0x00000002)
|
||||
#define IS_SIO_SCLKS_TRXD(param) (((param) == SIO_SCLKS_TXDF_RXDR) || \
|
||||
((param) == SIO_SCLKS_TXDR_RXDF))
|
||||
|
||||
#define SIO_TIDLE_LOW ((uint32_t)0x00000000)
|
||||
#define SIO_TIDLE_HIGH ((uint32_t)0x00000100)
|
||||
#define SIO_TIDLE_LAST ((uint32_t)0x00000200)
|
||||
#define IS_SIO_TIDLE_LEVEL(param) (((param) == SIO_TIDLE_LOW) || \
|
||||
((param) == SIO_TIDLE_HIGH) || \
|
||||
((param) == SIO_TIDLE_LAST))
|
||||
|
||||
#define SIO_TXDEMP_LOW ((uint32_t)0x00000000)
|
||||
#define SIO_TXDEMP_HIGH ((uint32_t)0x00000400)
|
||||
#define IS_SIO_TXDEMP_LEVEL(param) (((param) == SIO_TXDEMP_LOW) || \
|
||||
((param) == SIO_TXDEMP_HIGH))
|
||||
|
||||
#define SIO_EHOLD_FC_2 ((uint32_t)0x00000000)
|
||||
#define SIO_EHOLD_FC_4 ((uint32_t)0x00001000)
|
||||
#define SIO_EHOLD_FC_8 ((uint32_t)0x00002000)
|
||||
#define SIO_EHOLD_FC_16 ((uint32_t)0x00003000)
|
||||
#define SIO_EHOLD_FC_32 ((uint32_t)0x00004000)
|
||||
#define SIO_EHOLD_FC_64 ((uint32_t)0x00005000)
|
||||
#define SIO_EHOLD_FC_128 ((uint32_t)0x00006000)
|
||||
#define IS_SIO_EHOLD_TIME(param) (((param) == SIO_EHOLD_FC_2) || \
|
||||
((param) == SIO_EHOLD_FC_4) || \
|
||||
((param) == SIO_EHOLD_FC_8) || \
|
||||
((param) == SIO_EHOLD_FC_16) || \
|
||||
((param) == SIO_EHOLD_FC_32) || \
|
||||
((param) == SIO_EHOLD_FC_64) || \
|
||||
((param) == SIO_EHOLD_FC_128))
|
||||
|
||||
#define SIO_SINT_TIME_NONE ((uint32_t)0x00000000)
|
||||
#define SIO_SINT_TIME_SCLK_1 ((uint32_t)0x00000002)
|
||||
#define SIO_SINT_TIME_SCLK_2 ((uint32_t)0x00000004)
|
||||
#define SIO_SINT_TIME_SCLK_4 ((uint32_t)0x00000006)
|
||||
#define SIO_SINT_TIME_SCLK_8 ((uint32_t)0x00000008)
|
||||
#define SIO_SINT_TIME_SCLK_16 ((uint32_t)0x0000000A)
|
||||
#define SIO_SINT_TIME_SCLK_32 ((uint32_t)0x0000000C)
|
||||
#define SIO_SINT_TIME_SCLK_64 ((uint32_t)0x0000000E)
|
||||
#define IS_SIO_SINT_TIME(param) (((param) == SIO_SINT_TIME_NONE) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_1) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_2) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_4) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_8) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_16) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_32) || \
|
||||
((param) == SIO_SINT_TIME_SCLK_64))
|
||||
|
||||
#define SIO_TRANSFER_PROHIBIT ((uint32_t)0x00000000)
|
||||
#define SIO_TRANSFER_HALFDPX_RX ((uint32_t)0x00000020)
|
||||
#define SIO_TRANSFER_HALFDPX_TX ((uint32_t)0x00000040)
|
||||
#define SIO_TRANSFER_FULLDPX ((uint32_t)0x00000060)
|
||||
#define IS_SIO_TRANSFER_MODE(param) (((param) == SIO_TRANSFER_PROHIBIT) || \
|
||||
((param) == SIO_TRANSFER_HALFDPX_RX) || \
|
||||
((param) == SIO_TRANSFER_HALFDPX_TX) || \
|
||||
((param) == SIO_TRANSFER_FULLDPX))
|
||||
|
||||
#define SIO_ENABLE_RX ((uint32_t)0x00000020)
|
||||
#define SIO_ENABLE_TX ((uint32_t)0x00000010)
|
||||
#define IS_SIO_MODE(param) (((param) == SIO_ENABLE_RX) || \
|
||||
((param) == SIO_ENABLE_TX) || \
|
||||
((param) == (SIO_ENABLE_TX | SIO_ENABLE_RX)))
|
||||
|
||||
#define SIO_LSB_FRIST ((uint32_t)0x00000000)
|
||||
#define SIO_MSB_FRIST ((uint32_t)0x00000008)
|
||||
#define IS_SIO_TRANS_DIR(param) (((param) == SIO_LSB_FRIST) || \
|
||||
((param) == SIO_MSB_FRIST))
|
||||
|
||||
#define SIO_WBUF_DISABLE ((uint32_t)0x00000000)
|
||||
#define SIO_WBUF_ENABLE ((uint32_t)0x00000004)
|
||||
#define IS_SIO_WBUF_SET(param) (((param) == SIO_WBUF_DISABLE) || \
|
||||
((param) == SIO_WBUF_ENABLE))
|
||||
|
||||
#define SIO_BR_CLOCK_TS0 ((uint32_t)0x00000000)
|
||||
#define SIO_BR_CLOCK_TS2 ((uint32_t)0x00000010)
|
||||
#define SIO_BR_CLOCK_TS8 ((uint32_t)0x00000020)
|
||||
#define SIO_BR_CLOCK_TS32 ((uint32_t)0x00000030)
|
||||
#define IS_SIO_BR_CLOCK(param) (((param) == SIO_BR_CLOCK_TS0) || \
|
||||
((param) == SIO_BR_CLOCK_TS2) || \
|
||||
((param) == SIO_BR_CLOCK_TS8) || \
|
||||
((param) == SIO_BR_CLOCK_TS32))
|
||||
|
||||
#define SIO_BR_DIVIDER_16 ((uint32_t)0x00000000)
|
||||
#define SIO_BR_DIVIDER_1 ((uint32_t)0x00000001)
|
||||
#define SIO_BR_DIVIDER_2 ((uint32_t)0x00000002)
|
||||
#define SIO_BR_DIVIDER_3 ((uint32_t)0x00000003)
|
||||
#define SIO_BR_DIVIDER_4 ((uint32_t)0x00000004)
|
||||
#define SIO_BR_DIVIDER_5 ((uint32_t)0x00000005)
|
||||
#define SIO_BR_DIVIDER_6 ((uint32_t)0x00000006)
|
||||
#define SIO_BR_DIVIDER_7 ((uint32_t)0x00000007)
|
||||
#define SIO_BR_DIVIDER_8 ((uint32_t)0x00000008)
|
||||
#define SIO_BR_DIVIDER_9 ((uint32_t)0x00000009)
|
||||
#define SIO_BR_DIVIDER_10 ((uint32_t)0x0000000A)
|
||||
#define SIO_BR_DIVIDER_11 ((uint32_t)0x0000000B)
|
||||
#define SIO_BR_DIVIDER_12 ((uint32_t)0x0000000C)
|
||||
#define SIO_BR_DIVIDER_13 ((uint32_t)0x0000000D)
|
||||
#define SIO_BR_DIVIDER_14 ((uint32_t)0x0000000E)
|
||||
#define SIO_BR_DIVIDER_15 ((uint32_t)0x0000000F)
|
||||
#define IS_SIO_BR_DIVIDER(param) ((param) <= SIO_BR_DIVIDER_15)
|
||||
|
||||
#define IS_SIO_DATA(param) ((param) <= 0xFFU)
|
||||
|
||||
#define SIO_CLOCK_T0_HALF ((uint32_t)0x00000000)
|
||||
#define SIO_CLOCK_T0 ((uint32_t)0x00000002)
|
||||
#define IS_SIO_CLOCK(param) (((param) == SIO_CLOCK_T0_HALF) || \
|
||||
((param) == SIO_CLOCK_T0))
|
||||
|
||||
#define UART_ENABLE_RX ((uint32_t)0x00000020)
|
||||
#define UART_ENABLE_TX ((uint32_t)0x00000010)
|
||||
#define IS_UART_MODE(param) (((param) == UART_ENABLE_RX) || \
|
||||
((param) == UART_ENABLE_TX) || \
|
||||
((param) == (UART_ENABLE_TX | UART_ENABLE_RX)))
|
||||
|
||||
#define UART_NONE_FLOW_CTRL ((uint32_t)0x00000000)
|
||||
#define IS_UART_FLOW_CONTROL(param) ((param) == UART_NONE_FLOW_CTRL)
|
||||
|
||||
#ifdef USE_STK
|
||||
#define IS_UART_BAUDRATE(param) (((param) >= 3663U) && \
|
||||
((param) <= 921600U))
|
||||
#else
|
||||
#define IS_UART_BAUDRATE(param) (((param) >= 2929U) && \
|
||||
((param) <= 921600U))
|
||||
#endif
|
||||
|
||||
#define IS_UART_DATA(param) ((param) <= 0x01FFU)
|
||||
|
||||
#define IS_UART_CLOCK(param) ((param) <= ((uint32_t)0x00000001))
|
||||
#define IS_UART_TIME(param) ((param) <= ((uint32_t)0x00000006))
|
||||
#define UART_RX ((uint32_t)0x00000020)
|
||||
#define UART_TX ((uint32_t)0x00000040)
|
||||
#define IS_UART_TRX(param) (((param) == UART_RX) || \
|
||||
((param) == UART_TX))
|
||||
|
||||
#define UART_TRANSFER_PROHIBIT ((uint32_t)0x00000000)
|
||||
#define UART_TRANSFER_HALFDPX_RX ((uint32_t)0x00000020)
|
||||
#define UART_TRANSFER_HALFDPX_TX ((uint32_t)0x00000040)
|
||||
#define UART_TRANSFER_FULLDPX ((uint32_t)0x00000060)
|
||||
#define IS_UART_TRANSFER_MODE(param) (((param) == UART_TRANSFER_PROHIBIT) || \
|
||||
((param) == UART_TRANSFER_HALFDPX_RX) || \
|
||||
((param) == UART_TRANSFER_HALFDPX_TX) || \
|
||||
((param) == UART_TRANSFER_FULLDPX))
|
||||
|
||||
#define UART_RXFIFO_MAX ((uint32_t)0x00000000)
|
||||
#define UART_RXFIFO_RXFLEVEL ((uint32_t)0x00000010)
|
||||
#define IS_UATR_RXFIFO_BYTESUSED(param) (((param) == UART_RXFIFO_MAX) || \
|
||||
((param) == UART_RXFIFO_RXFLEVEL))
|
||||
|
||||
#define UART_RXFIFO4B_FLEVLE_4_2B ((uint32_t)0x00000000)
|
||||
#define UART_RXFIFO4B_FLEVLE_1_1B ((uint32_t)0x00000001)
|
||||
#define UART_RXFIFO4B_FLEVLE_2_2B ((uint32_t)0x00000002)
|
||||
#define UART_RXFIFO4B_FLEVLE_3_1B ((uint32_t)0x00000003)
|
||||
#define IS_UART_RXFIFO4B_FLEVLE(param) (((param) == UART_RXFIFO4B_FLEVLE_4_2B) || \
|
||||
((param) == UART_RXFIFO4B_FLEVLE_1_1B) || \
|
||||
((param) == UART_RXFIFO4B_FLEVLE_2_2B) || \
|
||||
((param) == UART_RXFIFO4B_FLEVLE_3_1B))
|
||||
|
||||
#define UART_RFIS_REACH_FLEVEL ((uint32_t)0x00000000)
|
||||
#define UART_RFIS_REACH_EXCEED_FLEVEL ((uint32_t)0x00000040)
|
||||
#define IS_UATR_RFIS_CONDITION(param) (((param) == UART_RFIS_REACH_FLEVEL) || \
|
||||
((param) == UART_RFIS_REACH_EXCEED_FLEVEL))
|
||||
|
||||
#define UART_TXFIFO4B_FLEVLE_0_0B ((uint32_t)0x00000000)
|
||||
#define UART_TXFIFO4B_FLEVLE_1_1B ((uint32_t)0x00000001)
|
||||
#define UART_TXFIFO4B_FLEVLE_2_0B ((uint32_t)0x00000002)
|
||||
#define UART_TXFIFO4B_FLEVLE_3_1B ((uint32_t)0x00000003)
|
||||
#define IS_UART_TXFIFO4B_FLEVLE(param) (((param) == UART_TXFIFO4B_FLEVLE_0_0B) || \
|
||||
((param) == UART_TXFIFO4B_FLEVLE_1_1B) || \
|
||||
((param) == UART_TXFIFO4B_FLEVLE_2_0B) || \
|
||||
((param) == UART_TXFIFO4B_FLEVLE_3_1B))
|
||||
|
||||
#define UART_TRXFIFO_EMPTY ((uint32_t)0x00000000)
|
||||
#define UART_TRXFIFO_1B ((uint32_t)0x00000001)
|
||||
#define UART_TRXFIFO_2B ((uint32_t)0x00000002)
|
||||
#define UART_TRXFIFO_3B ((uint32_t)0x00000003)
|
||||
#define UART_TRXFIFO_4B ((uint32_t)0x00000004)
|
||||
|
||||
#define UART_TFIS_REACH_FLEVEL ((uint32_t)0x00000000)
|
||||
#define UART_TFIS_REACH_NOREACH_FLEVEL ((uint32_t)0x00000040)
|
||||
#define IS_UATR_TFIS_CONDITION(param) (((param) == UART_TFIS_REACH_FLEVEL) || \
|
||||
((param) == UART_TFIS_REACH_NOREACH_FLEVEL))
|
||||
|
||||
#define UART_RXFIFO_OVERRUN ((uint32_t)0x00000001)
|
||||
|
||||
#define UART_TXFIFO_UNDERRUN ((uint32_t)0x00000001)
|
||||
|
||||
/** @} */
|
||||
/* End of group UART_Exported_Constants */
|
||||
|
||||
/** @addtogroup UART_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
UART_NO_ERR = 0U,
|
||||
UART_OVERRUN = 1U,
|
||||
UART_PARITY_ERR = 2U,
|
||||
UART_FRAMING_ERR = 3U,
|
||||
UART_ERRS = 4U
|
||||
} UART_Err;
|
||||
|
||||
typedef enum {
|
||||
UART_RXTXCNT_NONE = 0U,
|
||||
UART_RXTXCNT_AUTODISABLE = 1U
|
||||
} UART_TRxDisable;
|
||||
#define IS_UATR_TRX_AUTODISABLE(param) (((param) == UART_RXTXCNT_NONE) || \
|
||||
((param) == UART_RXTXCNT_AUTODISABLE))
|
||||
|
||||
/** @} */
|
||||
/* End of group UART_Exported_Types */
|
||||
|
||||
/** @defgroup UART_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
void UART_Enable(TSB_SC_TypeDef * UARTx);
|
||||
void UART_Disable(TSB_SC_TypeDef * UARTx);
|
||||
WorkState UART_GetBufState(TSB_SC_TypeDef * UARTx, uint8_t Direction);
|
||||
void UART_SWReset(TSB_SC_TypeDef * UARTx);
|
||||
void UART_Init(TSB_SC_TypeDef * UARTx, UART_InitTypeDef * InitStruct);
|
||||
uint32_t UART_GetRxData(TSB_SC_TypeDef * UARTx);
|
||||
void UART_SetTxData(TSB_SC_TypeDef * UARTx, uint32_t Data);
|
||||
void UART_DefaultConfig(TSB_SC_TypeDef * UARTx);
|
||||
UART_Err UART_GetErrState(TSB_SC_TypeDef * UARTx);
|
||||
void UART_SetWakeUpFunc(TSB_SC_TypeDef * UARTx, FunctionalState NewState);
|
||||
void UART_SetIdleMode(TSB_SC_TypeDef * UARTx, FunctionalState NewState);
|
||||
void UART_SetInputClock(TSB_SC_TypeDef * UARTx, uint32_t clock);
|
||||
void UART_FIFOConfig(TSB_SC_TypeDef * UARTx, FunctionalState NewState);
|
||||
void UART_SetFIFOTransferMode(TSB_SC_TypeDef * UARTx, uint32_t TransferMode);
|
||||
void UART_TRxAutoDisable(TSB_SC_TypeDef * UARTx, UART_TRxDisable TRxAutoDisable);
|
||||
void UART_RxFIFOINTCtrl(TSB_SC_TypeDef * UARTx, FunctionalState NewState);
|
||||
void UART_TxFIFOINTCtrl(TSB_SC_TypeDef * UARTx, FunctionalState NewState);
|
||||
void UART_RxFIFOByteSel(TSB_SC_TypeDef * UARTx, uint32_t BytesUsed);
|
||||
void UART_RxFIFOFillLevel(TSB_SC_TypeDef * UARTx, uint32_t RxFIFOLevel);
|
||||
void UART_RxFIFOINTSel(TSB_SC_TypeDef * UARTx, uint32_t RxINTCondition);
|
||||
void UART_RxFIFOClear(TSB_SC_TypeDef * UARTx);
|
||||
void UART_TxFIFOFillLevel(TSB_SC_TypeDef * UARTx, uint32_t TxFIFOLevel);
|
||||
void UART_TxFIFOINTSel(TSB_SC_TypeDef * UARTx, uint32_t TxINTCondition);
|
||||
void UART_TxFIFOClear(TSB_SC_TypeDef * UARTx);
|
||||
void UART_TxBufferClear(TSB_SC_TypeDef * UARTx);
|
||||
uint32_t UART_GetRxFIFOFillLevelStatus(TSB_SC_TypeDef * UARTx);
|
||||
uint32_t UART_GetRxFIFOOverRunStatus(TSB_SC_TypeDef * UARTx);
|
||||
uint32_t UART_GetTxFIFOFillLevelStatus(TSB_SC_TypeDef * UARTx);
|
||||
uint32_t UART_GetTxFIFOUnderRunStatus(TSB_SC_TypeDef * UARTx);
|
||||
void SIO_SetInputClock(TSB_SC_TypeDef * SIOx, uint32_t Clock);
|
||||
void SIO_Enable(TSB_SC_TypeDef * SIOx);
|
||||
void SIO_Disable(TSB_SC_TypeDef * SIOx);
|
||||
uint8_t SIO_GetRxData(TSB_SC_TypeDef * SIOx);
|
||||
void SIO_SetTxData(TSB_SC_TypeDef * SIOx, uint8_t Data);
|
||||
void SIO_Init(TSB_SC_TypeDef * SIOx, uint32_t IOClkSel, SIO_InitTypeDef * InitStruct);
|
||||
/** @} */
|
||||
/* End of group UART_Exported_FunctionPrototypes */
|
||||
|
||||
/** @} */
|
||||
/* End of group UART */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __TMPM46B_UART_H */
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tx04_common.h
|
||||
* @brief All common macro and definition for TX04 peripheral drivers
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/04
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TX04_COMMON_H
|
||||
#define __TX04_COMMON_H
|
||||
|
||||
typedef enum {
|
||||
SUCCESS = 0U,
|
||||
ERROR = 1U,
|
||||
FAIL = -1
|
||||
} Result;
|
||||
|
||||
typedef enum {
|
||||
BUSY = 0U,
|
||||
DONE = 1U
|
||||
} WorkState;
|
||||
|
||||
typedef enum {
|
||||
DISABLE = 0U,
|
||||
ENABLE = 1U
|
||||
} FunctionalState;
|
||||
|
||||
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||
#define IS_POINTER_NOT_NULL(param) ((void*)(param) != (void*)0)
|
||||
|
||||
/*
|
||||
* To report the name of the source file and source line number where the
|
||||
* assert_param error has occurred, "DEBUG" must be defined. And detailed
|
||||
* definition of assert_failed() is needed to be implemented, which can be
|
||||
* done, for example, in the main.c file.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
void assert_failed(char *file, int32_t line);
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((char *)__FILE__, __LINE__))
|
||||
#else
|
||||
#define assert_param(expr)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#endif /* __TX04_COMMON_H */
|
||||
@@ -0,0 +1,621 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_adc.c
|
||||
* @brief This file provides API functions for ADC driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/11
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_adc.h"
|
||||
|
||||
#if defined(__TMPM46B_ADC_H)
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC
|
||||
* @brief ADC driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
#define MOD6_ADRST_10 ((uint32_t)0x00000002)
|
||||
#define MOD6_ADRST_01 ((uint32_t)0x00000001)
|
||||
|
||||
#define MOD3_ITM_CLEAR ((uint32_t)0x00000003)
|
||||
|
||||
#define MOD2_ADCH_CLEAR ((uint32_t)0x000000F0)
|
||||
#define MOD2_HPADCH_CLEAR ((uint32_t)0x0000000F)
|
||||
|
||||
#define MOD1_ADHWE_CLEAR ((uint32_t)0x000000EE)
|
||||
#define MOD1_ADHWE_SET ((uint32_t)0x00000001)
|
||||
#define MOD1_ADHWS_CLEAR ((uint32_t)0x000000ED)
|
||||
#define MOD1_HPADHWE_CLEAR ((uint32_t)0x000000EB)
|
||||
#define MOD1_HPADHWE_SET ((uint32_t)0x00000004)
|
||||
#define MOD1_HPADHWS_CLEAR ((uint32_t)0x000000E7)
|
||||
|
||||
#define ADILV_TRGSEL_CLEAR ((uint32_t)0x0000F0FF)
|
||||
#define ADILV_HPTRGSEL_CLEAR ((uint32_t)0x00000FFF)
|
||||
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Private_Defines */
|
||||
|
||||
/** @defgroup ADC_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Private_FunctionPrototypes */
|
||||
|
||||
/** @defgroup ADC_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Private_Functions */
|
||||
|
||||
/** @defgroup ADC_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Software reset ADC.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SWReset(TSB_AD_TypeDef * ADx)
|
||||
{
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
|
||||
ADC_SetVref(ADx, ENABLE);
|
||||
ADx->MOD6 = MOD6_ADRST_10;
|
||||
ADx->MOD6 = MOD6_ADRST_01;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set AD sample hold time and prescaler clock.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param Sample_HoldTime: Select the AD sample hold time.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_CONVERSION_CLK_10, ADC_CONVERSION_CLK_20,
|
||||
* ADC_CONVERSION_CLK_30, ADC_CONVERSION_CLK_40,
|
||||
* ADC_CONVERSION_CLK_80, ADC_CONVERSION_CLK_160,
|
||||
* ADC_CONVERSION_CLK_320
|
||||
* @param Prescaler_Output: Select the AD prescaler clock.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_FC_DIVIDE_LEVEL_1, ADC_FC_DIVIDE_LEVEL_2,
|
||||
* ADC_FC_DIVIDE_LEVEL_4, ADC_FC_DIVIDE_LEVEL_8,
|
||||
* ADC_FC_DIVIDE_LEVEL_16.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetClk(TSB_AD_TypeDef * ADx, uint32_t Sample_HoldTime, uint32_t Prescaler_Output)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_HOLD_TIME(Sample_HoldTime));
|
||||
assert_param(IS_ADC_PRESCALER(Prescaler_Output));
|
||||
|
||||
/* Set ADCLK */
|
||||
ADx->CLK = Sample_HoldTime + Prescaler_Output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start AD conversion.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_Start(TSB_AD_TypeDef * ADx)
|
||||
{
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
|
||||
/* Set ADMOD0<ADS> = 1 to start AD conversion */
|
||||
TSB_AD_MOD0_ADS = 1U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable ADC scan mode.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param NewState: Specify ADC scan mode state.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetScanMode(TSB_AD_TypeDef * ADx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD3<SCAN> */
|
||||
TSB_AD_MOD3_SCAN = NewState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable ADC repeat mode.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param NewState: Specify ADC repeat mode state.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetRepeatMode(TSB_AD_TypeDef * ADx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD3<REPEAT> */
|
||||
TSB_AD_MOD3_REPEAT = NewState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC interrupt mode in fixed channel repeat conversion mode.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param INTMode: Specify AD conversion interrupt mode.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_INT_SINGLE, ADC_INT_CONVERSION_2,
|
||||
* ADC_INT_CONVERSION_3, ADC_INT_CONVERSION_4,
|
||||
* ADC_INT_CONVERSION_5, ADC_INT_CONVERSION_6,
|
||||
* ADC_INT_CONVERSION_7, ADC_INT_CONVERSION_8.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetINTMode(TSB_AD_TypeDef * ADx, uint32_t INTMode)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_INT_MODE(INTMode));
|
||||
|
||||
/* Set ADMOD3<ITM[2:0]> */
|
||||
tmp = ADx->MOD3;
|
||||
tmp &= MOD3_ITM_CLEAR;
|
||||
tmp |= INTMode;
|
||||
ADx->MOD3 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC input channel.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param InputChannel: Analog input channel.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_AN_00, ADC_AN_01, ADC_AN_02, ADC_AN_03,
|
||||
* ADC_AN_04, ADC_AN_05, ADC_AN_06, ADC_AN_07.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetInputChannel(TSB_AD_TypeDef * ADx, ADC_AINx InputChannel)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_INPUT_CHANNEL(InputChannel));
|
||||
|
||||
/* Set ADMOD2<ADCH[3:0]> */
|
||||
tmp = ADx->MOD2;
|
||||
tmp &= MOD2_ADCH_CLEAR;
|
||||
tmp |= InputChannel;
|
||||
ADx->MOD2 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC scan channel.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param StartChannel: Specify the start channel to be scanned.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_AN_00, ADC_AN_01, ADC_AN_02, ADC_AN_03,
|
||||
* ADC_AN_04, ADC_AN_05, ADC_AN_06, ADC_AN_07.
|
||||
* @param Range: Specify the range of assignable channel scan value.
|
||||
* This parameter can be one of the following values:
|
||||
* 1, 2, 3, 4, 5, 6, 7, 8 (note: StartChannel + Range <= 8 )
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetScanChannel(TSB_AD_TypeDef * ADx, ADC_AINx StartChannel, uint32_t Range)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_SCAN_CHANNEL(StartChannel, Range));
|
||||
|
||||
/* Set ADMOD4<SCANAREA> */
|
||||
ADx->MOD4 = (uint32_t) (StartChannel | ((Range - 1U) << 4U));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Control AVREFH-AVREFL current.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param VrefCtrl: Specify how to apply AVREFH-AVREFL current.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_APPLY_VREF_IN_CONVERSION or ADC_APPLY_VREF_AT_ANY_TIME.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetVrefCut(TSB_AD_TypeDef * ADx, uint32_t VrefCtrl)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_VREF_CTRL(VrefCtrl));
|
||||
|
||||
/* Set ADMOD1<RCUT> */
|
||||
TSB_AD_MOD1_RCUT = VrefCtrl;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC operation in IDLE mode.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param NewState: Specify ADC operation state in IDLE mode.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetIdleMode(TSB_AD_TypeDef * ADx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD1<I2AD> */
|
||||
TSB_AD_MOD1_I2AD = NewState;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC VREF application.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param NewState: Specify ADC Vref application state.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetVref(TSB_AD_TypeDef * ADx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD1<VREFON> */
|
||||
TSB_AD_MOD1_DACON = NewState;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select ADC top-priority conversion analog input channel.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following values:
|
||||
* TSB_AD
|
||||
* @param TopInputChannel: Analog input channel for top-priority conversion.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_AN_00, ADC_AN_01, ADC_AN_02, ADC_AN_03,
|
||||
* ADC_AN_04, ADC_AN_05, ADC_AN_06, ADC_AN_07.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetInputChannelTop(TSB_AD_TypeDef * ADx, ADC_AINx TopInputChannel)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_INPUT_CHANNEL(TopInputChannel));
|
||||
|
||||
/* Set ADMOD2<HPADCH[3:0]> */
|
||||
tmp = ADx->MOD2;
|
||||
tmp &= MOD2_HPADCH_CLEAR;
|
||||
tmp |= ((uint32_t) TopInputChannel << 4U);
|
||||
ADx->MOD2 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start top-priority AD conversion.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_StartTopConvert(TSB_AD_TypeDef * ADx)
|
||||
{
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
|
||||
/* Set ADMOD0<HPADS> = 1 to start top-priority AD conversion */
|
||||
TSB_AD_MOD0_HPADS = 1U;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the specified ADC monitor module.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param ADCMPx: Select which compare control register will be used.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_CMPCR_0 or ADC_CMPCR_1.
|
||||
* @param NewState: Specify ADC monitor function state.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetMonitor(TSB_AD_TypeDef * ADx, ADC_CMPCRx ADCMPx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_CMPCRx(ADCMPx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (ADCMPx == ADC_CMPCR_0) {
|
||||
/* Set ADCMPCR0<CMP0EN> */
|
||||
TSB_AD_CMPCR0_CMP0EN = NewState;
|
||||
} else {
|
||||
/* Set ADCMPCR1<CMP1EN> */
|
||||
TSB_AD_CMPCR1_CMP1EN = NewState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the specified ADC monitor module.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param ADCMPx: Select which compare control register will be used.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_CMPCR_0 or ADC_CMPCR_1.
|
||||
* @param Monitor: The structure containing ADC monitor configuration.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_ConfigMonitor(TSB_AD_TypeDef * ADx, ADC_CMPCRx ADCMPx, ADC_MonitorTypeDef * Monitor)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_CMPCRx(ADCMPx));
|
||||
assert_param(IS_POINTER_NOT_NULL(Monitor));
|
||||
assert_param(IS_ADC_INPUT_CHANNEL(Monitor->CmpChannel));
|
||||
assert_param(IS_ADC_CMPCNT(Monitor->CmpCnt));
|
||||
assert_param(IS_ADC_CMPCONDITION(Monitor->Condition));
|
||||
assert_param(IS_ADC_CMPMODE(Monitor->CntMode));
|
||||
assert_param(IS_ADC_CMPVALUE_12BIT(Monitor->CmpValue));
|
||||
|
||||
tmp |= (uint32_t) (Monitor->CmpChannel);
|
||||
tmp |= (uint32_t) (Monitor->Condition) << 4U;
|
||||
tmp |= (uint32_t) (Monitor->CntMode) << 5U;
|
||||
tmp |= (uint32_t) (Monitor->CmpCnt - 1U) << 8U;
|
||||
|
||||
if (ADCMPx == ADC_CMPCR_0) {
|
||||
ADx->CMPCR0 = tmp;
|
||||
ADx->CMP0 = Monitor->CmpValue;
|
||||
} else {
|
||||
ADx->CMPCR1 = tmp;
|
||||
ADx->CMP1 = Monitor->CmpValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set hardware trigger for normal AD conversion.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param HWSrc: Hardware source for activating normal AD conversion.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_EXTERADTRG,ADC_INTERTRIGGER
|
||||
* @param NewState: Specify state of hardware source for activating normal AD conversion.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetHWTrg(TSB_AD_TypeDef * ADx, uint32_t HWSrc, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_EXTERADTRG(HWSrc));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD1<ADHWS> */
|
||||
tmp = ADx->MOD1;
|
||||
tmp &= MOD1_ADHWS_CLEAR;
|
||||
tmp |= (HWSrc << 1U);
|
||||
|
||||
/* Set ADMOD1<ADHWE> */
|
||||
if (NewState == ENABLE) {
|
||||
tmp |= MOD1_ADHWE_SET;
|
||||
} else {
|
||||
tmp &= MOD1_ADHWE_CLEAR;
|
||||
}
|
||||
|
||||
ADx->MOD1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set hardware trigger for top-priority AD conversion.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param HWSrc: Hardware source for activating top-priority AD conversion.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_EXTERADTRG,ADC_INTERTRIGGER
|
||||
* @param NewState: Specify state of hardware source for activating top-priority AD conversion.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE or DISABLE.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetHWTrgTop(TSB_AD_TypeDef * ADx, uint32_t HWSrc, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_EXTERADTRG_TOP(HWSrc));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Set ADMOD1<HPADHWS> */
|
||||
tmp = ADx->MOD1;
|
||||
tmp &= MOD1_HPADHWS_CLEAR;
|
||||
tmp |= (HWSrc << 3U);
|
||||
|
||||
/* Set ADMOD1<HPADHWE> */
|
||||
if (NewState == ENABLE) {
|
||||
tmp |= MOD1_HPADHWE_SET;
|
||||
} else {
|
||||
tmp &= MOD1_HPADHWE_CLEAR;
|
||||
}
|
||||
|
||||
ADx->MOD1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read AD conversion completion/busy flag (normal and top-priority).
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @retval A union with the state of AD conversion.
|
||||
*/
|
||||
ADC_State ADC_GetConvertState(TSB_AD_TypeDef * ADx)
|
||||
{
|
||||
ADC_State retval = { 0U };
|
||||
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
|
||||
retval.All = ADx->MOD5;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read AD conversion result.
|
||||
* @param ADx: Select ADC unit.
|
||||
* This parameter can be the following value:
|
||||
* TSB_AD
|
||||
* @param ADREGx: ADC result register.
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_REG_00, ADC_REG_01, ADC_REG_02, ADC_REG_03,
|
||||
* ADC_REG_04, ADC_REG_05, ADC_REG_06, ADC_REG_07,
|
||||
* ADC_REG_SP.
|
||||
* @retval A union with AD result and 2 bits of extra information.
|
||||
*/
|
||||
ADC_Result ADC_GetConvertResult(TSB_AD_TypeDef * ADx, ADC_REGx ADREGx)
|
||||
{
|
||||
ADC_Result retval = { 0U };
|
||||
uint32_t tmpAddr = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_UNIT(ADx));
|
||||
assert_param(IS_ADC_REG(ADREGx));
|
||||
|
||||
if (ADREGx == ADC_REG_SP) {
|
||||
retval.All = ADx->REGSP;
|
||||
} else {
|
||||
tmpAddr = (uint32_t) (&ADx->REG00);
|
||||
tmpAddr += (0x4U * (uint32_t) ADREGx);
|
||||
retval.All = *((uint32_t *) (tmpAddr));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the trigger.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void ADC_EnableTrigger(void)
|
||||
{
|
||||
/* Set TRGSEL<TRGSELEN> to enable trigger */
|
||||
TSB_ADILV_TRGSEL_TRGSELEN = 1U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the trigger.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void ADC_DisableTrigger(void)
|
||||
{
|
||||
/* Set TRGSEL<TRGSELEN> to disable trigger */
|
||||
TSB_ADILV_TRGSEL_TRGSELEN = 0U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Selects a trigger for startup of normal AD conversion
|
||||
* @param TriggerStartup: trigger for startup of normal AD conversion
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_TRG_00, ADC_TRG_01, ADC_TRG_02, ADC_TRG_03,
|
||||
* ADC_TRG_04, ADC_TRG_05, ADC_TRG_06, ADC_TRG_07,
|
||||
* ADC_TRG_08, ADC_TRG_09.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetTriggerStartup(ADC_TRGx TriggerStartup)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_TRG(TriggerStartup));
|
||||
|
||||
/* Set TRGSEL<TRGSEL[3:0]> */
|
||||
tmp = TSB_ADILV->TRGSEL;
|
||||
tmp &= ADILV_TRGSEL_CLEAR;
|
||||
tmp |= ((uint32_t) TriggerStartup << 8U);
|
||||
TSB_ADILV->TRGSEL = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Selects a trigger for startup of top-priority AD conversion
|
||||
* @param TopTriggerStartup: trigger for startup of top-priority AD conversion
|
||||
* This parameter can be one of the following values:
|
||||
* ADC_TRG_00, ADC_TRG_01, ADC_TRG_02, ADC_TRG_03,
|
||||
* ADC_TRG_04, ADC_TRG_05, ADC_TRG_06, ADC_TRG_07,
|
||||
* ADC_TRG_08, ADC_TRG_09.
|
||||
* @retval None.
|
||||
*/
|
||||
void ADC_SetTriggerStartupTop(ADC_TRGx TopTriggerStartup)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ADC_TRG(TopTriggerStartup));
|
||||
|
||||
/* Set TRGSEL<HPTRGSEL[3:0]> */
|
||||
tmp = TSB_ADILV->TRGSEL;
|
||||
tmp &= ADILV_HPTRGSEL_CLEAR;
|
||||
tmp |= ((uint32_t) TopTriggerStartup << 12U);
|
||||
TSB_ADILV->TRGSEL = tmp;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group ADC */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#endif /* defined(__TMPM46B_ADC_H) */
|
||||
1302
targets/TARGET_TOSHIBA/TARGET_TMPM46B/Periph_Driver/src/tmpm46b_cg.c
Normal file
1302
targets/TARGET_TOSHIBA/TARGET_TMPM46B/Periph_Driver/src/tmpm46b_cg.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,306 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46B_esg.c
|
||||
* @brief This file provides API functions for ESG driver.
|
||||
* @version V2.0.2.2
|
||||
* @date 2018/03/15
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------ */
|
||||
#include "tmpm46b_esg.h"
|
||||
|
||||
#if defined(__TMPM46B_ESG_H)
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ESG
|
||||
* @brief ESG driver modules
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup ESG_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
#define ESG_START_SET (0x00000001U)
|
||||
#define ESG_FINTIMING_CLEAR (0xFFFF0000U)
|
||||
#define ESG_FINTIMING_SET (0x0000FFFFU)
|
||||
#define ESG_LATCHTIMING_SET (0x000F0000U)
|
||||
#define ESG_LATCHTIMING_CLEAR (0xFFF0FFFFU)
|
||||
#define ESG_BUSY_SET (0x00000001U)
|
||||
#define ESG_INT_SET (0x00000001U)
|
||||
#define SRST_IPRST_3_SET (0x00000008U)
|
||||
#define SRST_IPRST_3_CLEAR (0xFFFFFFF7U)
|
||||
#define SRST_PROTECT_DISABLE (0x0000006BU)
|
||||
#define SRST_PROTECT_ENABLE (0x00000000U)
|
||||
#define NUM_BLK (16U)
|
||||
|
||||
static const volatile uint32_t *const ESG_Blk[NUM_BLK] = {
|
||||
&TSB_ESG->BLK00, &TSB_ESG->BLK01, &TSB_ESG->BLK02, &TSB_ESG->BLK03,
|
||||
&TSB_ESG->BLK04, &TSB_ESG->BLK05, &TSB_ESG->BLK06, &TSB_ESG->BLK07,
|
||||
&TSB_ESG->BLK08, &TSB_ESG->BLK09, &TSB_ESG->BLK10, &TSB_ESG->BLK11,
|
||||
&TSB_ESG->BLK12, &TSB_ESG->BLK13, &TSB_ESG->BLK14, &TSB_ESG->BLK15
|
||||
};
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG_Private_Defines */
|
||||
|
||||
/** @defgroup ESG_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG_Private_FunctionPrototypes */
|
||||
|
||||
/** @defgroup ESG_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG_Private_Functions */
|
||||
|
||||
/** @defgroup ESG_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Start-up ESG operation.
|
||||
* @param None
|
||||
* @retval The value returned can be one of the following values:
|
||||
* SUCCESS or ERROR
|
||||
* @register The used registers:
|
||||
* ESGCR<START>
|
||||
*/
|
||||
Result ESG_Startup(void)
|
||||
{
|
||||
Result retval = ERROR;
|
||||
|
||||
if (ESG_GetCalculationStatus() == ESG_CALCULATION_COMPLETE) {
|
||||
/* Write '1' to ESGCR<START> to enable */
|
||||
TSB_ESG->CR = ESG_START_SET;
|
||||
retval = SUCCESS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set entropy seed latch timing.
|
||||
* @param Value: The latch timing for ESG
|
||||
* This parameter can be one of the following values:
|
||||
* ESG_LATCH_TIMING_1, ESG_LATCH_TIMING_2, ESG_LATCH_TIMING_3,
|
||||
* ESG_LATCH_TIMING_4, ESG_LATCH_TIMING_5, ESG_LATCH_TIMING_6,
|
||||
* ESG_LATCH_TIMING_7, ESG_LATCH_TIMING_8, ESG_LATCH_TIMING_9,
|
||||
* ESG_LATCH_TIMING_10, ESG_LATCH_TIMING_11, ESG_LATCH_TIMING_12,
|
||||
* ESG_LATCH_TIMING_13, ESG_LATCH_TIMING_14, ESG_LATCH_TIMING_15,
|
||||
* ESG_LATCH_TIMING_16.
|
||||
* @retval The value returned can be one of the following values:
|
||||
* SUCCESS or ERROR
|
||||
* @register The used registers:
|
||||
* ESGOUTCR<LATCHTIMING[19:16]>
|
||||
*/
|
||||
Result ESG_SetLatchTiming(ESG_LatchTiming Value)
|
||||
{
|
||||
/* Read OUTCR, keep bit 15 to 0, clear bit 19 to 16 */
|
||||
uint32_t tmp = TSB_ESG->OUTCR & ESG_LATCHTIMING_CLEAR;
|
||||
Result retval = ERROR;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_ESG_LATCH_TIMING(Value));
|
||||
|
||||
if (ESG_GetCalculationStatus() == ESG_CALCULATION_COMPLETE) {
|
||||
tmp |= (uint32_t) Value << 16;
|
||||
TSB_ESG->OUTCR = tmp;
|
||||
retval = SUCCESS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get entropy seed latch timing.
|
||||
* @param None
|
||||
* @retval tmp: the value of entropy seed latch timing
|
||||
* @register The used registers:
|
||||
* ESGOUTCR<LATCHTIMING[19:16]>
|
||||
*/
|
||||
uint32_t ESG_GetLatchTiming(void)
|
||||
{
|
||||
uint32_t tmp;
|
||||
|
||||
tmp = (TSB_ESG->OUTCR & ESG_LATCHTIMING_SET) >> 16;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Entropy seed output timing.
|
||||
* @param Fintming: the value of entropy seed output timing
|
||||
* @retval The value returned can be one of the following values:
|
||||
* SUCCESS or ERROR
|
||||
* @register The used registers:
|
||||
* ESGOUTCR<FINTIMING[15:0]>
|
||||
*/
|
||||
Result ESG_SetFintiming(uint16_t Fintming)
|
||||
{
|
||||
/* Read OUTCR, keep bit 19 to 16, clear bit 15 to 0 */
|
||||
uint32_t tmp = TSB_ESG->OUTCR & ESG_FINTIMING_CLEAR;
|
||||
Result retval = ERROR;
|
||||
|
||||
/* Get latchtiming value */
|
||||
uint16_t latchtiming = (uint16_t) ESG_GetLatchTiming();
|
||||
|
||||
if (ESG_GetCalculationStatus() == ESG_CALCULATION_COMPLETE) {
|
||||
if (Fintming >= 512U * (latchtiming + 1U) + 3U) {
|
||||
tmp |= (uint32_t) Fintming;
|
||||
TSB_ESG->OUTCR = tmp;
|
||||
retval = SUCCESS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get entropy seed Fintiming.
|
||||
* @param None
|
||||
* @retval tmp: the value of entropy seed Fintiming
|
||||
* @register The used registers:
|
||||
* ESGOUTCR<FINTIMING[15:0]>
|
||||
*/
|
||||
uint16_t ESG_GetFintiming(void)
|
||||
{
|
||||
uint16_t tmp;
|
||||
|
||||
tmp = (uint16_t) TSB_ESG->OUTCR & ESG_FINTIMING_SET;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the ESG interrupt.
|
||||
* @param None
|
||||
* @retval The value returned can be one of the following values:
|
||||
* SUCCESS or ERROR
|
||||
* @register The used registers:
|
||||
* ESGINT<INT>
|
||||
*/
|
||||
Result ESG_ClrInt(void)
|
||||
{
|
||||
Result retval = ERROR;
|
||||
|
||||
if (ESG_GetCalculationStatus() == ESG_CALCULATION_COMPLETE) {
|
||||
/* Write '1' to ESGINT<INT> to clear the interrupt */
|
||||
TSB_ESG->INT = ESG_INT_SET;
|
||||
retval = SUCCESS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the ESG interrupt status.
|
||||
* @param None
|
||||
* @retval The value returned can be one of the following values:
|
||||
* ENABLE: interrupt occurs
|
||||
* DISABLE: no interrupt
|
||||
* @register The used registers:
|
||||
* ESGINT<INT>
|
||||
*/
|
||||
FunctionalState ESG_GetIntStatus(void)
|
||||
{
|
||||
FunctionalState retval = DISABLE;
|
||||
|
||||
if (TSB_ESG->INT == ESG_INT_SET) {
|
||||
retval = ENABLE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset ESG by peripheral function.
|
||||
* @param None
|
||||
* @retval None
|
||||
* @register The used register:
|
||||
* SRSTIPRST<IPRST3>
|
||||
* SRSTPROTECT
|
||||
*/
|
||||
void ESG_IPReset(void)
|
||||
{
|
||||
/* Disable write protection state of SRSTIPRST */
|
||||
TSB_SRST->PROTECT = SRST_PROTECT_DISABLE;
|
||||
|
||||
TSB_SRST->IPRST |= SRST_IPRST_3_SET;
|
||||
|
||||
/* Release reset state */
|
||||
TSB_SRST->IPRST &= SRST_IPRST_3_CLEAR;
|
||||
|
||||
/* Enable write protection state of SRSTIPRST */
|
||||
TSB_SRST->PROTECT = SRST_PROTECT_ENABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the calculation status.
|
||||
* @param None
|
||||
* @retval The calculation status.
|
||||
* The value returned can be one of the following values:
|
||||
* ESG_CALCULATION_COMPLETE, ESG_CALCULATION_PROCESS.
|
||||
* @note Do not write any value to ESG registers when calculation is in process.
|
||||
* @register The used register:
|
||||
* ESGST<BUSY>
|
||||
*/
|
||||
ESG_CalculationStatus ESG_GetCalculationStatus(void)
|
||||
{
|
||||
ESG_CalculationStatus retval = ESG_CALCULATION_COMPLETE;
|
||||
|
||||
if (TSB_ESG->ST == ESG_BUSY_SET) {
|
||||
retval = ESG_CALCULATION_PROCESS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the calculation result.
|
||||
* @param Seed[16U]: A point that points to the value of calculation result.
|
||||
* @retval None
|
||||
* @register The used registers:
|
||||
* ESGBLK00 to ESGBLK15
|
||||
*/
|
||||
void ESG_GetResult(uint32_t Seed[NUM_BLK])
|
||||
{
|
||||
uint32_t i = 0U;
|
||||
|
||||
for (i = 0U; i < NUM_BLK; i++) {
|
||||
Seed[i] = *ESG_Blk[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group ESG */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
#endif /* defined(__TMPM46B_ESG_H) */
|
||||
1129
targets/TARGET_TOSHIBA/TARGET_TMPM46B/Periph_Driver/src/tmpm46b_fc.c
Normal file
1129
targets/TARGET_TOSHIBA/TARGET_TMPM46B/Periph_Driver/src/tmpm46b_fc.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,881 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46B_fuart.c
|
||||
* @brief This file provides API functions for Full UART driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/26
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_fuart.h"
|
||||
|
||||
#if defined(__TMPM46B_FUART_H)
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FUART
|
||||
* @brief FUART driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FUART_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
#define CR_UARTEN_SET ((uint32_t)0x00000001)
|
||||
#define CR_UARTEN_CLEAR ((uint32_t)0xFFFFFF7E)
|
||||
|
||||
#define RSR_ERROR_MASK ((uint32_t)0x0000000F)
|
||||
#define RSR_FERR_FLAG ((uint32_t)0x00000001)
|
||||
#define RSR_PERR_FLAG ((uint32_t)0x00000002)
|
||||
#define RSR_BERR_FLAG ((uint32_t)0x00000004)
|
||||
#define RSR_OERR_FLAG ((uint32_t)0x00000008)
|
||||
|
||||
#define ECR_ERROR_CLEAR ((uint32_t)0x00000000)
|
||||
|
||||
#define FR_BUSY_FLAG ((uint32_t)0x00000008)
|
||||
|
||||
#define LCR_H_FIFO_EN_FLAG ((uint32_t)0x00000010)
|
||||
#define LCR_H_FIFO_EN_SET ((uint32_t)0x00000010)
|
||||
#define LCR_H_FIFO_EN_CLEAR ((uint32_t)0xFFFFFFEF)
|
||||
#define FR_TX_STORAGE_MASK ((uint32_t)0x000000A0)
|
||||
#define FR_RX_STORAGE_MASK ((uint32_t)0x00000050)
|
||||
|
||||
#define FR_TX_STORAGE_NORMAL ((uint32_t)0x00000000)
|
||||
#define FR_TX_STORAGE_FULL ((uint32_t)0x00000020)
|
||||
#define FR_TX_STORAGE_EMPTY ((uint32_t)0x00000080)
|
||||
#define FR_TX_STORAGE_INVALID ((uint32_t)0x000000A0)
|
||||
|
||||
#define FR_RX_STORAGE_NORMAL ((uint32_t)0x00000000)
|
||||
#define FR_RX_STORAGE_EMPTY ((uint32_t)0x00000010)
|
||||
#define FR_RX_STORAGE_FULL ((uint32_t)0x00000040)
|
||||
#define FR_RX_STORAGE_INVALID ((uint32_t)0x00000050)
|
||||
|
||||
#define LCR_H_WLEN_MASK ((uint32_t)0xFFFFFF9F)
|
||||
#define LCR_H_STP2_MASK ((uint32_t)0xFFFFFFF7)
|
||||
#define LCR_H_PARITY_MASK ((uint32_t)0xFFFFFF79)
|
||||
#define CR_FLOW_CTRL_MASK ((uint32_t)0x00000F07)
|
||||
#define CR_MODE_MASK ((uint32_t)0x0000CC07)
|
||||
|
||||
#define LCR_H_BRK_SET ((uint32_t)0x00000001)
|
||||
#define LCR_H_BRK_CLEAR ((uint32_t)0xFFFFFFFE)
|
||||
|
||||
#define CR_SIRLP_MASK ((uint32_t)0xFFFFFFFB)
|
||||
|
||||
#define CR_UARTEN_MASK ((uint32_t)0x00000001)
|
||||
#define CR_SIREN_SET ((uint32_t)0x00000002)
|
||||
#define CR_SIREN_CLEAR ((uint32_t)0xFFFFFFFD)
|
||||
|
||||
#define FUART_INT_BITS ((uint32_t)0x000007FF)
|
||||
|
||||
#define DMACR_DMAONERR_CLEAR ((uint32_t)0x00000003)
|
||||
#define DMACR_DMAONERR_SET ((uint32_t)0x00000004)
|
||||
|
||||
#define DMACR_TXDMAE_CLEAR ((uint32_t)0x00000005)
|
||||
#define DMACR_TXDMAE_SET ((uint32_t)0x00000002)
|
||||
#define DMACR_RXDMAE_CLEAR ((uint32_t)0x00000006)
|
||||
#define DMACR_RXDMAE_SET ((uint32_t)0x00000001)
|
||||
|
||||
#define FR_MODEM_STATUS_MASK ((uint32_t)0x00000107)
|
||||
#define CR_MODEM_STATUS_MASK ((uint32_t)0x00000C00)
|
||||
|
||||
#define CR_RTS_OUTPUT_0 ((uint32_t)0x00000800)
|
||||
#define CR_RTS_OUTPUT_1 ((uint32_t)0xFFFFF77F)
|
||||
|
||||
#define CR_DTR_OUTPUT_0 ((uint32_t)0x00000400)
|
||||
#define CR_DTR_OUTPUT_1 ((uint32_t)0xFFFFFB7F)
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Private_Defines */
|
||||
|
||||
/** @defgroup FUART_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Private_FunctionPrototypes */
|
||||
|
||||
/** @defgroup FUART_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Private_Functions */
|
||||
|
||||
/** @defgroup FUART_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_Enable(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
tmp = FUARTx->CR | CR_UARTEN_SET;
|
||||
FUARTx->CR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_Disable(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
FUARTx->CR &= CR_UARTEN_CLEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get received data from the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval The data received from FUARTx
|
||||
*/
|
||||
uint32_t FUART_GetRxData(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t retval = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
/* Return received data */
|
||||
retval = FUARTx->DR & 0xFFU;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set data to be sent and start transmitting via the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Data: The data to be sent.
|
||||
* The Data range is 0x00 to 0xFF.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetTxData(TSB_FUART_TypeDef * FUARTx, uint32_t Data)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_DATA(Data));
|
||||
|
||||
FUARTx->DR = Data & 0xFFU;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get receive error status.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval The error flag.
|
||||
* The value returned can be one of the followings:
|
||||
* FUART_NO_ERR, FUART_OVERRUN, FUART_PARITY_ERR,
|
||||
* FUART_FRAMING_ERR, FUART_BREAK_ERR, FUART_ERRS.
|
||||
*/
|
||||
FUART_Err FUART_GetErrStatus(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
FUART_Err retval = FUART_NO_ERR;
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
tmp = (FUARTx->RSR & RSR_ERROR_MASK);
|
||||
switch (tmp) {
|
||||
case RSR_FERR_FLAG: /* Check overrun flag */
|
||||
retval = FUART_FRAMING_ERR;
|
||||
break;
|
||||
case RSR_PERR_FLAG: /* Check parity flag */
|
||||
retval = FUART_PARITY_ERR;
|
||||
break;
|
||||
case RSR_BERR_FLAG: /* Check break flag */
|
||||
retval = FUART_BREAK_ERR;
|
||||
break;
|
||||
case RSR_OERR_FLAG: /* Check overrun flag */
|
||||
retval = FUART_OVERRUN;
|
||||
break;
|
||||
default:
|
||||
if (tmp != 0U) {
|
||||
/* more than one error */
|
||||
retval = FUART_ERRS;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear receive error status.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_ClearErrStatus(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
/* Clear the receive error status */
|
||||
FUARTx->ECR &= ECR_ERROR_CLEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the state that whether the specified Full UART channel
|
||||
* is transmitting data or stopped.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval The work state of specified Full UART channel
|
||||
* This parameter can be one of the following values:
|
||||
* BUSY: The Full UART is transmitting data
|
||||
* DONE: The Full UART has stopped transmitting data
|
||||
*/
|
||||
WorkState FUART_GetBusyState(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
WorkState retval = DONE;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
tmp = FUARTx->FR & FR_BUSY_FLAG;
|
||||
|
||||
/* Check busy flag */
|
||||
if (tmp == FR_BUSY_FLAG) {
|
||||
retval = BUSY;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the FIFO or hold register status.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Direction: The direction of Full UART.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_RX, FUART_TX
|
||||
* @retval The storage status.
|
||||
* When FIFO is enabled, FUART_StorageStatus indicates the FIFO status.
|
||||
* When FIFO is disabled, FUART_StorageStatus indicates the hold register status.
|
||||
*/
|
||||
FUART_StorageStatus FUART_GetStorageStatus(TSB_FUART_TypeDef * FUARTx, FUART_Direction Direction)
|
||||
{
|
||||
uint32_t fen = 0U;
|
||||
uint32_t src = 0U;
|
||||
FUART_StorageStatus retval = FUART_STORAGE_EMPTY;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_DIRECTION(Direction));
|
||||
|
||||
fen = FUARTx->LCR_H & LCR_H_FIFO_EN_FLAG;
|
||||
src = FUARTx->FR;
|
||||
if (fen == LCR_H_FIFO_EN_FLAG) { /* FIFO mode */
|
||||
if (Direction == FUART_TX) { /* Get Transmit FIFO status */
|
||||
src = FUARTx->FR & FR_TX_STORAGE_MASK;
|
||||
switch (src) {
|
||||
case FR_TX_STORAGE_NORMAL:
|
||||
retval = FUART_STORAGE_NORMAL;
|
||||
break;
|
||||
case FR_TX_STORAGE_FULL:
|
||||
retval = FUART_STORAGE_FULL;
|
||||
break;
|
||||
case FR_TX_STORAGE_EMPTY:
|
||||
retval = FUART_STORAGE_EMPTY;
|
||||
break;
|
||||
case FR_TX_STORAGE_INVALID:
|
||||
retval = FUART_STORAGE_INVALID;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
} else { /* Get Receive FIFO status */
|
||||
src = FUARTx->FR & FR_RX_STORAGE_MASK;
|
||||
switch (src) {
|
||||
case FR_RX_STORAGE_NORMAL:
|
||||
retval = FUART_STORAGE_NORMAL;
|
||||
break;
|
||||
case FR_RX_STORAGE_EMPTY:
|
||||
retval = FUART_STORAGE_EMPTY;
|
||||
break;
|
||||
case FR_RX_STORAGE_FULL:
|
||||
retval = FUART_STORAGE_FULL;
|
||||
break;
|
||||
case FR_RX_STORAGE_INVALID:
|
||||
retval = FUART_STORAGE_INVALID;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { /* character mode */
|
||||
if (Direction == FUART_TX) { /* Get Transmit hold register status */
|
||||
src = FUARTx->FR & FR_TX_STORAGE_MASK;
|
||||
switch (src) {
|
||||
case FR_TX_STORAGE_NORMAL:
|
||||
case FR_TX_STORAGE_INVALID:
|
||||
retval = FUART_STORAGE_INVALID;
|
||||
break;
|
||||
case FR_TX_STORAGE_FULL:
|
||||
retval = FUART_STORAGE_FULL;
|
||||
break;
|
||||
case FR_TX_STORAGE_EMPTY:
|
||||
retval = FUART_STORAGE_EMPTY;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
} else { /* Get Receive hold register status */
|
||||
src = FUARTx->FR & FR_RX_STORAGE_MASK;
|
||||
switch (src) {
|
||||
case FR_RX_STORAGE_NORMAL:
|
||||
case FR_RX_STORAGE_INVALID:
|
||||
retval = FUART_STORAGE_INVALID;
|
||||
break;
|
||||
case FR_RX_STORAGE_EMPTY:
|
||||
retval = FUART_STORAGE_EMPTY;
|
||||
break;
|
||||
case FR_RX_STORAGE_FULL:
|
||||
retval = FUART_STORAGE_FULL;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set IrDA lower-power divisor.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Divisor: The IrDA Low-power divisor (from 0x01 to 0xFF)
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetIrDADivisor(TSB_FUART_TypeDef * FUARTx, uint32_t Divisor)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_IRDA_DIVISOR(Divisor));
|
||||
|
||||
FUARTx->ILPR = Divisor & 0xFFU;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize and configure the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param InitStruct: The structure containing basic Full UART configuration
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_Init(TSB_FUART_TypeDef * FUARTx, FUART_InitTypeDef * InitStruct)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
uint32_t fuartclk = 0U;
|
||||
uint32_t ibd = 0U; /* Integer part of baud rate divisor */
|
||||
uint32_t fbd = 0U; /* Fractional part of baud rate divisor */
|
||||
uint32_t br = InitStruct->BaudRate; /* BaudRate */
|
||||
/* Check the parameters */
|
||||
assert_param(IS_POINTER_NOT_NULL(InitStruct));
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_BAUDRATE(InitStruct->BaudRate));
|
||||
assert_param(IS_FUART_DATA_BITS(InitStruct->DataBits));
|
||||
assert_param(IS_FUART_STOPBITS(InitStruct->StopBits));
|
||||
assert_param(IS_FUART_PARITY(InitStruct->Parity));
|
||||
assert_param(IS_FUART_MODE(InitStruct->Mode));
|
||||
assert_param(IS_FUART_FLOW_CTRL(InitStruct->FlowCtrl));
|
||||
|
||||
/* Get UARTCLK */
|
||||
SystemCoreClockUpdate();
|
||||
fuartclk = SystemCoreClock; /* UARTCLK = fsys */
|
||||
|
||||
ibd = fuartclk / (16U * br);
|
||||
fbd = (8U * fuartclk + br - 128U * ibd * br) / (2U * br);
|
||||
|
||||
if (fbd == 0U) {
|
||||
fbd = 1U; /* Fractional part of baud rate divisor can not be 0x00 */
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
FUARTx->IBRD = ibd; /* Set integer part of baud rate divisor */
|
||||
FUARTx->FBRD = fbd; /* Set fractional part of baud rate divisor */
|
||||
|
||||
tmp = FUARTx->LCR_H;
|
||||
|
||||
tmp &= LCR_H_WLEN_MASK;
|
||||
tmp |= InitStruct->DataBits;
|
||||
|
||||
tmp &= LCR_H_STP2_MASK;
|
||||
tmp |= InitStruct->StopBits;
|
||||
|
||||
tmp &= LCR_H_PARITY_MASK;
|
||||
tmp |= InitStruct->Parity;
|
||||
|
||||
FUARTx->LCR_H = tmp; /* Set DataBits, StopBits, Parity */
|
||||
|
||||
tmp = FUARTx->CR;
|
||||
tmp &= CR_FLOW_CTRL_MASK;
|
||||
tmp |= InitStruct->FlowCtrl;
|
||||
|
||||
tmp &= CR_MODE_MASK;
|
||||
tmp |= InitStruct->Mode;
|
||||
|
||||
FUARTx->CR = tmp; /* Set Flow Control, Mode */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the transmit and receive FIFO.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_EnableFIFO(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
FUARTx->LCR_H |= LCR_H_FIFO_EN_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the transmit and receive FIFO and the mode will be changed to character mode.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_DisableFIFO(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
FUARTx->LCR_H &= LCR_H_FIFO_EN_CLEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate the break condition for Full UART.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param NewState: New state of the FUART Send break.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetSendBreak(TSB_FUART_TypeDef * FUARTx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set UARTxLCR_H<BRK> to enable the send break to generate transmit break condition */
|
||||
FUARTx->LCR_H |= LCR_H_BRK_SET;
|
||||
} else {
|
||||
/* Clear UARTxLCR_H<BRK> to disable the send break */
|
||||
FUARTx->LCR_H &= LCR_H_BRK_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select IrDA encoding mode for transmitting 0 bits.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Mode: IrDA encoding mode select for transmitting 0 bits.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_IRDA_3_16_BIT_PERIOD_MODE
|
||||
* FUART_IRDA_3_TIMES_IRLPBAUD16_MODE
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetIrDAEncodeMode(TSB_FUART_TypeDef * FUARTx, uint32_t Mode)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_IRDA_ENCODE_MODE(Mode));
|
||||
|
||||
/* read UARTCR register then clear bit<SIRLP> as FUART_IRDA_3_16_BIT_PERIOD_MODE */
|
||||
tmp = FUARTx->CR & CR_SIRLP_MASK;
|
||||
|
||||
if (Mode == FUART_IRDA_3_TIMES_IRLPBAUD16_MODE) {
|
||||
/* Set mode as FUART_IRDA_3_TIMES_IRLPBAUD16_MODE */
|
||||
tmp |= FUART_IRDA_3_TIMES_IRLPBAUD16_MODE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
FUARTx->CR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the IrDA circuit
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval The result of enabling IrDA circuit
|
||||
* This parameter can be one of the following values:
|
||||
* SUCCESS: Enable IrDA circuit successfully.
|
||||
* ERROR: The UART channel is disabled, can not enable IrDA circuit.
|
||||
*/
|
||||
Result FUART_EnableIrDA(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
Result retval = SUCCESS;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
/* Get UARTCR<UARTEN> to check if Full UART channel is enabled */
|
||||
tmp = FUARTx->CR & CR_UARTEN_MASK;
|
||||
|
||||
if (tmp == CR_UARTEN_SET) { /* Full UART is enabled */
|
||||
tmp = FUARTx->CR | CR_SIREN_SET;
|
||||
FUARTx->CR = tmp;
|
||||
} else { /* Full UART is disabled */
|
||||
retval = ERROR; /* Can not enable IrDA circuit */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the IrDA circuit
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_DisableIrDA(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
/* Get UARTCR<UARTEN> to check if Full UART channel is enabled */
|
||||
tmp = FUARTx->CR & CR_UARTEN_MASK;
|
||||
|
||||
if (tmp == CR_UARTEN_SET) { /* Full UART is enabled */
|
||||
tmp = FUARTx->CR & CR_SIREN_CLEAR;
|
||||
FUARTx->CR = tmp;
|
||||
} else { /* Full UART is disabled */
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Receive and Transmit interrupt FIFO level.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param RxLevel: Receive interrupt FIFO level.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_RX_FIFO_LEVEL_4: The data in Receive FIFO become >= 4 words
|
||||
* FUART_RX_FIFO_LEVEL_8: The data in Receive FIFO become >= 8 words
|
||||
* FUART_RX_FIFO_LEVEL_16: The data in Receive FIFO become >= 16 words
|
||||
* FUART_RX_FIFO_LEVEL_24: The data in Receive FIFO become >= 24 words
|
||||
* FUART_RX_FIFO_LEVEL_28: The data in Receive FIFO become >= 28 words
|
||||
* @param TxLevel: Transmit interrupt FIFO level.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_TX_FIFO_LEVEL_4: The data in Transmit FIFO become <= 4 words
|
||||
* FUART_TX_FIFO_LEVEL_8: The data in Transmit FIFO become <= 8 words
|
||||
* FUART_TX_FIFO_LEVEL_16: The data in Transmit FIFO become <= 16 words
|
||||
* FUART_TX_FIFO_LEVEL_24: The data in Transmit FIFO become <= 24 words
|
||||
* FUART_TX_FIFO_LEVEL_28: The data in Transmit FIFO become <= 28 words
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetINTFIFOLevel(TSB_FUART_TypeDef * FUARTx, uint32_t RxLevel, uint32_t TxLevel)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_RX_FIFO_LEVEL(RxLevel));
|
||||
assert_param(IS_FUART_TX_FIFO_LEVEL(TxLevel));
|
||||
|
||||
tmp = RxLevel | TxLevel;
|
||||
|
||||
FUARTx->IFLS = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mask(Enable) interrupt source of the specified channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param IntMaskSrc: The interrupt source to be masked(enabled).
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetINTMask(TSB_FUART_TypeDef * FUARTx, uint32_t IntMaskSrc)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_INT_MASK_SRC(IntMaskSrc));
|
||||
|
||||
FUARTx->IMSC = IntMaskSrc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the mask(enable) setting for each interrupt source.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval A data with union that it indicates the mask setting.
|
||||
*/
|
||||
FUART_INTStatus FUART_GetINTMask(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
FUART_INTStatus retval = { 0U };
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
retval.All = FUARTx->IMSC & FUART_INT_BITS;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the raw interrupt status of the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval A data with union that indicates the raw interrupt status.
|
||||
*/
|
||||
FUART_INTStatus FUART_GetRawINTStatus(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
FUART_INTStatus retval = { 0U };
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
retval.All = FUARTx->RIS & FUART_INT_BITS;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the masked interrupt status of the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval A data with union that indicates the masked interrupt status.
|
||||
*/
|
||||
FUART_INTStatus FUART_GetMaskedINTStatus(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
FUART_INTStatus retval = { 0U };
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
retval.All = FUARTx->MIS & FUART_INT_BITS;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the interrupts of the specified Full UART channel.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param INTStatus: A data with union that indicates the interrupts to be cleared.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_ClearINT(TSB_FUART_TypeDef * FUARTx, FUART_INTStatus INTStatus)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_INT_MASK_SRC(INTStatus.All));
|
||||
|
||||
FUARTx->ICR = INTStatus.All;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the DMA receive request output
|
||||
* on assertion of a UART error interrupt.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param NewState: New state of the DMA receive request output
|
||||
* on assertion of a UART error interrupt.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetDMAOnErr(TSB_FUART_TypeDef * FUARTx, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* read UARTDMACR then clear bit2 as disable it */
|
||||
tmp = FUARTx->DMACR & DMACR_DMAONERR_CLEAR;
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* if enable, Set bit2: UARTDMACR<DMAONERR> */
|
||||
tmp |= DMACR_DMAONERR_SET;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
FUARTx->DMACR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or Disable the Transmit FIFO DMA or Receive FIFO DMA.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Direction: The direction of Full UART.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_RX, FUART_TX
|
||||
* @param NewState: New state of Transmit or Receive FIFO DMA.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetFIFODMA(TSB_FUART_TypeDef * FUARTx, FUART_Direction Direction,
|
||||
FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_FUART_DIRECTION(Direction));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Direction == FUART_TX) { /* Configure Transmit FIFO DMA */
|
||||
tmp = FUARTx->DMACR & DMACR_TXDMAE_CLEAR;
|
||||
if (NewState == ENABLE) {
|
||||
/* if enable, Set bit1: UARTDMACR<TXDMAE> */
|
||||
tmp |= DMACR_TXDMAE_SET;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
} else { /* Configure Receive FIFO DMA */
|
||||
tmp = FUARTx->DMACR & DMACR_RXDMAE_CLEAR;
|
||||
if (NewState == ENABLE) {
|
||||
/* if enable, Set bit0: UARTDMACR<RXDMAE> */
|
||||
tmp |= DMACR_RXDMAE_SET;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
FUARTx->DMACR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get all the Modem Status, include: CTS, DSR, DCD, RIN, DTR, and RTS.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @retval A data with union that indicates all the modem status.
|
||||
*/
|
||||
FUART_AllModemStatus FUART_GetModemStatus(TSB_FUART_TypeDef * FUARTx)
|
||||
{
|
||||
uint32_t tmpfr = 0U;
|
||||
uint32_t tmpcr = 0U;
|
||||
FUART_AllModemStatus retval = { 0U };
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
|
||||
tmpfr = FUARTx->FR & FR_MODEM_STATUS_MASK; /* Get RI, DCD, DSR, CTS status */
|
||||
tmpcr = FUARTx->CR & CR_MODEM_STATUS_MASK; /* Get RTS,DTS status */
|
||||
|
||||
tmpfr |= tmpcr;
|
||||
retval.All = tmpfr;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Full UART RTS(Request To Send) modem status output.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Status: RTS modem status output.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_MODEM_STATUS_0: The modem status output is 0
|
||||
* FUART_MODEM_STATUS_1: The modem status output is 1
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetRTSStatus(TSB_FUART_TypeDef * FUARTx, FUART_ModemStatus Status)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_MODEM_STATUS(Status));
|
||||
|
||||
if (Status == FUART_MODEM_STATUS_1) {
|
||||
/* Set UARTxCR<RTS> to make RTS modem status output be 1 */
|
||||
FUARTx->CR &= CR_RTS_OUTPUT_1;
|
||||
} else {
|
||||
/* Set UARTxCR<RTS> to make RTS modem status output be 0 */
|
||||
tmp = FUARTx->CR | CR_RTS_OUTPUT_0;
|
||||
FUARTx->CR = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Full UART DTR(Data Transmit Ready) modem status output.
|
||||
* @param FUARTx: Select the Full UART channel.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART0, FUART1.
|
||||
* @param Status: DTR modem status output.
|
||||
* This parameter can be one of the following values:
|
||||
* FUART_MODEM_STATUS_0: The modem status output is 0
|
||||
* FUART_MODEM_STATUS_1: The modem status output is 1
|
||||
* @retval None
|
||||
*/
|
||||
void FUART_SetDTRStatus(TSB_FUART_TypeDef * FUARTx, FUART_ModemStatus Status)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_FUART_PERIPH(FUARTx));
|
||||
assert_param(IS_MODEM_STATUS(Status));
|
||||
|
||||
if (Status == FUART_MODEM_STATUS_1) {
|
||||
/* Set UARTxCR<DTR> to make DTR modem status output be 1 */
|
||||
FUARTx->CR &= CR_DTR_OUTPUT_1;
|
||||
} else {
|
||||
/* Set UARTxCR<DTR> to make DTR modem status output be 0 */
|
||||
tmp = FUARTx->CR | CR_DTR_OUTPUT_0;
|
||||
FUARTx->CR = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group FUART */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#endif /* defined(__TMPM46B_FUART_H) */
|
||||
@@ -0,0 +1,659 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_gpio.c
|
||||
* @brief This file provides API functions for GPIO driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/09
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_gpio.h"
|
||||
|
||||
#if defined(__TMPM46B_GPIO_H)
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup GPIO
|
||||
* @brief GPIO driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define GPIO_NUM (11U) /* total number of gpio */
|
||||
|
||||
/**
|
||||
* @brief the base address of GPIO port.
|
||||
*/
|
||||
const uint32_t GPIO_Base[GPIO_NUM] = {
|
||||
TSB_PA_BASE, TSB_PB_BASE, TSB_PC_BASE, TSB_PD_BASE, TSB_PE_BASE,
|
||||
TSB_PF_BASE, TSB_PG_BASE, TSB_PH_BASE, TSB_PJ_BASE, TSB_PK_BASE,
|
||||
TSB_PL_BASE
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief:Information of gpio port.
|
||||
* Note: for bit0 to bit7 of each member below, its value '0' or '1' has the means:
|
||||
* '0': that bit is not available
|
||||
* '1': that bit is available
|
||||
* For example, if DATA = 0x7F, it mean the bit0 to bit6 of DATA register are available.
|
||||
*/
|
||||
const GPIO_RegTypeDef GPIO_SFRs[GPIO_NUM] = {
|
||||
/* DATA CR FR1 FR2 FR3 FR4 FR5 FR6 OD PUP PDN IE */
|
||||
/* PA */ {0xFFU, 0xFFU, {0xFFU, 0xFFU, 0xE0U, 0x80U, 0x80U, 0x00U}, 0xFFU, 0xFBU, 0x04U, 0xFFU},
|
||||
/* PB */ {0xFFU, 0xFFU, {0x7FU, 0x40U, 0x3FU, 0x4CU, 0xFCU, 0x00U}, 0xFFU, 0xFFU, 0x00U, 0xBFU},
|
||||
/* PC */ {0x3FU, 0x3FU, {0x3CU, 0x20U, 0x00U, 0x00U, 0x00U, 0x00U}, 0x3FU, 0x3FU, 0x00U, 0x3FU},
|
||||
/* PD */ {0x1FU, 0x1FU, {0x1FU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U}, 0x1FU, 0x1FU, 0x00U, 0x1FU},
|
||||
/* PE */ {0xFFU, 0xFFU, {0x7EU, 0x00U, 0xFFU, 0x18U, 0x9FU, 0x00U}, 0xFFU, 0xFFU, 0x00U, 0xFFU},
|
||||
/* PF */ {0xFFU, 0xFFU, {0xFFU, 0x00U, 0xFFU, 0xC6U, 0x78U, 0x00U}, 0xFFU, 0xFFU, 0x00U, 0xFFU},
|
||||
/* PG */ {0xFFU, 0xFFU, {0xFFU, 0x00U, 0x0FU, 0x0CU, 0xFFU, 0x00U}, 0xFFU, 0xFFU, 0x00U, 0xFFU},
|
||||
/* PH */ {0x0FU, 0x0FU, {0x0FU, 0x03U, 0x0FU, 0x0FU, 0x00U, 0x00U}, 0x0FU, 0x0FU, 0x00U, 0x0FU},
|
||||
/* PJ */ {0xFFU, 0xFFU, {0x80U, 0x80U, 0x80U, 0x00U, 0x00U, 0x00U}, 0xFFU, 0xFFU, 0x00U, 0xFFU},
|
||||
/* PK */ {0x1FU, 0x1FU, {0x00U, 0x1EU, 0x0CU, 0x02U, 0x00U, 0x00U}, 0x1FU, 0x1FU, 0x00U, 0x1FU},
|
||||
/* PL */ {0x0FU, 0x0FU, {0x00U, 0x00U, 0x0FU, 0x0DU, 0x0EU, 0x08U}, 0x0FU, 0x0FU, 0x00U, 0x0FU}
|
||||
};
|
||||
|
||||
/** @defgroup GPIO_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Read GPIO Data register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL
|
||||
* @retval Data:The value of DATA register.
|
||||
*/
|
||||
uint8_t GPIO_ReadData(GPIO_Port GPIO_x)
|
||||
{
|
||||
uint8_t Data = 0U;
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
Data = (uint8_t) PORT->DATA;
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read Bit of GPIO Data register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7.
|
||||
* @retval BitValue:The value of specified Bit.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_VALUE_0, GPIO_BIT_VALUE_1
|
||||
*/
|
||||
uint8_t GPIO_ReadDataBit(GPIO_Port GPIO_x, uint8_t Bit_x)
|
||||
{
|
||||
uint8_t Data = 0U;
|
||||
uint8_t tmp = 0U;
|
||||
uint8_t BitValue = 0U;
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_GPIO_BIT(Bit_x));
|
||||
assert_param(IS_GPIO_BIT_DATA(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
Data = (uint8_t) PORT->DATA;
|
||||
tmp = (uint8_t) (Data & Bit_x);
|
||||
if (tmp) {
|
||||
BitValue = GPIO_BIT_VALUE_1;
|
||||
} else {
|
||||
BitValue = GPIO_BIT_VALUE_0;
|
||||
}
|
||||
|
||||
return (BitValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write specified value to GPIO DATA register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Data: specified value will be written to GPIO DATA register.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_WriteData(GPIO_Port GPIO_x, uint8_t Data)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_GPIO_WRITE(GPIO_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
PORT->DATA = Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write to specified Bit of GPIO DATA register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin,which can set as output.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param BitValue:The value of specified Bit.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_VALUE_0, GPIO_BIT_VALUE_1
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_WriteDataBit(GPIO_Port GPIO_x, uint8_t Bit_x, uint8_t BitValue)
|
||||
{
|
||||
uint8_t tmp = 0U;
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_GPIO_BIT_VALUE(BitValue));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinCR;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_OUT(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
tmp = GPIO_ReadData(GPIO_x);
|
||||
if (BitValue) {
|
||||
tmp |= Bit_x;
|
||||
} else {
|
||||
Bit_x = (~Bit_x);
|
||||
tmp &= Bit_x;
|
||||
}
|
||||
PORT->DATA = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the specified GPIO pin.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param GPIO_InitStruct: The structure containing basic GPIO configuration.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_Init(GPIO_Port GPIO_x, uint8_t Bit_x, GPIO_InitTypeDef * GPIO_InitStruct)
|
||||
{
|
||||
uint8_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_POINTER_NOT_NULL(GPIO_InitStruct));
|
||||
assert_param(IS_GPIO_IO_MODE_STATE(GPIO_InitStruct->IOMode));
|
||||
assert_param(IS_GPIO_PULLUP_STATE(GPIO_InitStruct->PullUp));
|
||||
assert_param(IS_GPIO_PULLDOWN_STATE(GPIO_InitStruct->PullDown));
|
||||
assert_param(IS_GPIO_OPEN_DRAIN_STATE(GPIO_InitStruct->OpenDrain));
|
||||
|
||||
tmp = GPIO_InitStruct->IOMode;
|
||||
switch (tmp) {
|
||||
case GPIO_INPUT_MODE:
|
||||
GPIO_SetInput(GPIO_x, Bit_x);
|
||||
break;
|
||||
case GPIO_OUTPUT_MODE:
|
||||
GPIO_SetOutput(GPIO_x, Bit_x);
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
tmp = GPIO_InitStruct->PullUp;
|
||||
switch (tmp) {
|
||||
case GPIO_PULLUP_ENABLE:
|
||||
GPIO_SetPullUp(GPIO_x, Bit_x, ENABLE);
|
||||
break;
|
||||
case GPIO_PULLUP_DISABLE:
|
||||
GPIO_SetPullUp(GPIO_x, Bit_x, DISABLE);
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
tmp = GPIO_InitStruct->PullDown;
|
||||
switch (tmp) {
|
||||
case GPIO_PULLDOWN_ENABLE:
|
||||
GPIO_SetPullDown(GPIO_x, Bit_x, ENABLE);
|
||||
break;
|
||||
case GPIO_PULLDOWN_DISABLE:
|
||||
GPIO_SetPullDown(GPIO_x, Bit_x, DISABLE);
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
tmp = GPIO_InitStruct->OpenDrain;
|
||||
switch (tmp) {
|
||||
case GPIO_OPEN_DRAIN_ENABLE:
|
||||
GPIO_SetOpenDrain(GPIO_x, Bit_x, ENABLE);
|
||||
break;
|
||||
case GPIO_OPEN_DRAIN_DISABLE:
|
||||
GPIO_SetOpenDrain(GPIO_x, Bit_x, DISABLE);
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set specified GPIO Pin as output port.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetOutput(GPIO_Port GPIO_x, uint8_t Bit_x)
|
||||
{
|
||||
uint8_t tmp = 0U;
|
||||
uint32_t i;
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinCR;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_OUT(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
tmp = (~Bit_x);
|
||||
for (i = 0U; i < FRMAX; i++) {
|
||||
if (GPIO_SFRs[GPIO_x].PinFR[i]) {
|
||||
PORT->FR[i] &= tmp;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
if (GPIO_SFRs[GPIO_x].PinIE) {
|
||||
PORT->IE &= tmp;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
PORT->CR |= Bit_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set specified GPIO Pin as input port.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetInput(GPIO_Port GPIO_x, uint8_t Bit_x)
|
||||
{
|
||||
uint8_t tmp = 0U;
|
||||
uint32_t i;
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinIE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_IN(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
tmp = (~Bit_x);
|
||||
for (i = 0U; i < FRMAX; i++) {
|
||||
if (GPIO_SFRs[GPIO_x].PinFR[i]) {
|
||||
PORT->FR[i] &= tmp;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
if (GPIO_SFRs[GPIO_x].PinCR) {
|
||||
PORT->CR &= tmp;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
PORT->IE |= Bit_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set or clear the bit setting in output control register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param NewState: The output state of the pin.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE , DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetOutputEnableReg(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinCR;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_OUT(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
if (NewState == ENABLE) {
|
||||
PORT->CR |= Bit_x;
|
||||
} else {
|
||||
PORT->CR &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set or clear the bit setting in input control register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param NewState: The input state of the pin.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE , DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetInputEnableReg(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinIE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_IN(GPIO_x, Bit_x));
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
PORT->IE |= Bit_x;
|
||||
} else {
|
||||
PORT->IE &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or Disable pull-up function of specified GPIO Pin.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param NewState: New state of the Pull-Up function.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE , DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetPullUp(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinPUP;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_PUP(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
if (NewState == ENABLE) {
|
||||
PORT->PUP |= Bit_x;
|
||||
} else {
|
||||
PORT->PUP &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or Disable pull-down function of specified GPIO Pin.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_2, GPIO_BIT_ALL, or combination of the effective bits.
|
||||
* @param NewState: New state of the Pull-Down function.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE , DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetPullDown(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinPDN;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_PDN(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
if (NewState == ENABLE) {
|
||||
PORT->PDN |= Bit_x;
|
||||
} else {
|
||||
PORT->PDN &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set specified GPIO Pin as open drain port or CMOS port.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @param NewState: New state of the Open Drain function.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE , DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_SetOpenDrain(GPIO_Port GPIO_x, uint8_t Bit_x, FunctionalState NewState)
|
||||
{
|
||||
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinOD;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_OD(GPIO_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
if (NewState == ENABLE) {
|
||||
PORT->OD |= Bit_x;
|
||||
} else {
|
||||
PORT->OD &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable specified GPIO Function register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK
|
||||
* GPIO_PL.
|
||||
* @param FuncReg_x: Select Function register of GPIO.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_FUNC_REG_1, GPIO_FUNC_REG_2, GPIO_FUNC_REG_3,
|
||||
* GPIO_FUNC_REG_4, GPIO_FUNC_REG_5, GPIO_FUNC_REG_6.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_EnableFuncReg(GPIO_Port GPIO_x, uint8_t FuncReg_x, uint8_t Bit_x)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_GPIO_FUNCTION_REG(FuncReg_x));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinFR[FuncReg_x];
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_FR(GPIO_x, FuncReg_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
PORT->FR[FuncReg_x] |= Bit_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable specified GPIO Function register.
|
||||
* @param GPIO_x: Select GPIO port.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE,
|
||||
* GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PJ, GPIO_PK,
|
||||
* GPIO_PL.
|
||||
* @param FuncReg_x: Select Function register of GPIO.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_FUNC_REG_1, GPIO_FUNC_REG_2, GPIO_FUNC_REG_3,
|
||||
* GPIO_FUNC_REG_4, GPIO_FUNC_REG_5, GPIO_FUNC_REG_6.
|
||||
* @param Bit_x: Select GPIO pin.
|
||||
* This parameter can be one of the following values:
|
||||
* GPIO_BIT_0, GPIO_BIT_1, GPIO_BIT_2, GPIO_BIT_3,
|
||||
* GPIO_BIT_4, GPIO_BIT_5, GPIO_BIT_6, GPIO_BIT_7, GPIO_BIT_ALL,
|
||||
* or combination of the effective bits.
|
||||
* @retval None
|
||||
*/
|
||||
void GPIO_DisableFuncReg(GPIO_Port GPIO_x, uint8_t FuncReg_x, uint8_t Bit_x)
|
||||
{
|
||||
TSB_Port_TypeDef *PORT = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_PORT(GPIO_x));
|
||||
assert_param(IS_GPIO_FUNCTION_REG(FuncReg_x));
|
||||
|
||||
if (Bit_x == GPIO_BIT_ALL) {
|
||||
Bit_x = GPIO_SFRs[GPIO_x].PinFR[FuncReg_x];
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_GPIO_BIT_FR(GPIO_x, FuncReg_x, Bit_x));
|
||||
|
||||
PORT = (TSB_Port_TypeDef *) GPIO_Base[GPIO_x];
|
||||
PORT->FR[FuncReg_x] &= (~(uint32_t) Bit_x);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group GPIO_Exported_Functions */
|
||||
/** @} */
|
||||
/* End of group GPIO */
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
#endif /* defined(__TMPM46B_GPIO_H) */
|
||||
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_i2c.c
|
||||
* @brief This file provides API functions for I2C driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/13
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_i2c.h"
|
||||
|
||||
#if defined(__TMPM46B_I2C_H)
|
||||
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C
|
||||
* @brief I2C driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2CCR1_BC_MASK ((uint32_t)0x0000001F)
|
||||
#define I2CCR1_ACK_SET ((uint32_t)0x00000010)
|
||||
#define I2CCR1_ACK_CLEAR ((uint32_t)0x000000EF)
|
||||
#define I2CCR1_SCK_MASK ((uint32_t)0x000000F8)
|
||||
#define I2CCR1_NOACK_MASK ((uint32_t)0x00000008)
|
||||
#define I2CCR1_NOACK_ENABLE ((uint32_t)0x00000000)
|
||||
|
||||
#define I2CCR2_PIN_SET ((uint32_t)0x00000010)
|
||||
#define I2CCR2_I2CM_I2C ((uint32_t)0x00000008)
|
||||
#define I2CCR2_SWRST_MASK ((uint32_t)0xFFFFFFFC)
|
||||
#define I2CCR2_SWRST_CMD1 ((uint32_t)0x00000002)
|
||||
#define I2CCR2_SWRST_CMD2 ((uint32_t)0x00000001)
|
||||
#define I2CCR2_START_CONDITION ((uint32_t)0x000000F0)
|
||||
#define I2CCR2_STOP_CONDITION ((uint32_t)0x000000D0)
|
||||
|
||||
|
||||
#define I2CAR_SA_MASK ((uint32_t)0x000000FE)
|
||||
#define I2CAR_ALS_SET ((uint32_t)0x00000001)
|
||||
#define I2CAR_ALS_CLEAR ((uint32_t)0xFFFFFFFE)
|
||||
#define I2C_DATA_MASK ((uint32_t)0x000000FF)
|
||||
|
||||
#define I2CIE_IE_SET ((uint32_t)0x00000001)
|
||||
#define I2CIE_IE_CLEAR ((uint32_t)0xFFFFFFFE)
|
||||
|
||||
#define I2CIR_ISIC_MASK ((uint32_t)0x00000001)
|
||||
#define I2CIR_ISIC_SET ((uint32_t)0x00000001)
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C_Private_Defines */
|
||||
|
||||
/** @defgroup I2C_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the generation of ACK clock.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param NewState: New state of ACK clock.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetACK(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
tmp = I2Cx->CR1;
|
||||
if (NewState == ENABLE) {
|
||||
/* Set I2CxCR1<ACK> to enable generation of ACK clock */
|
||||
tmp |= I2CCR1_ACK_SET;
|
||||
} else {
|
||||
/* Clear I2CxCR1<ACK> to disable generation of ACK clock */
|
||||
tmp &= I2CCR1_ACK_CLEAR;
|
||||
}
|
||||
I2Cx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the specified I2C channel in I2C mode.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param InitI2CStruct: The structure containing I2C in I2C mode configuration.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_Init(TSB_I2C_TypeDef * I2Cx, I2C_InitTypeDef * InitI2CStruct)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_POINTER_NOT_NULL(InitI2CStruct));
|
||||
assert_param(IS_I2C_ADDR(InitI2CStruct->I2CSelfAddr));
|
||||
assert_param(IS_I2C_BIT_NUM(InitI2CStruct->I2CDataLen));
|
||||
assert_param(IS_I2C_SCK_CLK_DIV(InitI2CStruct->I2CClkDiv));
|
||||
assert_param(IS_FUNCTIONAL_STATE(InitI2CStruct->I2CACKState));
|
||||
|
||||
/* Get the system clock frequency */
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/* Check the prescaler clock in the range between 50ns and 150ns */
|
||||
assert_param(IS_PRESCALER_CLK_VALID(InitI2CStruct->PrescalerClkDiv, SystemCoreClock));
|
||||
|
||||
/* Set prescaler clock */
|
||||
I2Cx->PRS = InitI2CStruct->PrescalerClkDiv % I2C_PRESCALER_DIV_32;
|
||||
|
||||
/* Set selfaddress for I2Cx */
|
||||
I2Cx->AR = InitI2CStruct->I2CSelfAddr & I2CAR_SA_MASK;
|
||||
|
||||
/* Set I2C bit length of transfer data */
|
||||
tmp = I2Cx->CR1 & I2CCR1_BC_MASK;
|
||||
tmp |= (InitI2CStruct->I2CDataLen << 5U);
|
||||
/* Set I2C clock division */
|
||||
tmp &= I2CCR1_SCK_MASK;
|
||||
tmp |= InitI2CStruct->I2CClkDiv;
|
||||
if (InitI2CStruct->I2CACKState) {
|
||||
/* Set I2CxCR1<ACK> to enable generation of ACK clock */
|
||||
tmp |= I2CCR1_ACK_SET;
|
||||
} else {
|
||||
/* Clear I2CxCR1<ACK> to disable generation of ACK clock */
|
||||
tmp &= I2CCR1_ACK_CLEAR;
|
||||
}
|
||||
I2Cx->CR1 = tmp;
|
||||
|
||||
/* Initialize I2C to I2C Slave-Rx mode */
|
||||
I2Cx->CR2 = I2CCR2_PIN_SET | I2CCR2_I2CM_I2C;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specify the number of bits per transfer.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param I2CBitNum: Specify the number of bits.
|
||||
* This parameter can be one of the following values:
|
||||
* I2C_DATA_LEN_8, I2C_DATA_LEN_1,I2C_DATA_LEN_2,I2C_DATA_LEN_3,
|
||||
* I2C_DATA_LEN_4, I2C_DATA_LEN_5,I2C_DATA_LEN_6 and I2C_DATA_LEN_7.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetBitNum(TSB_I2C_TypeDef * I2Cx, uint32_t I2CBitNum)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_I2C_BIT_NUM(I2CBitNum));
|
||||
|
||||
/* Write number of bits per transfer into I2CxCR1<BC> */
|
||||
tmp = I2Cx->CR1 & I2CCR1_BC_MASK;
|
||||
tmp |= ((uint32_t) I2CBitNum << 5U);
|
||||
|
||||
I2Cx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset the state of the specified I2C channel.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SWReset(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
tmp = I2Cx->CR2 & I2CCR2_SWRST_MASK;
|
||||
I2Cx->CR2 = tmp | I2CCR2_SWRST_CMD1;
|
||||
I2Cx->CR2 = tmp | I2CCR2_SWRST_CMD2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear I2C interrupt request in I2C mode.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_ClearINTReq(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Set I2CxCR2<PIN> to clear request, and Set I2CxCR2<I2CM> to enable I2C operation */
|
||||
tmp = I2Cx->SR;
|
||||
tmp &= (uint32_t) 0x000000E0;
|
||||
tmp |= (I2CCR2_PIN_SET | I2CCR2_I2CM_I2C);
|
||||
I2Cx->CR2 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2c bus to Master mode and Generate start condition in I2C mode.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_GenerateStart(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Set I2CxCR2<MST>, <TRX>, <BB> and <PIN> to generate start condition */
|
||||
I2Cx->CR2 = I2CCR2_START_CONDITION | I2CCR2_I2CM_I2C;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2c bus to Master mode and Generate stop condition in I2C mode.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_GenerateStop(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Set I2CxCR2<MST>, <TRX>, <PIN> and clear <BB> to generate stop condition */
|
||||
I2Cx->CR2 = I2CCR2_STOP_CONDITION | I2CCR2_I2CM_I2C;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the I2C channel state in I2C mode
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval The state of the I2C channel in I2C bus.
|
||||
*/
|
||||
I2C_State I2C_GetState(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
I2C_State state;
|
||||
state.All = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
state.All = I2Cx->SR;
|
||||
state.All &= I2C_DATA_MASK;
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set data to be sent and MCU starts transmission.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param Data: The data to be sent, max 0xFF.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetSendData(TSB_I2C_TypeDef * I2Cx, uint32_t Data)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_I2C_DATA(Data));
|
||||
|
||||
/* Write data into I2CxDBR */
|
||||
I2Cx->DBR = Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get data having been received.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval The data having been received
|
||||
*/
|
||||
uint32_t I2C_GetReceiveData(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
uint32_t retval = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Save the received data */
|
||||
retval = I2Cx->DBR;
|
||||
retval &= I2C_DATA_MASK;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable I2C free data mode of the I2C channel.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param NewState: New state of free data mode.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetFreeDataMode(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set I2CxI2CAR<ALS> to use free data mode transfer in I2C mode */
|
||||
I2Cx->AR |= I2CAR_ALS_SET;
|
||||
} else {
|
||||
/* Clear I2CxI2CAR<ALS> to not use free data mode transfer in I2C mode */
|
||||
I2Cx->AR &= I2CAR_ALS_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get slave address match detection state.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval DISABLE or ENABLE.
|
||||
*/
|
||||
FunctionalState I2C_GetSlaveAddrMatchState(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
FunctionalState retval = DISABLE;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
tmp = I2Cx->CR1 & I2CCR1_NOACK_MASK;
|
||||
if (tmp == I2CCR1_NOACK_ENABLE) {
|
||||
/* the slave address match or general call detection are enabled. */
|
||||
retval = ENABLE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set prescaler clock of the specified I2C channel.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param PrescalerClock: the prescaler clock value.
|
||||
* This parameter can be one of the following values:
|
||||
* I2C_PRESCALER_DIV_1 to I2C_PRESCALER_DIV_32
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetPrescalerClock(TSB_I2C_TypeDef * I2Cx, uint32_t PrescalerClock)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Get the system clock frequency */
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/* Check the prescaler clock in the range between 50ns and 150ns */
|
||||
assert_param(IS_PRESCALER_CLK_VALID(PrescalerClock, SystemCoreClock));
|
||||
|
||||
/* Write prescaler clock into I2CxPRS<PRSCK> */
|
||||
I2Cx->PRS = PrescalerClock % I2C_PRESCALER_DIV_32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable interrupt request of the I2C channel.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @param NewState: Specify I2C interrupt setting.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_SetINTReq(TSB_I2C_TypeDef * I2Cx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set I2CxIE<IE> to enable interrupt request */
|
||||
I2Cx->IE |= I2CIE_IE_SET;
|
||||
} else {
|
||||
/* Clear I2CxIE<IE> to disable interrupt request */
|
||||
I2Cx->IE &= I2CIE_IE_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get interrupt generation state.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval DISABLE or ENABLE.
|
||||
*/
|
||||
FunctionalState I2C_GetINTStatus(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
FunctionalState retval = DISABLE;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
tmp = I2Cx->IR & I2CIR_ISIC_MASK;
|
||||
if (tmp == I2CIR_ISIC_SET) {
|
||||
/* the I2C interrupt has been generated */
|
||||
retval = ENABLE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the I2C interrupt output.
|
||||
* @param I2Cx: Select the I2C channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_I2C0,TSB_I2C1,TSB_I2C2
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_ClearINTOutput(TSB_I2C_TypeDef * I2Cx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_I2C_PERIPH(I2Cx));
|
||||
|
||||
/* Set I2CxIR<ISIC> to clear the I2C interrupt output(INTI2Cx) */
|
||||
I2Cx->IR = I2CIR_ISIC_SET;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group I2C */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#endif /* defined(__TMPM46B_I2C_H) */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,661 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_ssp.c
|
||||
* @brief This file provides API functions for SSP driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/05
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_ssp.h"
|
||||
|
||||
#if defined(__TMPM46B_SSP_H)
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup SSP
|
||||
* @brief SSP driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup SSP_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SSP_ENABLE_SET ((uint32_t)0x00000002)
|
||||
#define SSP_CR1_MASK ((uint32_t)0x0000000F)
|
||||
#define SSP_ENABLE_CLEAR ((uint32_t)0x0000000D)
|
||||
|
||||
#define SSP_SCR_MASK ((uint32_t)0x000000FF)
|
||||
#define SSP_FORMAT_MASK ((uint32_t)0x0000FFCF)
|
||||
#define SSP_SPO_MASK ((uint32_t)0x0000FFBF)
|
||||
#define SSP_SPH_MASK ((uint32_t)0x0000FF7F)
|
||||
#define SSP_DSS_MASK ((uint32_t)0x0000FFF0)
|
||||
#define SSP_SOD_SET ((uint32_t)0x00000008)
|
||||
#define SSP_SOD_CLEAR ((uint32_t)0x00000007)
|
||||
|
||||
#define SSP_MS_SETSLAVE ((uint32_t)0x00000004)
|
||||
#define SSP_MS_MASK ((uint32_t)0x0000000B)
|
||||
|
||||
#define SSP_LBM_SET ((uint32_t)0x00000001)
|
||||
#define SSP_LBM_CLEAR ((uint32_t)0x0000000E)
|
||||
|
||||
#define SSP_BSY_MASK ((uint32_t)0x00000010)
|
||||
|
||||
#define SSP_TXFIFO_SR_MASK ((uint32_t)0x00000003)
|
||||
#define SSP_RXFIFO_SR_MASK ((uint32_t)0x0000000C)
|
||||
|
||||
#define SSP_IMSC_MASK ((uint32_t)0x0000000F)
|
||||
#define SSP_RIS_MASK ((uint32_t)0x0000000F)
|
||||
#define SSP_MIS_MASK ((uint32_t)0x0000000F)
|
||||
|
||||
#define SSP_DMA_MASK ((uint32_t)0x00000003)
|
||||
|
||||
#define SSP_TXFIFO_FULL 0U
|
||||
#define SSP_TXFIFO_INVALID 1U
|
||||
#define SSP_TXFIFO_NORMAL 2U
|
||||
#define SSP_TXFIFO_EMPTY 3U
|
||||
|
||||
#define SSP_RXFIFO_FULL 3U
|
||||
#define SSP_RXFIFO_INVALID 2U
|
||||
#define SSP_RXFIFO_NORMAL 1U
|
||||
#define SSP_RXFIFO_EMPTY 0U
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP_Private_Defines */
|
||||
|
||||
/** @defgroup SSP_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP_Private_FunctionPrototypes */
|
||||
|
||||
/** @defgroup SSP_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP_Private_Functions */
|
||||
|
||||
/** @defgroup SSP_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_Enable(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
/* Set SSPxCR1<SSE> to enable SSP module */
|
||||
tmp = SSPx->CR1 & SSP_CR1_MASK;
|
||||
tmp |= SSP_ENABLE_SET;
|
||||
SSPx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_Disable(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
/* Clear SSPxCR1<SSE> to disable SSP module */
|
||||
SSPx->CR1 &= SSP_ENABLE_CLEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the specified SSP channel through the data in structure SSP_InitTypeDef
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param InitStruct: Parameters to configure SSP module,
|
||||
* It includes data to set Frame Format, Clock prescale divider, Clock Rate,Clock Phase and Polarity, DataSize and Mode.
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_Init(TSB_SSP_TypeDef * SSPx, SSP_InitTypeDef * InitStruct)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_POINTER_NOT_NULL(InitStruct));
|
||||
|
||||
SSP_SetFrameFormat(SSPx, InitStruct->FrameFormat);
|
||||
SSP_SetClkPreScale(SSPx, InitStruct->PreScale, InitStruct->ClkRate);
|
||||
SSP_SetClkPolarity(SSPx, InitStruct->ClkPolarity);
|
||||
SSP_SetClkPhase(SSPx, InitStruct->ClkPhase);
|
||||
SSP_SetDataSize(SSPx, InitStruct->DataSize);
|
||||
SSP_SetMSMode(SSPx, InitStruct->Mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the bit rate for transmit and receive for the specified SSP channel.
|
||||
* BitRate = fSYS / (PreScale x (1 + ClkRate))
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param PreScale: Clock prescale divider(even number from 2 to 254)
|
||||
* @param ClkRate: Serial clock rate (From 0 to 255)
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetClkPreScale(TSB_SSP_TypeDef * SSPx, uint8_t PreScale, uint8_t ClkRate)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_PRE_SCALE(PreScale));
|
||||
|
||||
/* Set serial clock rate */
|
||||
tmp = SSPx->CR0 & SSP_SCR_MASK;
|
||||
tmp |= (((uint32_t) ClkRate) << 8U);
|
||||
SSPx->CR0 = tmp;
|
||||
|
||||
/* Set clock prescale divider */
|
||||
SSPx->CPSR = (uint32_t) PreScale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specify the Frame Format of specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param FrameFormat: Frame Format of SSP
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_FORMAT_SPI,
|
||||
* SSP_FORMAT_SSI,
|
||||
* SSP_FORMAT_MICROWIRE
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetFrameFormat(TSB_SSP_TypeDef * SSPx, SSP_FrameFormat FrameFormat)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_FRAME_FORMAT(FrameFormat));
|
||||
|
||||
/* Set Frame Format */
|
||||
tmp = SSPx->CR0 & SSP_FORMAT_MASK;
|
||||
tmp |= (((uint32_t) FrameFormat) << 4U);
|
||||
SSPx->CR0 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief When specified SSP channel is configured as SPI mode, specify the clock polarity in its idle state.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param ClkPolarity: SPI clock polarity
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_POLARITY_LOW,
|
||||
* SSP_POLARITY_HIGH
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetClkPolarity(TSB_SSP_TypeDef * SSPx, SSP_ClkPolarity ClkPolarity)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_CLK_POLARITY(ClkPolarity));
|
||||
|
||||
/* Set clock polarity */
|
||||
tmp = SSPx->CR0 & SSP_SPO_MASK;
|
||||
tmp |= (((uint32_t) ClkPolarity) << 6U);
|
||||
SSPx->CR0 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief When specified SSP channel is configured as SPI mode, specify its clock phase.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param ClkPolarity: SPI clock phase
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_PHASE_FIRST_EDGE : To captures serial data on the first clock transition of a frame.
|
||||
* SSP_PHASE_SECOND_EDGE : To captures serial data on the second clock transition of a frame
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetClkPhase(TSB_SSP_TypeDef * SSPx, SSP_ClkPhase ClkPhase)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_CLK_PHASE(ClkPhase));
|
||||
|
||||
/* Set clock phase */
|
||||
tmp = SSPx->CR0 & SSP_SPH_MASK;
|
||||
tmp |= (((uint32_t) ClkPhase) << 7U);
|
||||
SSPx->CR0 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Rx/Tx data size for the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param DataSize: Data size select. From 4 to 16
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetDataSize(TSB_SSP_TypeDef * SSPx, uint8_t DataSize)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_DATA_BIT_SIZE(DataSize));
|
||||
|
||||
/* Set Rx/Tx Data Size */
|
||||
tmp = SSPx->CR0 & SSP_DSS_MASK;
|
||||
tmp |= ((uint32_t) DataSize - 1U);
|
||||
SSPx->CR0 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable slave mode, SPDO pin output for the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param NewState: New state of slave mode output setting.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetSlaveOutputCtrl(TSB_SSP_TypeDef * SSPx, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Read SFR(Special Function Register)then clear other bits, also clear SSPxCR1<SOD>), bit3 as enable it */
|
||||
tmp = SSPx->CR1 & SSP_SOD_CLEAR;
|
||||
|
||||
/* Set SSPxCR1<SOD>, bit3 */
|
||||
if (NewState == DISABLE) {
|
||||
tmp |= SSP_SOD_SET;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
SSPx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select Master or Slave mode for the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param Mode: SSP device mode
|
||||
* This parameter can be SSP_MASTER or SSP_SLAVE.
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetMSMode(TSB_SSP_TypeDef * SSPx, SSP_MS_Mode Mode)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_MS_MODE(Mode));
|
||||
|
||||
/* Read SFR(Special Function Register)then clear other bits, also clear(SSPxCR1<MS>), bit2 as select master mode */
|
||||
tmp = SSPx->CR1 & SSP_MS_MASK;
|
||||
|
||||
/* Set SSPxCR1<MS>, bit2 */
|
||||
if (Mode == SSP_SLAVE) {
|
||||
tmp |= SSP_MS_SETSLAVE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
SSPx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set loop back mode for the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param NewState: New state of loop back mode.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE,
|
||||
* DISABLE
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetLoopBackMode(TSB_SSP_TypeDef * SSPx, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
/* Read SFR(Special Function Register)then clear other bits, also clear (SSPxCR1<LBM>), bit0 as disable it */
|
||||
tmp = SSPx->CR1 & SSP_LBM_CLEAR;
|
||||
|
||||
/* Set SSPxCR1<LBM>, bit0 */
|
||||
if (NewState == ENABLE) {
|
||||
tmp |= SSP_LBM_SET;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
SSPx->CR1 = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the data to be sent into Tx FIFO of the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param Data: the 4~16bit data to be send
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetTxData(TSB_SSP_TypeDef * SSPx, uint16_t Data)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
SSPx->DR = (uint32_t) Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the data received from Rx FIFO of the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval The 4~16bit data received from FIFO.
|
||||
*/
|
||||
uint16_t SSP_GetRxData(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
return ((uint16_t) (SSPx->DR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Busy or Idle state of the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval The state of SSP, which can be BUSY or DONE
|
||||
*/
|
||||
WorkState SSP_GetWorkState(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
WorkState tmp = DONE;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
/* Check the bit 'BSY'(bit4) of register SSPSR, */
|
||||
/* 1 == busy, 0 == idle or done */
|
||||
if ((SSPx->SR & SSP_BSY_MASK) == SSP_BSY_MASK) {
|
||||
tmp = BUSY;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Rx/Tx FIFO state of the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param Direction: the communication direction which will be check.
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_TX
|
||||
SSP_RX
|
||||
* @retval The state of Rx/Tx FIFO,
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_FIFO_EMPTY : FIFO is empty
|
||||
* SSP_FIFO_NORMAL : FIFO is not full and not empty
|
||||
* SSP_FIFO_INVALID : FIFO is invalid state
|
||||
* SSP_FIFO_FULL : FIFO is full
|
||||
*/
|
||||
SSP_FIFOState SSP_GetFIFOState(TSB_SSP_TypeDef * SSPx, SSP_Direction Direction)
|
||||
{
|
||||
uint32_t src = 0U;
|
||||
SSP_FIFOState tgt = SSP_FIFO_EMPTY;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_DIRECTION(Direction));
|
||||
|
||||
src = SSPx->SR;
|
||||
if (Direction == SSP_TX) {
|
||||
src &= SSP_TXFIFO_SR_MASK;
|
||||
switch (src) {
|
||||
case SSP_TXFIFO_FULL:
|
||||
tgt = SSP_FIFO_FULL;
|
||||
break;
|
||||
case SSP_TXFIFO_INVALID:
|
||||
tgt = SSP_FIFO_INVALID;
|
||||
break;
|
||||
case SSP_TXFIFO_NORMAL:
|
||||
tgt = SSP_FIFO_NORMAL;
|
||||
break;
|
||||
case SSP_TXFIFO_EMPTY:
|
||||
tgt = SSP_FIFO_EMPTY;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
src &= SSP_RXFIFO_SR_MASK;
|
||||
src >>= 2U;
|
||||
switch (src) {
|
||||
case SSP_RXFIFO_FULL:
|
||||
tgt = SSP_FIFO_FULL;
|
||||
break;
|
||||
case SSP_RXFIFO_INVALID:
|
||||
tgt = SSP_FIFO_INVALID;
|
||||
break;
|
||||
case SSP_RXFIFO_NORMAL:
|
||||
tgt = SSP_FIFO_NORMAL;
|
||||
break;
|
||||
case SSP_RXFIFO_EMPTY:
|
||||
tgt = SSP_FIFO_EMPTY;
|
||||
break;
|
||||
default:
|
||||
/* Do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tgt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable interrupt source of the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param INTSrc: The interrupt source for SSP to be enable or disable.
|
||||
* To disable all interrupt source,use the parameter:
|
||||
* SSP_INTCFG_NONE
|
||||
* To enable the interrupt one by one, use the "OR" operation with below parameter:
|
||||
* SSP_INTCFG_RX_OVERRUN Receive overrun interrupt
|
||||
* SSP_INTCFG_RX_TIMEOUT Receive timeout interrupt
|
||||
* SSP_INTCFG_RX Receive FIFO interrupt(at least half full)
|
||||
* SSP_INTCFG_TX Transmit FIFO interrupt(at least half empty)
|
||||
* To enable all the 4 interrupt above together, use the parameter:
|
||||
* SSP_INTCFG_ALL
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetINTConfig(TSB_SSP_TypeDef * SSPx, uint32_t IntSrc)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_INT_SRC(IntSrc));
|
||||
|
||||
SSPx->IMSC = IntSrc & SSP_IMSC_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Enable/Disable mask setting for each Interrupt source in the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval A data with union SSP_INTState type.
|
||||
*/
|
||||
SSP_INTState SSP_GetINTConfig(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
SSP_INTState state = { 0U };
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
state.All = SSPx->IMSC & SSP_IMSC_MASK;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the SSP pre-enable interrupt status of the specified SSP channel.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval A data with union SSP_INTState type.
|
||||
*/
|
||||
SSP_INTState SSP_GetPreEnableINTState(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
SSP_INTState state = { 0U };
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
state.All = SSPx->RIS & SSP_RIS_MASK;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the SSP post-enable interrupt status of the specified SSP channel.( after masked)
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @retval A data with union SSP_INTState type.
|
||||
*/
|
||||
SSP_INTState SSP_GetPostEnableINTState(TSB_SSP_TypeDef * SSPx)
|
||||
{
|
||||
SSP_INTState state = { 0U };
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
|
||||
state.All = SSPx->MIS & SSP_MIS_MASK;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear interrupt flag of specified SSP channel by writing '1' to correspond bit.
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param INTSrc: The interrupt source to be cleared.
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_INTCFG_RX_OVERRUN Receive overrun interrupt
|
||||
* SSP_INTCFG_RX_TIMEOUT Receive timeout interrupt
|
||||
* SSP_INTCFG_ALL All interrupt flags above
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_ClearINTFlag(TSB_SSP_TypeDef * SSPx, uint32_t IntSrc)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_CLEAR_INT_SRC(IntSrc));
|
||||
|
||||
if (IntSrc == SSP_INTCFG_RX_OVERRUN) {
|
||||
tmp = 1U;
|
||||
} else if (IntSrc == SSP_INTCFG_RX_TIMEOUT) {
|
||||
tmp = 2U;
|
||||
} else {
|
||||
tmp = 3U;
|
||||
}
|
||||
|
||||
SSPx->ICR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable the Rx/Tx DMA FIFO of the specified SSP channel
|
||||
* @param SSPx: Select the SSP channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_SSP0, TSB_SSP1, TSB_SSP2
|
||||
* @param Direction: The Direction of SSP,
|
||||
* This parameter can be one of the following values:
|
||||
* SSP_RX,
|
||||
* SSP_TX
|
||||
* @param NewState: New state of DMA FIFO Rx/Tx.
|
||||
* This parameter can be one of the following values:
|
||||
* ENABLE,
|
||||
* DISABLE
|
||||
* @retval None
|
||||
*/
|
||||
void SSP_SetDMACtrl(TSB_SSP_TypeDef * SSPx, SSP_Direction Direction, FunctionalState NewState)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
uint32_t tmpDMASet = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_SSP_PERIPH(SSPx));
|
||||
assert_param(IS_SSP_DIRECTION(Direction));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (Direction == SSP_RX) {
|
||||
/* Bit0 is for Rx */
|
||||
tmp = 1U;
|
||||
} else {
|
||||
/* Bit1 is for Tx */
|
||||
tmp = 2U;
|
||||
}
|
||||
|
||||
/* Read, then clear all bits except bit0 and bit1 */
|
||||
tmpDMASet = SSPx->DMACR & SSP_DMA_MASK;
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
tmpDMASet |= tmp;
|
||||
} else {
|
||||
/* Disable, clear bit */
|
||||
tmpDMASet &= ((uint32_t) ~tmp & SSP_DMA_MASK);
|
||||
}
|
||||
|
||||
SSPx->DMACR = tmpDMASet;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group SSP */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#endif /* defined(__TMPM46B_SSP_H) */
|
||||
@@ -0,0 +1,547 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tmpm46b_tmrb.c
|
||||
* @brief This file provides API functions for TMRB driver.
|
||||
* @version V2.0.2.1
|
||||
* @date 2015/02/27
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "tmpm46b_tmrb.h"
|
||||
|
||||
#if defined(__TMPM46B_TMRB_H)
|
||||
/** @addtogroup TX04_Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TMRB
|
||||
* @brief TMRB driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TMRB_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define EN_TBEN_SET ((uint32_t)0x00000080)
|
||||
#define EN_TBEN_CLEAR ((uint32_t)0xFFFFFF7F)
|
||||
|
||||
#define MPT_TIMER_MODE ((uint32_t)0xFFFFFFFE)
|
||||
|
||||
#define CR_I2TB_SET ((uint32_t)0x00000008)
|
||||
#define CR_I2TB_CLEAR ((uint32_t)0xFFFFFFF7)
|
||||
#define CR_TBSYNC_SET ((uint32_t)0x00000020)
|
||||
#define CR_TBSYNC_CLEAR ((uint32_t)0xFFFFFFDF)
|
||||
#define CR_TBWBF_SET ((uint32_t)0x00000080)
|
||||
#define CR_TBWBF_CLEAR ((uint32_t)0xFFFFFF7F)
|
||||
#define CR_CSSEL_SET ((uint32_t)0x00000001)
|
||||
#define CR_CSSEL_CLEAR ((uint32_t)0xFFFFFFFE)
|
||||
#define CR_TRGSEL_CLEAR ((uint32_t)0xFFFFFFBD)
|
||||
|
||||
#define MOD_CLK_CLE_CLEAR_MPT ((uint32_t)0xFFFFFFF8)
|
||||
#define MOD_CLK_CLE_CLEAR_TMRB ((uint32_t)0xFFFFFFF0)
|
||||
#define MOD_TBCPM_CLEAR_MPT ((uint32_t)0xFFFFFFE7)
|
||||
#define MOD_TBCPM_CLEAR_TMRB ((uint32_t)0xFFFFF8FF)
|
||||
#define MOD_TBCP_CLEAR_MPT ((uint32_t)0xFFFFFFDF)
|
||||
#define MOD_TBCP_CLEAR_TMRB ((uint32_t)0xFFFFFFBF)
|
||||
#define MOD_TBRSWR_CLEAR ((uint32_t)0xFFFFFFBF)
|
||||
|
||||
#define TB_ST_MASK ((uint32_t)0x00000007)
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Private_Defines */
|
||||
|
||||
/** @defgroup TMRB_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Private_FunctionPrototypes */
|
||||
|
||||
/** @defgroup TMRB_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Private_Functions */
|
||||
|
||||
/** @defgroup TMRB_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the specified TMRB channel.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_Enable(TSB_TB_TypeDef * TBx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
/* Clear MPTxEN<MTMODE> to Timer mode */
|
||||
if ((TBx == TSB_TB_MPT0) || (TBx == TSB_TB_MPT1) || (TBx == TSB_TB_MPT2) || (TBx == TSB_TB_MPT3)) {
|
||||
TBx->EN &= MPT_TIMER_MODE;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
/* Set TBxEN<TBEN> to enable TBx */
|
||||
TBx->EN |= EN_TBEN_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the specified TMRB channel.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_Disable(TSB_TB_TypeDef * TBx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
/* Clear TBxEN<TBEN> to disable TBx */
|
||||
TBx->EN &= EN_TBEN_CLEAR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start or stop counter of the specified TMRB channel.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param Cmd: The command for the counter.
|
||||
* This parameter can be TMRB_RUN or TMRB_STOP.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetRunState(TSB_TB_TypeDef * TBx, uint32_t Cmd)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_CMD(Cmd));
|
||||
|
||||
/* Write command into RUN register */
|
||||
TBx->RUN = Cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the specified TMRB channel.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param InitStruct: The structure containing basic TMRB configuration.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_Init(TSB_TB_TypeDef * TBx, TMRB_InitTypeDef * InitStruct)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_POINTER_NOT_NULL(InitStruct));
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_MODE(InitStruct->Mode));
|
||||
assert_param(IS_TMRB_VALUE(InitStruct->TrailingTiming));
|
||||
assert_param(IS_TMRB_VALUE(InitStruct->LeadingTiming));
|
||||
assert_param(IS_VALID_LEADING(InitStruct->LeadingTiming, InitStruct->TrailingTiming));
|
||||
tmp = TBx->MOD;
|
||||
|
||||
if ((TBx == TSB_TB_MPT0) || (TBx == TSB_TB_MPT1) || (TBx == TSB_TB_MPT2) || (TBx == TSB_TB_MPT3)) {
|
||||
assert_param(IS_MPT_CLK_DIV(InitStruct->ClkDiv));
|
||||
assert_param(IS_MPT_UC_CTRL(InitStruct->UpCntCtrl));
|
||||
tmp &= MOD_CLK_CLE_CLEAR_MPT;
|
||||
} else {
|
||||
assert_param(IS_TMRB_CLK_DIV(InitStruct->ClkDiv));
|
||||
assert_param(IS_TMRB_UC_CTRL(InitStruct->UpCntCtrl));
|
||||
tmp &= MOD_CLK_CLE_CLEAR_TMRB;
|
||||
}
|
||||
|
||||
if (InitStruct->Mode != 0U) {
|
||||
/* Use internal clock, set the prescaler */
|
||||
tmp |= InitStruct->ClkDiv;
|
||||
} else {
|
||||
/* Use external clock */
|
||||
/* Do nothing */
|
||||
}
|
||||
/* Set up-counter running mode */
|
||||
tmp |= InitStruct->UpCntCtrl;
|
||||
TBx->MOD = tmp;
|
||||
|
||||
/* Write leading-timing into RG0 */
|
||||
TBx->RG0 = InitStruct->LeadingTiming;
|
||||
|
||||
/* Write trailing-timing into RG1 */
|
||||
TBx->RG1 = InitStruct->TrailingTiming;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the capture timing and up-counter clearing timing.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param CaptureTiming: Specify TMRB capture timing.
|
||||
* This parameter can be one of the following values:
|
||||
* TBx = TSB_TB_MPT0 or TSB_TB_MPT1 or TSB_TB_MPT2 or TSB_TB_MPT3:
|
||||
* MPT_DISABLE_CAPTURE, MPT_CAPTURE_IN_RISING, MPT_CAPTURE_IN_RISING_FALLING.
|
||||
* TBx = TSB_TB0 to TSB_TB3:
|
||||
* TMRB_DISABLE_CAPTURE, TMRB_CAPTURE_TBIN0_RISING_FALLING,
|
||||
* TMRB_CAPTURE_TBFF0_EDGE.
|
||||
* TBx = TSB_TB4 to TSB_TB7:
|
||||
* TMRB_DISABLE_CAPTURE, TMRB_CAPTURE_TBIN0_TBIN1_RISING,
|
||||
* TMRB_CAPTURE_TBIN0_RISING_FALLING, TMRB_CAPTURE_TBFF0_EDGE,
|
||||
* TMRB_CLEAR_TBIN1_RISING, TMRB_CAPTURE_TBIN0_RISING_CLEAR_TBIN1_RISING.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetCaptureTiming(TSB_TB_TypeDef * TBx, uint32_t CaptureTiming)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
|
||||
/* Configure capture timing */
|
||||
if ((TBx == TSB_TB_MPT0) || (TBx == TSB_TB_MPT1) || (TBx == TSB_TB_MPT2) || (TBx == TSB_TB_MPT3)) {
|
||||
assert_param(IS_MPT_CAPTURE_TIMING(CaptureTiming));
|
||||
tmp = TBx->MOD & MOD_TBCPM_CLEAR_MPT;
|
||||
} else {
|
||||
if ((TBx == TSB_TB0) || (TBx == TSB_TB1) || (TBx == TSB_TB2) || (TBx == TSB_TB3)) {
|
||||
assert_param(IS_TMRB_CAPTURE_TIMING_NONE_TBIN1(CaptureTiming));
|
||||
} else {
|
||||
assert_param(IS_TMRB_CAPTURE_TIMING_ALL(CaptureTiming));
|
||||
}
|
||||
tmp = TBx->MOD & MOD_TBCPM_CLEAR_TMRB;
|
||||
}
|
||||
tmp |= CaptureTiming;
|
||||
TBx->MOD = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the flip-flop function.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param FFStruct: The structure containing TMRB flip-flop configuration
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetFlipFlop(TSB_TB_TypeDef * TBx, TMRB_FFOutputTypeDef * FFStruct)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_POINTER_NOT_NULL(FFStruct));
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_FLIPFLOP_CTRL(FFStruct->FlipflopCtrl));
|
||||
assert_param(IS_TMRB_FLIPFLOP_TRG(FFStruct->FlipflopReverseTrg));
|
||||
|
||||
/* Configure the flip-flop function of TBx */
|
||||
TBx->FFCR = (FFStruct->FlipflopCtrl | FFStruct->FlipflopReverseTrg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate what causes the interrupt.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @retval The interrupt factor of TBx.
|
||||
*/
|
||||
TMRB_INTFactor TMRB_GetINTFactor(TSB_TB_TypeDef * TBx)
|
||||
{
|
||||
TMRB_INTFactor retval;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
|
||||
retval.All = 0U;
|
||||
retval.All = TBx->ST & TB_ST_MASK;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Mask some TMRB interrupt.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param INTMask: Select the mask of TMRB interrupt.
|
||||
* This parameter can be one of the following values:
|
||||
* TMRB_NO_INT_MASK, TMRB_MASK_MATCH_LEADING_INT, TMRB_MASK_MATCH_TRAILING_INT,
|
||||
* TMRB_MASK_OVERFLOW_INT, TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_MATCH_TRAILING_INT,
|
||||
* TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_OVERFLOW_INT,
|
||||
* TMRB_MASK_MATCH_TRAILING_INT | TMRB_MASK_OVERFLOW_INT,
|
||||
* TMRB_MASK_MATCH_LEADING_INT | TMRB_MASK_MATCH_TRAILING_INT | TMRB_MASK_OVERFLOW_INT.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetINTMask(TSB_TB_TypeDef * TBx, uint32_t INTMask)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_INT_MASK(INTMask));
|
||||
|
||||
/* Mask the specified interrupt */
|
||||
TBx->IM = INTMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change leadingtiming value of TBx.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param LeadingTiming: New leadingtiming value, max 0xFFFF.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_ChangeLeadingTiming(TSB_TB_TypeDef * TBx, uint32_t LeadingTiming)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_VALUE(LeadingTiming));
|
||||
assert_param(IS_VALID_LEADING(LeadingTiming, TBx->RG1));
|
||||
|
||||
/* Write leadingtiming into RG0 */
|
||||
TBx->RG0 = LeadingTiming;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change trailingtiming value of TBx.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param TrailingTiming: New trailingtiming value, max 0xFFFF.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_ChangeTrailingTiming(TSB_TB_TypeDef * TBx, uint32_t TrailingTiming)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_VALUE(TrailingTiming));
|
||||
assert_param(IS_VALID_LEADING(TBx->RG0, TrailingTiming));
|
||||
|
||||
/* Write trailingtiming into RG1 */
|
||||
TBx->RG1 = TrailingTiming;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get up-counter value of TBx.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @retval Up-counter value of TBx
|
||||
*/
|
||||
uint16_t TMRB_GetUpCntValue(TSB_TB_TypeDef * TBx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
|
||||
/* Return up-counter value */
|
||||
return (uint16_t) TBx->UC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get TMRB capture value of TBx.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param CapReg: Select the capture register to read.
|
||||
* This parameter can be: TMRB_CAPTURE_0 or TMRB_CAPTURE_1.
|
||||
* @retval Capture value of TBx
|
||||
*/
|
||||
uint16_t TMRB_GetCaptureValue(TSB_TB_TypeDef * TBx, uint8_t CapReg)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_CAPTURE_REG(CapReg));
|
||||
|
||||
return CapReg ? (uint16_t) TBx->CP1 : (uint16_t) TBx->CP0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Capture counter by software and take them into capture register 0.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_ExecuteSWCapture(TSB_TB_TypeDef * TBx)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
|
||||
/* Set software capture */
|
||||
|
||||
if ((TBx == TSB_TB_MPT0) || (TBx == TSB_TB_MPT1) || (TBx == TSB_TB_MPT2) || (TBx == TSB_TB_MPT3)) {
|
||||
TBx->MOD &= MOD_TBCP_CLEAR_MPT;
|
||||
} else {
|
||||
TBx->MOD &= MOD_TBCP_CLEAR_TMRB;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable TMRB when system is in idle mode.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param NewState: New state of TMRB in system idle mode.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetIdleMode(TSB_TB_TypeDef * TBx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set TBxCR<I2TB> to enable TBx in system idle mode */
|
||||
TBx->CR |= CR_I2TB_SET;
|
||||
} else {
|
||||
/* Clear TBxCR<I2TB> to disable TBx in system idle mode */
|
||||
TBx->CR &= CR_I2TB_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the synchronous mode of specified TMRB channel.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB5, TSB_TB6, TSB_TB7.
|
||||
* @param NewState: New state of TBx synchronous mode.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetSyncMode(TSB_TB_TypeDef * TBx, FunctionalState NewState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_SYNC_PERIPH(TBx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set TBxCR<TBSYNC> to make TBx running in synchronous mode */
|
||||
TBx->CR |= CR_TBSYNC_SET;
|
||||
} else {
|
||||
/* Clear TBxCR<TBSYNC> to make TBx running in individual mode */
|
||||
TBx->CR &= CR_TBSYNC_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable double buffer of TBx and set the timing to write to timer register.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param NewState: New state of TBx double buffer.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @param WriteRegMode: Timing to write to timer register.
|
||||
* This parameter can be TMRB_WRITE_REG_SEPARATE or TMRB_WRITE_REG_SIMULTANEOUS.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetDoubleBuf(TSB_TB_TypeDef * TBx, FunctionalState NewState, uint8_t WriteRegMode)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
assert_param(IS_TMRB_WRITE_REG_MODE(WriteRegMode));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set TBxCR<TBWBF> to enable TBx double buffer */
|
||||
TBx->CR |= CR_TBWBF_SET;
|
||||
if ((TBx == TSB_TB_MPT0) || (TBx == TSB_TB_MPT1) || (TBx == TSB_TB_MPT2) || (TBx == TSB_TB_MPT3)) {
|
||||
/* Write timer register timing */
|
||||
tmp = TBx->MOD & MOD_TBRSWR_CLEAR;
|
||||
tmp |= (uint32_t) WriteRegMode;
|
||||
TBx->MOD = tmp;
|
||||
} else {
|
||||
/* Do nothing */
|
||||
}
|
||||
} else {
|
||||
/* Clear TBxCR<TBWBF> to disable TBx double buffer */
|
||||
TBx->CR &= CR_TBWBF_CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable external trigger to start count and set the active edge.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param NewState: New state of external trigger.
|
||||
* This parameter can be ENABLE or DISABLE.
|
||||
* @param TrgMode: Active edge of the external trigger signal.
|
||||
* This parameter can be TMRB_TRG_EDGE_RISING or TMRB_TRG_EDGE_FALLING.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetExtStartTrg(TSB_TB_TypeDef * TBx, FunctionalState NewState, uint8_t TrgMode)
|
||||
{
|
||||
uint32_t tmp = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_FUNCTIONAL_STATE(NewState));
|
||||
assert_param(IS_TMRB_TRG_EDGE(TrgMode));
|
||||
|
||||
if (NewState == ENABLE) {
|
||||
/* Set TBxCR<CSSEL> to choose external trigger */
|
||||
TBx->CR |= CR_CSSEL_SET;
|
||||
} else {
|
||||
/* Clear TBxCR<CSSEL> to choose software start */
|
||||
TBx->CR &= CR_CSSEL_CLEAR;
|
||||
}
|
||||
|
||||
/* external trigger selection */
|
||||
tmp = TBx->CR & CR_TRGSEL_CLEAR;
|
||||
tmp |= (uint32_t) TrgMode;
|
||||
TBx->CR = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable clock operation during debug HALT.
|
||||
* @param TBx: Select the TMRB channel.
|
||||
* This parameter can be one of the following values:
|
||||
* TSB_TB0, TSB_TB1, TSB_TB2, TSB_TB3, TSB_TB4, TSB_TB5, TSB_TB6, TSB_TB7,
|
||||
* TSB_TB_MPT0, TSB_TB_MPT1, TSB_TB_MPT2, TSB_TB_MPT3.
|
||||
* @param ClkState: Timer state in HALT mode.
|
||||
* This parameter can be TMRB_RUNNING_IN_CORE_HALT or TMRB_STOP_IN_CORE_HALT.
|
||||
* @retval None
|
||||
*/
|
||||
void TMRB_SetClkInCoreHalt(TSB_TB_TypeDef * TBx, uint8_t ClkState)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TMRB_ALL_PERIPH(TBx));
|
||||
assert_param(IS_TMRB_CLK_IN_CORE_HALT(ClkState));
|
||||
|
||||
if (ClkState == TMRB_STOP_IN_CORE_HALT) {
|
||||
/* Set TBEN<TBHALT> */
|
||||
TBx->EN |= (uint32_t) TMRB_STOP_IN_CORE_HALT;
|
||||
} else {
|
||||
/* Clear TBEN<TBHALT> */
|
||||
TBx->EN &= ~(uint32_t) TMRB_STOP_IN_CORE_HALT;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB_Exported_Functions */
|
||||
|
||||
/** @} */
|
||||
/* End of group TMRB */
|
||||
|
||||
/** @} */
|
||||
/* End of group TX04_Periph_Driver */
|
||||
|
||||
#endif /* defined(__TMPM46B_TMRB_H) */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user