mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7923 from ganesh-ramachandran/master
Add Support for Toshiba TMPM4G9pull/8436/merge
commit
af19a395e0
|
@ -0,0 +1,499 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file adc.h
|
||||
* @brief This file provides all the functions prototypes for ADC driver.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-09-12 13:52:12 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __ADC_H
|
||||
#define __ADC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
#include "adc_ch.h"
|
||||
/**
|
||||
* @addtogroup Periph_Driver Peripheral Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ADC ADC
|
||||
* @brief ADC Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_define ADC Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ADC_ChannelMax Channel Num Max
|
||||
* @brief Max Num of channel.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ADC_NUM_MAX ((uint32_t)24) /*!< Max Num of conversion. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_ChannelMax */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
@defgroup ADC_Exported_define ADC Exported Define
|
||||
@{
|
||||
*/
|
||||
/** @enum adc_sampling_period0_t
|
||||
@brief Outside AIN sampling period.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_SAMPLING_PERIOD0_XN = 0x00, /*!< SCLK Period (1/SCLK)xN */
|
||||
ADC_SAMPLING_PERIOD0_X2N = 0x08, /*!< SCLK Period (1/SCLK)x2N */
|
||||
ADC_SAMPLING_PERIOD0_X3N = 0x10, /*!< SCLK Period (1/SCLK)x3N */
|
||||
ADC_SAMPLING_PERIOD0_X4N = 0x18, /*!< SCLK Period (1/SCLK)x4N */
|
||||
ADC_SAMPLING_PERIOD0_X16N = 0x28, /*!< SCLK Period (1/SCLK)x16N */
|
||||
ADC_SAMPLING_PERIOD0_X64N = 0x38, /*!< SCLK Period (1/SCLK)x64N */
|
||||
}adc_sampling_period0_t;
|
||||
/** @enum adc_sampling_period1_t
|
||||
@brief Outside AIN sampling period.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_SAMPLING_PERIOD1_XN = 0x000, /*!< SCLK Period (1/SCLK)xN */
|
||||
ADC_SAMPLING_PERIOD1_X2N = 0x100, /*!< SCLK Period (1/SCLK)x2N */
|
||||
ADC_SAMPLING_PERIOD1_X3N = 0x200, /*!< SCLK Period (1/SCLK)x3N */
|
||||
ADC_SAMPLING_PERIOD1_X4N = 0x300, /*!< SCLK Period (1/SCLK)x4N */
|
||||
ADC_SAMPLING_PERIOD1_X16N = 0x500, /*!< SCLK Period (1/SCLK)x16N */
|
||||
ADC_SAMPLING_PERIOD1_X64N = 0x700, /*!< SCLK Period (1/SCLK)x64N */
|
||||
}adc_sampling_period1_t;
|
||||
|
||||
/*! @enum adc_sclk_t
|
||||
@brief Select AD prescaler output (SCLK).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_SCLK_1 = (0x00000000U), /*!< ADCLK/1 */
|
||||
ADC_SCLK_2 = (0x00000001U), /*!< ADCLK/2 */
|
||||
ADC_SCLK_4 = (0x00000002U), /*!< ADCLK/4 */
|
||||
ADC_SCLK_8 = (0x00000003U), /*!< ADCLK/8 */
|
||||
ADC_SCLK_16 = (0x00000004U), /*!< ADCLK/16 */
|
||||
}adc_sclk_t;
|
||||
|
||||
/*! @enum adc_mod1_t
|
||||
@brief Select SCLK Frequency Band (MOD1).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_MOD1_SCLK_1 = (0x00001000U), /*!< SCLK =< 40MHz > */
|
||||
ADC_MOD1_SCLK_2 = (0x00003000U), /*!< 40MHz < SCLK =< 50MHz > */
|
||||
ADC_MOD1_SCLK_3 = (0x00004000U), /*!< 50MHz < SCLK =< 60MHz > */
|
||||
ADC_MOD1_SCLK_4 = (0x00106011U), /*!< 60MHz < SCLK =< 80MHz > */
|
||||
}adc_mod1_t;
|
||||
|
||||
/*! @enum adc_mod2_t
|
||||
@brief Select ADC Product Setting Value (MOD2).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_MOD2_TMPM4G9 = (0x00000000U), /*!< TMPM4G9 */
|
||||
ADC_MOD2_CLEAR = (0x00000000U), /*!< Reset Value */
|
||||
}adc_mod2_t;
|
||||
|
||||
/*! @enum adc_int_t
|
||||
@brief Select Interrupt Enable/Disable.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_INT_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADC_INT_ENABLE = (0x00000080U), /*!< Enable. */
|
||||
}adc_int_t;
|
||||
|
||||
/*! @enum adc_conversion_t
|
||||
@brief Select conversion method.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_CONVERSION_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADC_CONVERSION_CNT = (0x00000100U), /*!< Continuation. */
|
||||
ADC_CONVERSION_SGL = (0x00000200U), /*!< Single. */
|
||||
ADC_CONVERSION_TRG = (0x00000300U), /*!< Universal Trigger. */
|
||||
ADC_CONVERSION_HPTG = (0x00000400U), /*!< High Priority Trigger. */
|
||||
}adc_conversion_t;
|
||||
|
||||
/*! @enum adc_dma_int_t
|
||||
@brief Select DMA interrupt method.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_DMA_INT_SGL_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADC_DMA_INT_SGL_ENABLE = (0x00000020U), /*!< DMA Single interrupt Enable. */
|
||||
ADC_DMA_INT_CNT_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADC_DMA_INT_CNT_ENABLE = (0x00000040U), /*!< DMA Continuation interrupt Enable. */
|
||||
ADC_DMA_INT_TRG_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADC_DMA_INT_TRG_ENABLE = (0x00000010U), /*!< DMA Universal Trigger interrupt Enable. */
|
||||
ADC_TRG_DISABLE = (0x00000000U), /*!< Universal Trigger Disable. */
|
||||
ADC_TRG_ENABLE = (0x00000001U), /*!< Universal Trigger Enable. */
|
||||
ADC_HPTG_DISABLE = (0x00000000U), /*!< High Priority Trigger Disable. */
|
||||
ADC_HPTG_ENABLE = (0x00000002U), /*!< High Priority Trigger Enable. */
|
||||
}adc_dma_int_t;
|
||||
|
||||
/*! @enum adc_ain_range_t
|
||||
@brief Range of AIN Macro Definisiton.
|
||||
Range of AIN be set "(ADC_AIN_RANGE_MIN <= Value <= ADC_AIN_RANGE_MAX)".
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_AIN_RANGE_MIN = (0x00000000U), /*!< Minimum Value :AINx00 */
|
||||
ADC_AIN_RANGE_MAX = (0x00000017U), /*!< Maximum Value :AINx23 */
|
||||
}adc_ain_range_t;
|
||||
|
||||
/*! @enum adc_status_t
|
||||
@brief AD Running Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_STATUS_MASK = (0x00000080U), /*!< for Mask. */
|
||||
ADC_STATUS_SLEEP = (0x00000000U), /*!< Sleep. */
|
||||
ADC_STATUS_RUNNING = (0x00000080U), /*!< Running. */
|
||||
}adc_status_t;
|
||||
|
||||
/*! @enum adc_cnt_status_t
|
||||
@brief Continuity Conversion Running Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_CNT_STATUS_MASK = (0x00000008U), /*!< for Mask. */
|
||||
ADC_CNT_STATUS_SLEEP = (0x00000000U), /*!< Sleep. */
|
||||
ADC_CNT_STATUS_RUNNING = (0x00000008U), /*!< Running. */
|
||||
}adc_cnt_status_t;
|
||||
|
||||
/*! @enum adc_sgl_status_t
|
||||
@brief Single Conversion Running Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_SGL_STATUS_MASK = (0x00000004U), /*!< for Mask. */
|
||||
ADC_SGL_STATUS_SLEEP = (0x00000000U), /*!< Sleep. */
|
||||
ADC_SGL_STATUS_RUNNING = (0x00000004U), /*!< Running. */
|
||||
}adc_sgl_status_t;
|
||||
|
||||
/*! @enum adc_trg_status_t
|
||||
@brief Trigger Conversion Running Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_TRG_STATUS_MASK = (0x00000002U), /*!< for Mask. */
|
||||
ADC_TRG_STATUS_SLEEP = (0x00000000U), /*!< Sleep. */
|
||||
ADC_TRG_STATUS_RUNNING = (0x00000002U), /*!< Running. */
|
||||
}adc_trg_status_t;
|
||||
|
||||
/*! @enum adc_hpri_status_t
|
||||
@brief Trigger Conversion Running Status.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADC_HPTG_STATUS_MASK = (0x00000001U), /*!< for Mask. */
|
||||
ADC_HPTG_STATUS_SLEEP = (0x00000000U), /*!< Sleep. */
|
||||
ADC_HPTG_STATUS_RUNNING = (0x00000001U), /*!< Running. */
|
||||
}adc_hpri_status_t;
|
||||
|
||||
/*! @enum adcmpxen_t
|
||||
@brief Select Enable, Disable setting(ADxCMPEN).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCMP3EN_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADCMP3EN_ENABLE = (0x00000008U), /*!< Enable. */
|
||||
ADCMP2EN_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADCMP2EN_ENABLE = (0x00000004U), /*!< Enable. */
|
||||
ADCMP1EN_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADCMP1EN_ENABLE = (0x00000002U), /*!< Enable. */
|
||||
ADCMP0EN_DISABLE = (0x00000000U), /*!< Disable. */
|
||||
ADCMP0EN_ENABLE = (0x00000001U), /*!< Enable. */
|
||||
}adcmpxen_t;
|
||||
|
||||
/*! @enum adcmpcnt_t
|
||||
@brief Select Compare count num.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCMPCNT_1 = (0x00000000U), /*!< 1 time */
|
||||
ADCMPCNT_2 = (0x00000100U), /*!< 2 times */
|
||||
ADCMPCNT_3 = (0x00000200U), /*!< 3 times */
|
||||
ADCMPCNT_4 = (0x00000300U), /*!< 4 times */
|
||||
ADCMPCNT_5 = (0x00000400U), /*!< 5 times */
|
||||
ADCMPCNT_6 = (0x00000500U), /*!< 6 times */
|
||||
ADCMPCNT_7 = (0x00000600U), /*!< 7 times */
|
||||
ADCMPCNT_8 = (0x00000700U), /*!< 8 times */
|
||||
ADCMPCNT_9 = (0x00000800U), /*!< 9 times */
|
||||
ADCMPCNT_10 = (0x00000900U), /*!< 10 times */
|
||||
ADCMPCNT_11 = (0x00000a00U), /*!< 11 times */
|
||||
ADCMPCNT_12 = (0x00000b00U), /*!< 12 times */
|
||||
ADCMPCNT_13 = (0x00000c00U), /*!< 13 times */
|
||||
ADCMPCNT_14 = (0x00000d00U), /*!< 14 times */
|
||||
ADCMPCNT_15 = (0x00000e00U), /*!< 15 times */
|
||||
ADCMPCNT_16 = (0x00000f00U), /*!< 16 times */
|
||||
}adcmpcnt_t;
|
||||
|
||||
/*! @enum adcmpcond_t
|
||||
@brief Compare condition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCMPCond_CNT = (0x00000000U), /*!< Continuous */
|
||||
ADCMPCond_ACC = (0x00000040U), /*!< Accumulation */
|
||||
}adcmpcond_t;
|
||||
|
||||
/*! @enum adcmpbigsml_t
|
||||
@brief Compare Big, Small condition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCMPBigSml_Big = (0x00000000U), /*!< Big */
|
||||
ADCMPBigSml_Sml = (0x00000020U), /*!< Small */
|
||||
}adcmpbigsml_t;
|
||||
|
||||
/*! @enum adcmpstr_t
|
||||
@brief Select Compare Store register
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCMPStr_Reg0 = (0x00000000U), /*!< ADxREG0 */
|
||||
ADCMPStr_Reg1 = (0x00000001U), /*!< ADxREG1 */
|
||||
ADCMPStr_Reg2 = (0x00000002U), /*!< ADxREG2 */
|
||||
ADCMPStr_Reg3 = (0x00000003U), /*!< ADxREG3 */
|
||||
ADCMPStr_Reg4 = (0x00000004U), /*!< ADxREG4 */
|
||||
ADCMPStr_Reg5 = (0x00000005U), /*!< ADxREG5 */
|
||||
ADCMPStr_Reg6 = (0x00000006U), /*!< ADxREG6 */
|
||||
ADCMPStr_Reg7 = (0x00000007U), /*!< ADxREG7 */
|
||||
ADCMPStr_Reg8 = (0x00000008U), /*!< ADxREG8 */
|
||||
ADCMPStr_Reg9 = (0x00000009U), /*!< ADxREG9 */
|
||||
ADCMPStr_Reg10 = (0x0000000aU), /*!< ADxREG10 */
|
||||
ADCMPStr_Reg11 = (0x0000000bU), /*!< ADxREG11 */
|
||||
ADCMPStr_Reg12 = (0x0000000cU), /*!< ADxREG12 */
|
||||
ADCMPStr_Reg13 = (0x0000000dU), /*!< ADxREG13 */
|
||||
ADCMPStr_Reg14 = (0x0000000eU), /*!< ADxREG14 */
|
||||
ADCMPStr_Reg15 = (0x0000000fU), /*!< ADxREG15 */
|
||||
ADCMPStr_Reg16 = (0x00000010U), /*!< ADxREG16 */
|
||||
ADCMPStr_Reg17 = (0x00000011U), /*!< ADxREG17 */
|
||||
ADCMPStr_Reg18 = (0x00000012U), /*!< ADxREG18 */
|
||||
ADCMPStr_Reg19 = (0x00000013U), /*!< ADxREG19 */
|
||||
ADCMPStr_Reg20 = (0x00000014U), /*!< ADxREG20 */
|
||||
ADCMPStr_Reg21 = (0x00000015U), /*!< ADxREG21 */
|
||||
ADCMPStr_Reg22 = (0x00000016U), /*!< ADxREG22 */
|
||||
ADCMPStr_Reg23 = (0x00000017U), /*!< ADxREG23 */
|
||||
}adcmpstr_t;
|
||||
/*! @enum adcexazain_t
|
||||
@brief Select AIN no.
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADCEXAZSEL_AIN0 = 0, /*!< AIN0 */
|
||||
ADCEXAZSEL_AIN1, /*!< AIN1 */
|
||||
ADCEXAZSEL_AIN2, /*!< AIN2 */
|
||||
ADCEXAZSEL_AIN3, /*!< AIN3 */
|
||||
ADCEXAZSEL_AIN4, /*!< AIN4 */
|
||||
ADCEXAZSEL_AIN5, /*!< AIN5 */
|
||||
ADCEXAZSEL_AIN6, /*!< AIN6 */
|
||||
ADCEXAZSEL_AIN7, /*!< AIN7 */
|
||||
ADCEXAZSEL_AIN8, /*!< AIN8 */
|
||||
ADCEXAZSEL_AIN9, /*!< AIN9 */
|
||||
ADCEXAZSEL_AIN10, /*!< AIN10 */
|
||||
ADCEXAZSEL_AIN11, /*!< AIN11 */
|
||||
ADCEXAZSEL_AIN12, /*!< AIN12 */
|
||||
ADCEXAZSEL_AIN13, /*!< AIN13 */
|
||||
ADCEXAZSEL_AIN14, /*!< AIN14 */
|
||||
ADCEXAZSEL_AIN15, /*!< AIN15 */
|
||||
ADCEXAZSEL_AIN16, /*!< AIN16 */
|
||||
ADCEXAZSEL_AIN17, /*!< AIN17 */
|
||||
ADCEXAZSEL_AIN18, /*!< AIN18 */
|
||||
ADCEXAZSEL_AIN19, /*!< AIN19 */
|
||||
ADCEXAZSEL_AIN20, /*!< AIN20 */
|
||||
ADCEXAZSEL_AIN21, /*!< AIN21 */
|
||||
ADCEXAZSEL_AIN22, /*!< AIN22 */
|
||||
ADCEXAZSEL_AIN23, /*!< AIN23 */
|
||||
}adcexazain_t;
|
||||
/*! @enum adcexazsel_t
|
||||
@brief Select sampling period, EXAS0 or EXAS1.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ADCEXAZSEL_EXAZ0 = (0x00000000), /*< EXAZ0 */
|
||||
ADCEXAZSEL_EXAZ1 = (0x00000001), /*< EXAZ1 */
|
||||
}adcexazsel_t;
|
||||
|
||||
/*!
|
||||
@}
|
||||
*/ /* End of group ADC_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/*!
|
||||
@defgroup ADC_Exported_typedef ADC Exported Typedef
|
||||
@{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_clock_t
|
||||
@brief Clock information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
adc_sampling_period0_t exaz0; /*!< Outside AIN0 Sampling period.
|
||||
: Use @ref adc_sampling_period0_t. */
|
||||
adc_sampling_period1_t exaz1; /*!< Outside AIN1 Sampling period.
|
||||
: Use @ref adc_sampling_period1_t. */
|
||||
adc_sclk_t vadcld; /*!< Select AD prescaler output (SCLK).
|
||||
: Use @ref adc_sclk_t. */
|
||||
uint32_t sampling_select; /*!< Sampling period select. : bit0-bit23 */
|
||||
} adc_clock_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_cmpx_t
|
||||
@brief Clock information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t CMPEN; /*!< Enable Register status */
|
||||
uint32_t CMPCNT; /*!< Compare count num. */
|
||||
uint32_t CMPCond; /*!< Compare condition */
|
||||
uint32_t CMPBigSml; /*!< Compare Big/Small condition */
|
||||
uint32_t StrReg; /*!< Compare Store register */
|
||||
uint32_t ADComp; /*!< ADxCMP0 register data */
|
||||
void (*handle)(uint32_t id, TXZ_Result result); /*!< Notity Compare Done. */
|
||||
} adc_cmpx_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_initial_setting_t
|
||||
@brief Initial setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t id; /*!< ID: User value. */
|
||||
adc_clock_t clk; /*!< Clock setting.
|
||||
: Use @ref adc_clock_t. */
|
||||
uint32_t mod1; /*!< AVDD3 voltage band setting.
|
||||
: Use @ref adc_mod1_t. */
|
||||
uint32_t mod2; /*!< Product info setting.
|
||||
: Use @ref adc_mod2_t. */
|
||||
adc_cmpx_t CMPxEN[4]; /*!< adc_cmpx_t. */
|
||||
|
||||
|
||||
} adc_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_channel_setting_t
|
||||
@brief Channel Setting. \n
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t interrupt; /*!< Interrupt Enable/Disable.
|
||||
: Use @ref adc_dma_int_t. */
|
||||
uint32_t type; /*!< Conversion Type.
|
||||
: Use @ref adc_conversion_t. */
|
||||
uint32_t ain; /*!< AIN. */
|
||||
} adc_channel_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_internal_info_t
|
||||
@brief Driver internal information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
adc_ch_t ch[ADC_NUM_MAX]; /*!< Channel Instance. */
|
||||
} adc_internal_info_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_t
|
||||
@brief ADC handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_AD_TypeDef *p_instance; /*!< Registers base address. */
|
||||
adc_initial_setting_t init; /*!< Initial setting. */
|
||||
adc_internal_info_t info; /*!< Driver internal information. */
|
||||
struct
|
||||
{
|
||||
void (*single)(uint32_t id, TXZ_Result result); /*!< Notity Single Conversion Done. */
|
||||
void (*continuity)(uint32_t id, TXZ_Result result); /*!< Notity Continuity Conversion Done. */
|
||||
void (*trigger)(uint32_t id, TXZ_Result result); /*!< Notity Trigger Conversion Done. */
|
||||
void (*highpriority)(uint32_t id, TXZ_Result result); /*!< Notity HighPriority Conversion Done. */
|
||||
} handler; /*!< Handler structure. */
|
||||
} adc_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_functions ADC Exported Functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result adc_init(adc_t *p_obj);
|
||||
TXZ_Result adc_deinit(adc_t *p_obj);
|
||||
TXZ_Result adc_mode1_setting(void);
|
||||
TXZ_Result adc_channel_setting(adc_t *p_obj, uint32_t ch, adc_channel_setting_t *p_setting);
|
||||
TXZ_Result adc_channel_clear(adc_t *p_obj, uint32_t ch);
|
||||
TXZ_Result adc_cmp_init(adc_t *p_obj, adc_cmpx_t *p_cmpx_t);
|
||||
TXZ_Result adc_cmp_deinit(adc_t *p_obj, adc_cmpx_t *p_cmpx_t);
|
||||
TXZ_Result adc_channel_get_value(adc_t *p_obj, uint32_t ch, uint32_t *p_value);
|
||||
TXZ_Result adc_start(adc_t *p_obj);
|
||||
TXZ_Result adc_stop(adc_t *p_obj);
|
||||
TXZ_Result adc_get_status(adc_t *p_obj, uint32_t *p_status);
|
||||
TXZ_WorkState adc_poll_conversion(adc_t *p_obj, uint32_t timeout);
|
||||
void adc_compa_irq_handler( void );
|
||||
void adc_compb_irq_handler( void );
|
||||
void adc_single_irq_handler( void );
|
||||
void adc_continuity_irq_handler( void );
|
||||
void adc_trigger_irq_handler( void );
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __ADC_H */
|
||||
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file adc_ch.h
|
||||
* @brief This file provides all the functions prototypes for ADC driver. \n
|
||||
* Channel Class.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-09-07 13:52:12 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __ADC_CH_H
|
||||
#define __ADC_CH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver Peripheral Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ADC ADC
|
||||
* @brief ADC Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_define ADC Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_define ADC Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_typedef ADC Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_ch_initial_setting_t
|
||||
* @brief Initialize Setting.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t interrupt; /*!< Interrupt Enable/Disable.
|
||||
: Use @ref adc_dma_int_t. */
|
||||
uint32_t type; /*!< Conversion Type.
|
||||
: Use @ref adc_conversion_t. */
|
||||
uint32_t ain; /*!< AIN. */
|
||||
} adc_ch_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/*! @struct adc_ch_t
|
||||
* @brief ADC handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t *p_tset; /*!< ADxTSETn Address. */
|
||||
__I uint32_t *p_reg; /*!< ADxREGx Address. */
|
||||
adc_ch_initial_setting_t init; /*!< Initial setting. */
|
||||
} adc_ch_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Exported_functions ADC Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t get_conversion_data(uint32_t reg);
|
||||
TXZ_Result adc_ch_init(adc_ch_t *p_obj);
|
||||
TXZ_Result adc_ch_deinit(adc_ch_t *p_obj);
|
||||
TXZ_Result adc_ch_int_enable(adc_ch_t *p_obj);
|
||||
TXZ_Result adc_ch_int_disable(adc_ch_t *p_obj);
|
||||
TXZ_Result adc_ch_get_value(adc_ch_t *p_obj, uint32_t *p_value);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __ADC_CH_H */
|
||||
|
||||
|
|
@ -0,0 +1,349 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file adc_include.h
|
||||
* @brief This file provides internal common definition.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-09-07 13:52:12 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __ADC_INCLUDE_H
|
||||
#define __ADC_INCLUDE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
#include "txz_hal.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver Peripheral Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ADC ADC
|
||||
* @brief ADC Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_define ADC Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup NULL_Pointer NULL Pointer
|
||||
* @brief NULL Pointer.
|
||||
* @{
|
||||
*/
|
||||
#define ADC_NULL ((void *)0) /*!< NULL Pointer. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group NULL_Pointer */
|
||||
|
||||
/**
|
||||
* @defgroup Parameter_Result Parameter Result
|
||||
* @brief Whether the parameter is specified or not.
|
||||
* @{
|
||||
*/
|
||||
#define ADC_PARAM_OK ((int32_t)1) /*!< Parameter is valid(specified). */
|
||||
#define ADC_PARAM_NG ((int32_t)0) /*!< Parameter is invalid(not specified). */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Parameter_Result */
|
||||
|
||||
/**
|
||||
* @defgroup ADxCR0 ADxCR0
|
||||
* @brief ADxCR0 Register.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-8 | - |
|
||||
* | 7 | ADEN |
|
||||
* | 6-3 | - |
|
||||
* | 2 | HPSGL |
|
||||
* | 1 | SGL |
|
||||
* | 0 | CNT |
|
||||
* @{
|
||||
*/
|
||||
/* ADEN */
|
||||
#define ADxCR0_ADEN_DISABLE ((uint32_t)0x00000000) /*!< ADEN :Disable */
|
||||
#define ADxCR0_ADEN_ENABLE ((uint32_t)0x00000080) /*!< ADEN :Enable */
|
||||
/* HPSGL */
|
||||
#define ADxCR0_HPSGL_ENABLE ((uint32_t)0x00000004) /*!< HPSGL :Enable */
|
||||
/* SGL */
|
||||
#define ADxCR0_SGL_ENABLE ((uint32_t)0x00000002) /*!< SGL :Enable */
|
||||
/* CNT */
|
||||
#define ADxCR0_CNT_MASK ((uint32_t)0x00000001) /*!< CNT :Mask */
|
||||
#define ADxCR0_CNT_DISABLE ((uint32_t)0x00000000) /*!< CNT :Disable */
|
||||
#define ADxCR0_CNT_ENABLE ((uint32_t)0x00000001) /*!< CNT :Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADxCR0 */
|
||||
|
||||
/**
|
||||
* @defgroup ADxCR1 ADxCR1
|
||||
* @brief ADxCR1 Register.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-8 | - |
|
||||
* | 7 | HPDMEN |
|
||||
* | 6 | CNTDMEN |
|
||||
* | 5 | SGLDMEN |
|
||||
* | 4 | TRGDMEN |
|
||||
* | 3:2 | - |
|
||||
* | 1 | HPTRGEN |
|
||||
* | 0 | TRGEN |
|
||||
* @{
|
||||
*/
|
||||
/* HPDMEN */
|
||||
#define ADxCR1_HPDMEN_DISABLE ((uint32_t)0x00000000) /*!< HPDMEN :Disable */
|
||||
#define ADxCR1_HPDMEN_ENABLE ((uint32_t)0x00000080) /*!< HPDMEN :Enable */
|
||||
/* CNTDMEN */
|
||||
#define ADxCR1_CNTDMEN_DISABLE ((uint32_t)0x00000000) /*!< CNTDMEN :Disable */
|
||||
#define ADxCR1_CNTDMEN_ENABLE ((uint32_t)0x00000040) /*!< CNTDMEN :Enable */
|
||||
/* SGLDMEN */
|
||||
#define ADxCR1_SGLDMEN_DISABLE ((uint32_t)0x00000000) /*!< SGLDMEN :Disable */
|
||||
#define ADxCR1_SGLDMEN_ENABLE ((uint32_t)0x00000020) /*!< SGLDMEN :Enable */
|
||||
/* TRGDMEN */
|
||||
#define ADxCR1_TRGDMEN_DISABLE ((uint32_t)0x00000000) /*!< TRGDMEN :Disable */
|
||||
#define ADxCR1_TRGDMEN_ENABLE ((uint32_t)0x00000010) /*!< TRGDMEN :Enable */
|
||||
/* HPTRGEN */
|
||||
#define ADxCR1_HPTRGEN_DISABLE ((uint32_t)0x00000000) /*!< HPTRGEN :Disable */
|
||||
#define ADxCR1_HPTRGEN_ENABLE ((uint32_t)0x00000002) /*!< HPTRGEN :Enable */
|
||||
/* TRGEN */
|
||||
#define ADxCR1_TRGEN_DISABLE ((uint32_t)0x00000000) /*!< TRGEN :Disable */
|
||||
#define ADxCR1_TRGEN_ENABLE ((uint32_t)0x00000001) /*!< TRGEN :Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADxCR1 */
|
||||
|
||||
/**
|
||||
* @defgroup ADxST ADxST
|
||||
* @brief ADxST Register.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-8 | - |
|
||||
* | 7 | ADBF |
|
||||
* | 6-4 | - |
|
||||
* | 3 | CNTF |
|
||||
* | 2 | SNGF |
|
||||
* | 1 | TRGF |
|
||||
* | 0 | HPF |
|
||||
* @{
|
||||
*/
|
||||
/* ADBF */
|
||||
#define ADxST_ADBF_MASK ((uint32_t)0x00000080) /*!< ADBF :Mask. */
|
||||
#define ADxST_ADBF_IDLE ((uint32_t)0x00000000) /*!< ADBF :Idle. Can stop ADCLK. */
|
||||
#define ADxST_ADBF_RUN ((uint32_t)0x00000080) /*!< ADBF :Running. Can't stop ADCLK. */
|
||||
/* CNTF */
|
||||
#define ADxST_CNTF_MASK ((uint32_t)0x00000008) /*!< CNTF :Mask. */
|
||||
#define ADxST_CNTF_IDLE ((uint32_t)0x00000000) /*!< CNTF :Idle. */
|
||||
#define ADxST_CNTF_RUN ((uint32_t)0x00000008) /*!< CNTF :Running. */
|
||||
/* SNGF */
|
||||
#define ADxST_SNGF_MASK ((uint32_t)0x00000004) /*!< SNGF :Mask. */
|
||||
#define ADxST_SNGF_IDLE ((uint32_t)0x00000000) /*!< SNGF :Idle. */
|
||||
#define ADxST_SNGF_RUN ((uint32_t)0x00000004) /*!< SNGF :Running. */
|
||||
/* TRGF */
|
||||
#define ADxST_TRGF_MASK ((uint32_t)0x00000002) /*!< TRGF :Mask. */
|
||||
#define ADxST_TRGF_IDLE ((uint32_t)0x00000000) /*!< TRGF :Idle. */
|
||||
#define ADxST_TRGF_RUN ((uint32_t)0x00000002) /*!< TRGF :Running. */
|
||||
/* PMDF */
|
||||
#define ADxST_HPF_MASK ((uint32_t)0x00000001) /*!< HPF :Mask. */
|
||||
#define ADxST_HPF_IDLE ((uint32_t)0x00000000) /*!< HPF :Idle. */
|
||||
#define ADxST_HPF_RUN ((uint32_t)0x00000001) /*!< HPF :Running. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADxST */
|
||||
|
||||
/**
|
||||
* @defgroup ADxMOD0 ADxMOD0.
|
||||
* @brief ADxMOD0 Register.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-2 | - |
|
||||
* | 1 | RCUT |
|
||||
* | 0 | DACON |
|
||||
* @{
|
||||
*/
|
||||
/* RCUT */
|
||||
#define ADxMOD0_RCUT_NORMAL ((uint32_t)0x00000000) /*!< RCUT :Normal */
|
||||
#define ADxMOD0_RCUT_IREF_CUT ((uint32_t)0x00000002) /*!< RCUT :Iref cut */
|
||||
/* DACON */
|
||||
#define ADxMOD0_DACON_OFF ((uint32_t)0x00000000) /*!< DACON :DAC off */
|
||||
#define ADxMOD0_DACON_ON ((uint32_t)0x00000001) /*!< DACON :DAC on */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADxMOD0 */
|
||||
|
||||
/**
|
||||
* @name ADxCMPEN Macro Definition.
|
||||
* @brief ADxCMPEN Register Macro Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-4 | - |
|
||||
* | 3 | CMP3EN |
|
||||
* | 2 | CMP2EN |
|
||||
* | 1 | CMP1EN |
|
||||
* | 0 | CMP0EN |
|
||||
* @{
|
||||
*/
|
||||
/* CMP3EN */
|
||||
#define ADxCMPEN_CMP3EN_DISABLE ((uint32_t)0x00000000) /*!< CMP3EN :Disable */
|
||||
#define ADxCMPEN_CMP3EN_ENABLE ((uint32_t)0x00000008) /*!< CMP3EN :Enable */
|
||||
/* CMP2EN */
|
||||
#define ADxCMPEN_CMP2EN_DISABLE ((uint32_t)0x00000000) /*!< CMP2EN :Disable */
|
||||
#define ADxCMPEN_CMP2EN_ENABLE ((uint32_t)0x00000004) /*!< CMP2EN :Enable */
|
||||
/* CMP1EN */
|
||||
#define ADxCMPEN_CMP1EN_DISABLE ((uint32_t)0x00000000) /*!< CMP1EN :Disable */
|
||||
#define ADxCMPEN_CMP1EN_ENABLE ((uint32_t)0x00000002) /*!< CMP1EN :Enable */
|
||||
/* CMP0EN */
|
||||
#define ADxCMPEN_CMP0EN_DISABLE ((uint32_t)0x00000000) /*!< CMP0EN :Disable */
|
||||
#define ADxCMPEN_CMP0EN_ENABLE ((uint32_t)0x00000001) /*!< CMP0EN :Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name ADxCMPEN Macro Definition */
|
||||
|
||||
/**
|
||||
* @name ADxTSETn Macro Definition.
|
||||
* @brief ADxTSETn Register Macro Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-8 | - |
|
||||
* | 7 | ENINT0 |
|
||||
* | 6-5 | TRGS0[1:0] |
|
||||
* | 4-0 | AINST0[4:0]|
|
||||
* @{
|
||||
*/
|
||||
/* ENINT0 */
|
||||
#define ADxTSETn_ENINT_MASK ((uint32_t)0x00000080) /*!< ENINT :Mask */
|
||||
#define ADxTSETn_ENINT_DISABLE ((uint32_t)0x00000000) /*!< ENINT :Disable */
|
||||
#define ADxTSETn_ENINT_ENABLE ((uint32_t)0x00000080) /*!< ENINT :Enable */
|
||||
/* TRGS0[1:0] */
|
||||
#define ADxTSETn_TRGS_DISABLE ((uint32_t)0x00000000) /*!< TRGS :Disable */
|
||||
#define ADxTSETn_TRGS_CNT ((uint32_t)0x00000100) /*!< TRGS :Continuation */
|
||||
#define ADxTSETn_TRGS_SGL ((uint32_t)0x00000200) /*!< TRGS :Single */
|
||||
#define ADxTSETn_TRGS_TRG ((uint32_t)0x00000300) /*!< TRGS :Universal Trigger */
|
||||
#define ADxTSETn_TRGS_PRI ((uint32_t)0x00000400) /*!< TRGS :Priority Trigger */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name ADxTSETn Macro Definition */
|
||||
|
||||
/**
|
||||
* @name ADxREGn Macro Definition.
|
||||
* @brief ADxREGn Register Macro Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-30 | - |
|
||||
* | 29 | ADOVRF_Mn |
|
||||
* | 28 | ADRF_Mn |
|
||||
* | 27-16 | ADR_Mn[11:0] |
|
||||
* | 15-4 | ADRn[11:0] |
|
||||
* | 3-2 | - |
|
||||
* | 1 | ADOVRFn |
|
||||
* | 0 | ADRFn |
|
||||
* @{
|
||||
*/
|
||||
/* ADOVRF_Mn */
|
||||
#define ADxREGn_ADOVRF_Mn_MASK ((uint32_t)0x20000000) /*!< ADOVRF_Mn :Mask */
|
||||
#define ADxREGn_ADOVRF_Mn_OFF ((uint32_t)0x00000000) /*!< ADOVRF_Mn :Flag off. */
|
||||
#define ADxREGn_ADOVRF_Mn_ON ((uint32_t)0x20000000) /*!< ADOVRF_Mn :Flag on */
|
||||
/* ADRF_Mn */
|
||||
#define ADxREGn_ADRF_Mn_MASK ((uint32_t)0x10000000) /*!< ADRF_Mn :Mask */
|
||||
#define ADxREGn_ADRF_Mn_OFF ((uint32_t)0x00000000) /*!< ADRF_Mn :Flag off. */
|
||||
#define ADxREGn_ADRF_Mn_ON ((uint32_t)0x10000000) /*!< ADRF_Mn :Flag on */
|
||||
/* ADR_Mn */
|
||||
#define ADxREGn_ADR_Mn_MASK ((uint32_t)0x0FFF0000) /*!< ADR_Mn :Mask */
|
||||
/* ADRn */
|
||||
#define ADxREGn_ADRn_MASK ((uint32_t)0x0000FFF0) /*!< ADRn :Mask */
|
||||
/* ADOVRFn */
|
||||
#define ADxREGn_ADOVRFn_MASK ((uint32_t)0x00000002) /*!< ADOVRF_Mn :Mask */
|
||||
#define ADxREGn_ADOVRFn_OFF ((uint32_t)0x00000000) /*!< ADOVRF_Mn :Flag off. */
|
||||
#define ADxREGn_ADOVRFn_ON ((uint32_t)0x00000002) /*!< ADOVRF_Mn :Flag on */
|
||||
/* ADRFn */
|
||||
#define ADxREGn_ADRFn_MASK ((uint32_t)0x00000001) /*!< ADRFn :Mask */
|
||||
#define ADxREGn_ADRFn_OFF ((uint32_t)0x00000000) /*!< ADRFn :Flag off. */
|
||||
#define ADxREGn_ADRFn_ON ((uint32_t)0x00000001) /*!< ADRFn :Flag on */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name ADxREGn Macro Definition */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_define ADC Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_typedef ADC Private Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Inline Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_fuctions ADC Private Fuctions
|
||||
* @{
|
||||
*/
|
||||
/* no define */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __ADC_INCLUDE_H */
|
||||
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file fc.h
|
||||
* @brief Flash_Userboot Sample Application.
|
||||
* @version V1.0.0.0
|
||||
* $date:: $
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __FC_H
|
||||
#define __FC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
#if defined(__FC_H)
|
||||
/** @addtogroup Periph driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup fc
|
||||
* @brief fc
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup FlashApi_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @enum fc_sr0_t
|
||||
* @brief Enumerated type definition of the FCSR0 register.
|
||||
*/
|
||||
typedef enum {
|
||||
FC_SR0_RDYBSY = (0x00000001UL) /*!< 0:Busy, 1:Ready all flash */
|
||||
} fc_sr0_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @enum fc_erase_kind_t
|
||||
* @brief FC Erase Flash Kind structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef enum {
|
||||
FC_ERASE_KIND_PAGE = (0x00000040UL), /*!< Page Erase */
|
||||
FC_ERASE_KIND_BLOCK = (0x00000030UL) /*!< Block Erase */
|
||||
} fc_erase_kind_t;
|
||||
|
||||
typedef enum {
|
||||
FC_CODE_FLASH_PAGE0 = 0, /*!< (0x5E000000UL), CODE FLASH Page0 */
|
||||
FC_CODE_FLASH_PAGE1, /*!< (0x5E001000UL), CODE FLASH Page1 */
|
||||
FC_CODE_FLASH_PAGE2, /*!< (0x5E002000UL), CODE FLASH Page2 */
|
||||
FC_CODE_FLASH_PAGE3, /*!< (0x5E003000UL), CODE FLASH Page3 */
|
||||
FC_CODE_FLASH_PAGE4, /*!< (0x5E004000UL), CODE FLASH Page4 */
|
||||
FC_CODE_FLASH_PAGE5, /*!< (0x5E005000UL), CODE FLASH Page5 */
|
||||
FC_CODE_FLASH_PAGE6, /*!< (0x5E006000UL), CODE FLASH Page6 */
|
||||
FC_CODE_FLASH_PAGE7, /*!< (0x5E007000UL), CODE FLASH Page7 */
|
||||
FC_CODE_FLASH_PAGE8, /*!< (0x5E008000UL), CODE FLASH Page8 */
|
||||
FC_CODE_FLASH_PAGE9, /*!< (0x5E009000UL), CODE FLASH Page9 */
|
||||
FC_CODE_FLASH_PAGE10, /*!< (0x5E00A000UL), CODE FLASH Page10 */
|
||||
FC_CODE_FLASH_PAGE11, /*!< (0x5E00B000UL), CODE FLASH Page11 */
|
||||
FC_CODE_FLASH_PAGE12, /*!< (0x5E00C000UL), CODE FLASH Page12 */
|
||||
FC_CODE_FLASH_PAGE13, /*!< (0x5E00D000UL), CODE FLASH Page13 */
|
||||
FC_CODE_FLASH_PAGE14, /*!< (0x5E00E000UL), CODE FLASH Page14 */
|
||||
FC_CODE_FLASH_PAGE15, /*!< (0x5E00F000UL), CODE FLASH Page15 */
|
||||
FC_CODE_FLASH_PAGE16, /*!< (0x5E010000UL), CODE FLASH Page16 */
|
||||
FC_CODE_FLASH_PAGE17, /*!< (0x5E011000UL), CODE FLASH Page17 */
|
||||
FC_CODE_FLASH_PAGE18, /*!< (0x5E012000UL), CODE FLASH Page18 */
|
||||
FC_CODE_FLASH_PAGE19, /*!< (0x5E013000UL), CODE FLASH Page19 */
|
||||
FC_CODE_FLASH_PAGE20, /*!< (0x5E014000UL), CODE FLASH Page20 */
|
||||
FC_CODE_FLASH_PAGE21, /*!< (0x5E015000UL), CODE FLASH Page21 */
|
||||
FC_CODE_FLASH_PAGE22, /*!< (0x5E016000UL), CODE FLASH Page22 */
|
||||
FC_CODE_FLASH_PAGE23, /*!< (0x5E017000UL), CODE FLASH Page23 */
|
||||
FC_CODE_FLASH_PAGE24, /*!< (0x5E018000UL), CODE FLASH Page24 */
|
||||
FC_CODE_FLASH_PAGE25, /*!< (0x5E019000UL), CODE FLASH Page25 */
|
||||
FC_CODE_FLASH_PAGE26, /*!< (0x5E01A000UL), CODE FLASH Page26 */
|
||||
FC_CODE_FLASH_PAGE27, /*!< (0x5E01B000UL), CODE FLASH Page27 */
|
||||
FC_CODE_FLASH_PAGE28, /*!< (0x5E01C000UL), CODE FLASH Page28 */
|
||||
FC_CODE_FLASH_PAGE29, /*!< (0x5E01D000UL), CODE FLASH Page29 */
|
||||
FC_CODE_FLASH_PAGE30, /*!< (0x5E01E000UL), CODE FLASH Page30 */
|
||||
FC_CODE_FLASH_PAGE31 /*!< (0x5E01F000UL), CODE FLASH Page31 */
|
||||
} fc_code_flash_page_number_t;
|
||||
|
||||
/** @} */
|
||||
/* End of group FlashApi_Exported_Types */
|
||||
|
||||
/** @defgroup FlashApi_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
//#define FC_RAMADDRESSTOP (0x20000000UL) /*!< RAM Address Top */
|
||||
//#define FC_RAMADDRESSEND (0x20003fffUL) /*!< RAM Address End */
|
||||
#define FC_CODE_FLASH_ADDRESS_TOP (0x5E000000UL) /*!< CODE FLASH Address Top */
|
||||
//#define FC_CODEFLASHADDRESSEND (0x5E01FFFFUL) /*!< CODE FLASH Address End */
|
||||
#define FC_PAGE_SIZE (0x1000) /*!< The number of bytes in a page. */
|
||||
//#define FC_CODEFLASHPAGESIZE (0x1000) /*!< CODE FLASH PAGE SIZE */
|
||||
#define FC_CODE_FLASH_WRITE_SIZE (sizeof(uint32_t)*4) /*!< CODE FLASH WRITE SIZE */
|
||||
|
||||
/** @} */
|
||||
/* End of group FlashApi_Exported_Constants */
|
||||
|
||||
|
||||
|
||||
/** @weakgroup FlashApi_Exported_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
TXZ_WorkState fc_get_status(fc_sr0_t status);
|
||||
TXZ_Result fc_write_code_flash(uint32_t* src_address, uint32_t* dst_address, uint32_t size);
|
||||
TXZ_Result fc_erase_page_code_flash(fc_code_flash_page_number_t first_page, uint8_t num_of_pages);
|
||||
TXZ_Result fc_blank_check_page_code_flash(fc_code_flash_page_number_t first_page, fc_code_flash_page_number_t lasr_page);
|
||||
TXZ_Result fc_erase_block_code_flash(uint32_t *top_addr, uint32_t *blk_addr);
|
||||
|
||||
/** @} */
|
||||
/* End of group FlashApi_Exported_FunctionPrototypes */
|
||||
|
||||
|
||||
/** @} */
|
||||
/* End of group fc */
|
||||
|
||||
/** @} */
|
||||
/* End of group Periph_driver */
|
||||
|
||||
#endif /* defined(__FC_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __FC_H */
|
|
@ -0,0 +1,386 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file bsp_rtc.h
|
||||
* @brief This file provides all the functions prototypes for RTC Class.
|
||||
* @version V1.0.0.1
|
||||
* $Date:: 2017-09-01 08:26:38 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __BSP_RTC_H
|
||||
#define __BSP_RTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
//#include "txz_sample_def.h"
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Example
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES_Exported_macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup RTC_RangeSec Range Second
|
||||
* @brief Range of Second.
|
||||
* @brief Range of Second "(RTC_RANGE_SEC_MIN <= Value <= RTC_RANGE_SEC_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_SEC_MIN ((uint8_t)0x00) /*!< Minimum Value : 0 sec */
|
||||
#define RTC_RANGE_SEC_MAX ((uint8_t)0x3B) /*!< Maximum Value :59 sec */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_RangeSec */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_RangeMin Range Minute
|
||||
* @brief Range of Minute.
|
||||
* @brief Range of Minute "(RTC_RANGE_MIN_MIN <= Value <= RTC_RANGE_MIN_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_MIN_MIN ((uint8_t)0x00) /*!< Minimum Value : 0 min */
|
||||
#define RTC_RANGE_MIN_MAX ((uint8_t)0x3B) /*!< Maximum Value :59 min */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_RangeMin */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_AlarmMin Alarm Minute
|
||||
* @brief Compare/No Compare minute.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_ALARM_MIN_OFF ((uint8_t)0x7F) /*!< No compare. */
|
||||
#define RTC_ALARM_MIN_ON ((uint8_t)0x00) /*!< Compare. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_AlarmMin */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_Range24Hour Range 24 Hour
|
||||
* @brief Range of 24 Hour.
|
||||
* @brief Range of 24 Hour "(RTC_RANGE_24_HOUR_MIN <= Value <= RTC_RANGE_24_HOUR_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_24_HOUR_MIN ((uint8_t)0x00) /*!< Minimum Value : 0 hour */
|
||||
#define RTC_RANGE_24_HOUR_MAX ((uint8_t)0x17) /*!< Maximum Value :23 hour */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_Range24Hour */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_Range12Hour Range 12 Hour
|
||||
* @brief Range of 12 Hour.
|
||||
* @brief Range of 12 Hour "(RTC_RANGE_12_HOUR_MIN <= Value <= RTC_RANGE_12_HOUR_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_12_HOUR_MIN ((uint8_t)0x00) /*!< Minimum Value : 0 hour */
|
||||
#define RTC_RANGE_12_HOUR_MAX ((uint8_t)0x0B) /*!< Maximum Value :11 hour */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_Range12Hour */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_Meridiem Meridiem
|
||||
* @brief AM/PM.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_MERIDIEM_AM ((uint8_t)0x00) /*!< A.M. */
|
||||
#define RTC_MERIDIEM_PM ((uint8_t)0x20) /*!< P.M. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_Meridiem */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_AlarmHour Alarm Hour
|
||||
* @brief Compare/No Compare hour.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_ALARM_HOUR_OFF ((uint8_t)0x3F) /*!< No compare. */
|
||||
#define RTC_ALARM_HOUR_ON ((uint8_t)0x00) /*!< Compare. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_AlarmHour */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_Day Day Of Week
|
||||
* @brief Day of week.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_DAY_SUNDAY ((uint8_t)0x00) /*!< Sunday. */
|
||||
#define RTC_DAY_MONDAY ((uint8_t)0x01) /*!< Monday. */
|
||||
#define RTC_DAY_TUESDAY ((uint8_t)0x02) /*!< Tuesday. */
|
||||
#define RTC_DAY_WEDNESDAY ((uint8_t)0x03) /*!< Wednesday. */
|
||||
#define RTC_DAY_THURSDAY ((uint8_t)0x04) /*!< Thursday. */
|
||||
#define RTC_DAY_FRIDAY ((uint8_t)0x05) /*!< Friday. */
|
||||
#define RTC_DAY_SATURDAY ((uint8_t)0x06) /*!< Saturday. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_Day */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_AlarmDay Alarm Day
|
||||
* @brief Compare/No Compare day.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_ALARM_DAY_OFF ((uint8_t)0x03) /*!< No compare. */
|
||||
#define RTC_ALARM_DAY_ON ((uint8_t)0x00) /*!< Compare. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_AlarmDay */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_RangeDate Range Date
|
||||
* @brief Range of Date.
|
||||
* @brief Range of Date "(RTC_RANGE_DATE_MIN <= Value <= RTC_RANGE_DATE_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_DATE_MIN ((uint8_t)0x00) /*!< Minimum Value :date 00 */
|
||||
#define RTC_RANGE_DATE_MAX ((uint8_t)0x1F) /*!< Maximum Value :date 31 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_RangeDate */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_AlarmDate Alarm Date
|
||||
* @brief Compare/No Compare date.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_ALARM_DATE_OFF ((uint8_t)0x3F) /*!< No compare. */
|
||||
#define RTC_ALARM_DATE_ON ((uint8_t)0x00) /*!< Compare. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_AlarmDate */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_Month Month
|
||||
* @brief Month.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_MONTH_JAN ((uint8_t)0x01) /*!< January. */
|
||||
#define RTC_MONTH_FEB ((uint8_t)0x02) /*!< February. */
|
||||
#define RTC_MONTH_MAR ((uint8_t)0x03) /*!< March. */
|
||||
#define RTC_MONTH_APR ((uint8_t)0x04) /*!< April. */
|
||||
#define RTC_MONTH_MAY ((uint8_t)0x05) /*!< May. */
|
||||
#define RTC_MONTH_JUN ((uint8_t)0x06) /*!< June. */
|
||||
#define RTC_MONTH_JUL ((uint8_t)0x07) /*!< July. */
|
||||
#define RTC_MONTH_AUG ((uint8_t)0x08) /*!< August. */
|
||||
#define RTC_MONTH_SEP ((uint8_t)0x09) /*!< September. */
|
||||
#define RTC_MONTH_OCT ((uint8_t)0x10) /*!< October. */
|
||||
#define RTC_MONTH_NOV ((uint8_t)0x11) /*!< November. */
|
||||
#define RTC_MONTH_DEC ((uint8_t)0x12) /*!< December. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_Month */
|
||||
|
||||
/**
|
||||
* @defgroup BSP_RTC_HourNotation Hour Notation
|
||||
* @brief 24/12 Hour Notation.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_HOUR_NOTATION_12 ((uint8_t)0x00) /*!< 12-hour notation. */
|
||||
#define RTC_HOUR_NOTATION_24 ((uint8_t)0x01) /*!< 24-hour notation. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_RTC_HourNotation */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_RangeYear Range Year
|
||||
* @brief Range of Year.
|
||||
* @brief Range of Year "(RTC_RANGE_YEAR_MIN <= Value <= RTC_RANGE_YEAR_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define RTC_RANGE_YEAR_MIN ((uint8_t)0x00) /*!< Minimum Value :year 00 */
|
||||
#define RTC_RANGE_YEAR_MAX ((uint8_t)0x63) /*!< Maximum Value :year 99 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_RangeYear */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_LeapYear Leap Year
|
||||
* @brief Leap Year.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_LEAP_YEAR_0 ((uint8_t)0x00) /*!< Leap year. */
|
||||
#define RTC_LEAP_YEAR_1 ((uint8_t)0x01) /*!< 1 year since leap year. */
|
||||
#define RTC_LEAP_YEAR_2 ((uint8_t)0x02) /*!< 2 years since leap year. */
|
||||
#define RTC_LEAP_YEAR_3 ((uint8_t)0x03) /*!< 3 years since leap year. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_LeapYear */
|
||||
|
||||
/**
|
||||
* @defgroup RTC_IntSource Interrupt Source Signal
|
||||
* @brief Interrupt Source Signal.
|
||||
* @{
|
||||
*/
|
||||
#define RTC_INT_SRC_1HZ ((uint8_t)0x47) /*!< 1 Hz. */
|
||||
#define RTC_INT_SRC_2HZ ((uint8_t)0xC3) /*!< 2 Hz. */
|
||||
#define RTC_INT_SRC_4HZ ((uint8_t)0xC5) /*!< 4 Hz. */
|
||||
#define RTC_INT_SRC_8HZ ((uint8_t)0x01) /*!< 8 Hz. */
|
||||
#define RTC_INT_SRC_16HZ ((uint8_t)0xC6) /*!< 16 Hz. */
|
||||
#define RTC_INT_SRC_ALARM ((uint8_t)0xC7) /*!< Alarm. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group RTC_IntSource */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup BSP_UTILITIES_Exported_typedef
|
||||
* @{
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief RTC handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct uart_handle
|
||||
{
|
||||
TSB_RTC_TypeDef *p_instance; /*!< Registers base address. */
|
||||
} rtc_t;
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup BSP_UTILITIES_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result m4g9_rtc_init(rtc_t *p_obj);
|
||||
TXZ_Result rtc_deinit(rtc_t *p_obj);
|
||||
TXZ_Result rtc_enable_int(rtc_t *p_obj);
|
||||
TXZ_Result rtc_disable_int(rtc_t *p_obj);
|
||||
TXZ_Result rtc_set_int_source(rtc_t *p_obj, uint8_t src);
|
||||
TXZ_Result rtc_set_hour_notation(rtc_t *p_obj, uint8_t notation);
|
||||
TXZ_Result rtc_get_hour_notation(rtc_t *p_obj, uint8_t *p_notation);
|
||||
/* clock */
|
||||
TXZ_Result rtc_clock_enable(rtc_t *p_obj);
|
||||
TXZ_Result rtc_clock_disable(rtc_t *p_obj);
|
||||
TXZ_Result rtc_clock_reset_counter(rtc_t *p_obj);
|
||||
TXZ_Result rtc_clock_set_sec(rtc_t *p_obj, uint8_t sec);
|
||||
TXZ_Result rtc_clock_get_sec(rtc_t *p_obj, uint8_t *p_sec);
|
||||
TXZ_Result rtc_clock_set_min(rtc_t *p_obj, uint8_t min);
|
||||
TXZ_Result rtc_clock_get_min(rtc_t *p_obj, uint8_t *p_min);
|
||||
TXZ_Result rtc_clock_set_hour_24(rtc_t *p_obj, uint8_t hour);
|
||||
TXZ_Result rtc_clock_get_hour_24(rtc_t *p_obj, uint8_t *p_hour);
|
||||
TXZ_Result rtc_clock_set_hour_12(rtc_t *p_obj, uint8_t meridiem, uint8_t hour);
|
||||
TXZ_Result rtc_clock_get_hour_12(rtc_t *p_obj, uint8_t *p_meridiem, uint8_t *p_hour);
|
||||
TXZ_Result rtc_clock_set_day(rtc_t *p_obj, uint8_t day);
|
||||
TXZ_Result rtc_clock_get_day(rtc_t *p_obj, uint8_t *p_day);
|
||||
TXZ_Result rtc_clock_set_date(rtc_t *p_obj, uint8_t date);
|
||||
TXZ_Result rtc_clock_get_date(rtc_t *p_obj, uint8_t *p_date);
|
||||
TXZ_Result rtc_clock_set_month(rtc_t *p_obj, uint8_t month);
|
||||
TXZ_Result rtc_clock_get_month(rtc_t *p_obj, uint8_t *p_month);
|
||||
TXZ_Result rtc_clock_set_year(rtc_t *p_obj, uint8_t year);
|
||||
TXZ_Result rtc_clock_get_year(rtc_t *p_obj, uint8_t *p_year);
|
||||
TXZ_Result rtc_clock_set_leap(rtc_t *p_obj, uint8_t leap);
|
||||
TXZ_Result rtc_clock_get_leap(rtc_t *p_obj, uint8_t *p_leap);
|
||||
/* alarm */
|
||||
TXZ_Result rtc_alarm_enable(rtc_t *p_obj);
|
||||
TXZ_Result rtc_alarm_disable(rtc_t *p_obj);
|
||||
TXZ_Result rtc_alarm_reset(rtc_t *p_obj);
|
||||
TXZ_Result rtc_alarm_set_min(rtc_t *p_obj, uint8_t compare, uint8_t min);
|
||||
TXZ_Result rtc_alarm_get_min(rtc_t *p_obj, uint8_t *p_compare, uint8_t *p_min);
|
||||
TXZ_Result rtc_alarm_set_hour_24(rtc_t *p_obj, uint8_t compare, uint8_t hour);
|
||||
TXZ_Result rtc_alarm_get_hour_24(rtc_t *p_obj, uint8_t *p_compare, uint8_t *p_hour);
|
||||
TXZ_Result rtc_alarm_set_hour_12(rtc_t *p_obj, uint8_t compare, uint8_t meridiem, uint8_t hour);
|
||||
TXZ_Result rtc_alarm_get_hour_12(rtc_t *p_obj, uint8_t *p_compare, uint8_t *p_meridiem, uint8_t *p_hour);
|
||||
TXZ_Result rtc_alarm_set_day(rtc_t *p_obj, uint8_t compare, uint8_t day);
|
||||
TXZ_Result rtc_alarm_get_day(rtc_t *p_obj, uint8_t *p_compare, uint8_t *p_day);
|
||||
TXZ_Result rtc_alarm_set_date(rtc_t *p_obj, uint8_t compare, uint8_t date);
|
||||
TXZ_Result rtc_alarm_get_date(rtc_t *p_obj, uint8_t *p_compare, uint8_t *p_date);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group BSP_UTILITIES */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Sample_Appli */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __BSP_RTC_H */
|
||||
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_cg.h
|
||||
* @brief This file provides all the functions prototypes for CG driver.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2018-04-02 19:31:41 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __CG_H
|
||||
#define __CG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup CG CG
|
||||
* @brief CG Driver.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Exported_define CG Exported Define
|
||||
* @{
|
||||
*/
|
||||
/* no define */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Exported_define CG Exported Define
|
||||
* @{
|
||||
*/
|
||||
/* no define */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Exported_typedef CG Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief CG member.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_CG_TypeDef *p_instance; /*!< Registers base address. */
|
||||
} cg_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Exported_functions CG Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t cg_get_fsysm(cg_t *p_obj);
|
||||
uint32_t cg_get_phyt0(cg_t *p_obj);
|
||||
uint32_t cg_get_mphyt0(cg_t *p_obj);
|
||||
TXZ_Result cg_ihosc_enable(cg_t *p_obj);
|
||||
TXZ_Result cg_ihosc_disable(cg_t *p_obj);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __CG_H */
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_driver_def.h
|
||||
* @brief All common macro and definition for TXZ peripheral drivers
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-07-21 15:39:36 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TXZ_DRIVER_DEF_H
|
||||
#define __TXZ_DRIVER_DEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup Periph_Driver Peripheral Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TXZ_DRIVER_DEF TXZ DRIVER DEF
|
||||
* @brief All common macro and definition for TXZ peripheral drivers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup Device_Header_Included Device Header Included
|
||||
* @brief Include the Device header file of a Target.
|
||||
* @{
|
||||
*/
|
||||
#include "TMPM4G9.h" /*!< TMPM4Gx Group Header file. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Device_Header */
|
||||
|
||||
|
||||
/** @defgroup TXZ_Exported_typedef TXZ Exported typedef
|
||||
* @{
|
||||
*/
|
||||
typedef enum {
|
||||
TXZ_SUCCESS = 0U,
|
||||
TXZ_ERROR = 1U
|
||||
} TXZ_Result;
|
||||
|
||||
typedef enum {
|
||||
TXZ_BUSY = 0U,
|
||||
TXZ_DONE = 1U
|
||||
} TXZ_WorkState;
|
||||
|
||||
typedef enum {
|
||||
TXZ_DISABLE = 0U,
|
||||
TXZ_ENABLE = 1U
|
||||
} TXZ_FunctionalState;
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group TXZ_Exported_typedef */
|
||||
|
||||
/** @defgroup TXZ_Exported_macro TXZ Exported macro
|
||||
* @{
|
||||
*/
|
||||
#define IS_TXZ_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||
|
||||
#define IS_POINTER_NOT_NULL(param) ((void*)(param)!=(void*)0)
|
||||
|
||||
/**
|
||||
* @brief 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 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group TXZ_Exported_macro */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group TXZ_DRIVER_DEF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __TXZ_DRIVER_DEF_H */
|
|
@ -0,0 +1,552 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_fuart.h
|
||||
* @brief This file provides all the functions prototypes for FUART driver.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-06 10:43:01 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __FUART_H
|
||||
#define __FUART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup FUART FUART
|
||||
* @brief FUART Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup FUART_Exported_define FUART Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup FUART_FifoMax Max Num of FIFO
|
||||
* @brief Max Num of Tx/Rx Fifo.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_TX_FIFO_MAX ((uint32_t)0x00000020) /*!< TX FIFO Max. */
|
||||
#define FUART_RX_FIFO_MAX ((uint32_t)0x00000020) /*!< RX FIFO Max. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_FifoMax */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_CTSHandshake CTS Handshake
|
||||
* @brief Available CTS Handshake Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_CTS_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define FUART_CTS_ENABLE ((uint32_t)0x00008000) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_CTSHandshake */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_RTSHandshake RTS Handshake
|
||||
* @brief Available RTS Handshake Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_RTS_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define FUART_RTS_ENABLE ((uint32_t)0x00004000) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_RTSHandshake */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_FIFO FIFO Enable
|
||||
* @brief FIFO Enable Bit Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_FIFO_DISABLE ((uint32_t)0x00000000) /*!< Disable. */
|
||||
#define FUART_FIFO_ENABLE ((uint32_t)0x00000010) /*!< Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_FIFO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_StopBit Stop Bit
|
||||
* @brief Stop Bit Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_STOP_BIT_1 ((uint32_t)0x00000000) /*!< 1 bit */
|
||||
#define FUART_STOP_BIT_2 ((uint32_t)0x00000008) /*!< 2 bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_StopBit */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_ParityBit Parity Bit
|
||||
* @brief Parity Bit Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_PARITY_BIT_ODD ((uint32_t)0x00000000) /*!< Odd Parity */
|
||||
#define FUART_PARITY_BIT_EVEN ((uint32_t)0x00000004) /*!< Even Parity */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ParityBit */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_ParityEnable Parity Enable
|
||||
* @brief Enable/Disable Parity Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_PARITY_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_PARITY_ENABLE ((uint32_t)0x00000002) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ParityEnable */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_StaticParityEnable Static Parity Enable
|
||||
* @brief Enable/Disable Static Parity Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_STATIC_PARITY_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_STATIC_PARITY_ENABLE ((uint32_t)0x00000080) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ParityEnable */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_DataLength Data Length
|
||||
* @brief Data Length Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_DATA_LENGTH_5 ((uint32_t)0x00000000) /*!< 5 bit */
|
||||
#define FUART_DATA_LENGTH_6 ((uint32_t)0x00000020) /*!< 6 bit */
|
||||
#define FUART_DATA_LENGTH_7 ((uint32_t)0x00000040) /*!< 7 bit */
|
||||
#define FUART_DATA_LENGTH_8 ((uint32_t)0x00000060) /*!< 8 bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_DataLength */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_FIFO_Level FIFO Level
|
||||
* @brief FIFO Level Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_FIFO_LEVEL_4 ((uint32_t)0x00000000) /*!< 4 level */
|
||||
#define FUART_FIFO_LEVEL_8 ((uint32_t)0x00000001) /*!< 8 level */
|
||||
#define FUART_FIFO_LEVEL_16 ((uint32_t)0x00000002) /*!< 16 level */
|
||||
#define FUART_FIFO_LEVEL_24 ((uint32_t)0x00000003) /*!< 24 level */
|
||||
#define FUART_FIFO_LEVEL_28 ((uint32_t)0x00000004) /*!< 28 level */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_DataLength */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_TxInterrupt Tx Interrpt
|
||||
* @brief Available Transmit Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_TX_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define FUART_TX_INT_ENABLE ((uint32_t)0x00000020) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_TxInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_RxInterrupt Rx Interrpt
|
||||
* @brief Available Receive Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_RX_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define FUART_RX_INT_ENABLE ((uint32_t)0x00000010) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_RxInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_ErrorInterrupt Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @defgroup FUART_OVER_RUN_ErrorInterrupt Over Run Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_OV_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_OV_ERR_INT_ENABLE ((uint32_t)0x00000400) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_OVER_RUN_ErrorInterrupt */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_BREAK_ErrorInterrupt Break Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_BK_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_BK_ERR_INT_ENABLE ((uint32_t)0x00000200) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_BREAK_ErrorInterrupt */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_PARITY_ErrorInterrupt Parity Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_PA_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_PA_ERR_INT_ENABLE ((uint32_t)0x00000100) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_PARITY_ErrorInterrupt */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_FRAMING_ErrorInterrupt Framing Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_FR_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_FR_ERR_INT_ENABLE ((uint32_t)0x00000080) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_FRAMING_ErrorInterrupt */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_RX_TIMEOUT_ErrorInterrupt Rx Timeout Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_TO_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define FUART_TO_ERR_INT_ENABLE ((uint32_t)0x00000040) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_RX_TIMEOUT_RUN_ErrorInterrupt */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ErrorInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_RangeK Range K
|
||||
* @brief Range of K Macro Definisiton.
|
||||
* @brief Range of K be set "(UART_RANGE_K_MIN <= Value <= FUART_RANGE_K_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define FUART_RANGE_K_MIN ((uint32_t)0x00000000) /*!< Minimum Value :K=0 */
|
||||
#define FUART_RANGE_K_MAX ((uint32_t)0x0000003F) /*!< Maximum Value :K=63 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_RangeK */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_RangeN Range N
|
||||
* @brief Range of N Macro Definisiton.
|
||||
* @brief Range of N be set "(UART_RANGE_N_MIN <= Value <= FUART_RANGE_N_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define FUART_RANGE_N_MIN ((uint32_t)0x00000002) /*!< Minimum Value :N=2 */
|
||||
#define FUART_RANGE_N_MAX ((uint32_t)0x0000FFFF) /*!< Maximum Value :N=65535 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_RangeN */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_OverrunErr Overrun Error
|
||||
* @brief Overrun Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_OVERRUN_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define FUART_OVERRUN_ERR ((uint32_t)0x00000008) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_OverrunErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_BreakErr Break Error
|
||||
* @brief Break Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_BREAK_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define FUART_BREAK_ERR ((uint32_t)0x00000004) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_BreakErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_ParityErr Parity Error
|
||||
* @brief Parity Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_PARITY_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define FUART_PARITY_ERR ((uint32_t)0x00000002) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ParityErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup FUART_FramingErr Framing Error
|
||||
* @brief Framing Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_FRAMING_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define FUART_FRAMING_ERR ((uint32_t)0x00000001) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_FramingErr */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxFR FUARTxFR Register
|
||||
* @brief FUARTxFR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
/* FR */
|
||||
#define FUARTxFR_TXFE_MASK ((uint32_t)0x00000080) /*!< TXFE :Mask */
|
||||
#define FUARTxFR_RXFF_MASK ((uint32_t)0x00000040) /*!< RXFF :Mask */
|
||||
#define FUARTxFR_TXFF_MASK ((uint32_t)0x00000020) /*!< TXFF :Mask */
|
||||
#define FUARTxFR_RXFE_MASK ((uint32_t)0x00000010) /*!< RXFE :Mask */
|
||||
#define FUARTxFR_BUSY_MASK ((uint32_t)0x00000008) /*!< BUSY :Mask */
|
||||
#define FUARTxFR_CTS_MASK ((uint32_t)0x00000001) /*!< CTS :Mask */
|
||||
|
||||
#define FUARTxFR_TXFE_FLAG_SET ((uint32_t)0x00000080) /*!< TXFE :Flag Set */
|
||||
#define FUARTxFR_RXFF_FLAG_SET ((uint32_t)0x00000040) /*!< RXFF :Flag Set */
|
||||
#define FUARTxFR_TXFF_FLAG_SET ((uint32_t)0x00000020) /*!< TXFF :Flag Set */
|
||||
#define FUARTxFR_RXFE_FLAG_SET ((uint32_t)0x00000010) /*!< RXFE :Flag Set */
|
||||
#define FUARTxFR_BUSY_FLAG_SET ((uint32_t)0x00000008) /*!< BUSY :Flag Set */
|
||||
#define FUARTxFR_CTS_FLAG_SET ((uint32_t)0x00000001) /*!< CTS :Flag Set */
|
||||
|
||||
#define FUARTxFR_TXFE_FLAG_CLR ((uint32_t)0x00000000) /*!< TXFE :Flag Clear */
|
||||
#define FUARTxFR_RXFF_FLAG_CLR ((uint32_t)0x00000000) /*!< RXFF :Flag Clear */
|
||||
#define FUARTxFR_TXFF_FLAG_CLR ((uint32_t)0x00000000) /*!< TXFF :Flag Clear */
|
||||
#define FUARTxFR_RXFE_FLAG_CLR ((uint32_t)0x00000000) /*!< RXFE :Flag Clear */
|
||||
#define FUARTxFR_BUSY_FLAG_CLR ((uint32_t)0x00000000) /*!< BUSY :Flag Clear */
|
||||
#define FUARTxFR_CTS_FLAG_CLR ((uint32_t)0x00000000) /*!< CTS :Flag Clear */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxFR */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup FUART_Exported_define FUART Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup FUART_Exported_typedef FUART Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive event information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_data; /*!< The buffer to receive data. */
|
||||
uint32_t num; /*!< The number of receive data. */
|
||||
} fuart_receive_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit data information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_data; /*!< The buffer to transmit data. */
|
||||
uint32_t num; /*!< The number of transmit data. */
|
||||
} fuart_transmit_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Boudrate setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t brk; /*!< Division Value K.
|
||||
: K Range ( FUART_RANGE_K_MIN <= K =< FUART_RANGE_K_MAX ) @ref FUART_RangeK */
|
||||
uint32_t brn; /*!< Division Value N.
|
||||
: N Range ( FUART_RANGE_N_MIN <= N =< FUART_RANGE_N_MAX ) @ref FUART_RangeN */
|
||||
} fuart_boudrate_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit FIFO setting.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t inttx; /*!< Available Transmit Interrupt.
|
||||
: Use @ref FUART_TxInterrupt */
|
||||
uint32_t level; /*!< Transmit Fill Level.
|
||||
: Use @ref FUART_FIFO_Level */
|
||||
} fuart_tx_int_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive FIFO setting.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t intrx; /*!< Available Receive Interrupt.
|
||||
: Use @ref FUART_RxInterrupt */
|
||||
uint32_t level; /*!< Receive Fill Level.
|
||||
: Use @ref FUART_FIFO_Level */
|
||||
} fuart_rx_int_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Initial setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t id; /*!< ID: User value. */
|
||||
fuart_boudrate_t boudrate; /*!< Boudrate setting.
|
||||
: Use @ref fuart_boudrate_t */
|
||||
uint32_t interr; /*!< Available Error Interrupt.
|
||||
: Use @ref FUART_ErrorInterrupt */
|
||||
fuart_tx_int_t tx_int; /*!< Transmit Interrupt setting.
|
||||
: Use @ref fuart_tx_int_t */
|
||||
fuart_rx_int_t rx_int; /*!< Receive Interrupt setting.
|
||||
: Use @ref fuart_rx_int_t */
|
||||
uint32_t ctse; /*!< Available CTS Handshake.
|
||||
: Use @ref FUART_CTSHandshake */
|
||||
uint32_t rtse; /*!< Available RTS Handshake.
|
||||
: Use @ref FUART_RTSHandshake */
|
||||
uint32_t stpa; /*!< Enable/Disable Static Parity.
|
||||
: Use @ref FUART_StaticParityEnable */
|
||||
uint32_t sm; /*!< Data Length.
|
||||
: Use @ref FUART_DataLength */
|
||||
uint32_t fifo; /*!< Available FIFO.
|
||||
: Use @ref FUART_FIFO */
|
||||
uint32_t sblen; /*!< Stop Bit.
|
||||
: Use @ref FUART_StopBit */
|
||||
uint32_t even; /*!< Odd/Even Parity Bit.
|
||||
: Use @ref FUART_ParityBit */
|
||||
uint32_t pe; /*!< Enable/Disable Parity Bit.
|
||||
: Use @ref FUART_ParityEnable */
|
||||
} fuart_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief FUART handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_FURT_TypeDef *p_instance; /*!< Registers base address. */
|
||||
fuart_initial_setting_t init; /*!< Initial setting. */
|
||||
/*------------------------------------------*/
|
||||
/*!
|
||||
@brief Transmit Informatin.
|
||||
*/
|
||||
/*------------------------------------------*/
|
||||
struct
|
||||
{
|
||||
uint32_t rp; /*!< Num of transmited data. */
|
||||
fuart_transmit_t info; /*!< Transmit Data Information. */
|
||||
void (*handler)(uint32_t id, TXZ_Result result); /*!< Transmit Event handler. */
|
||||
} transmit;
|
||||
/*------------------------------------------*/
|
||||
/*!
|
||||
@brief Receive Informatin.
|
||||
*/
|
||||
/*------------------------------------------*/
|
||||
struct
|
||||
{
|
||||
uint32_t wp; /*!< Num of received data. */
|
||||
fuart_receive_t info; /*!< Receive Data Information. */
|
||||
void (*handler)(uint32_t id, TXZ_Result result, fuart_receive_t *p_info); /*!< Receive Event handler. */
|
||||
} receive;
|
||||
} fuart_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup FUART_Exported_functions FUART Exported Functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result fuart_init(fuart_t *p_obj);
|
||||
TXZ_Result fuart_deinit(fuart_t *p_obj);
|
||||
TXZ_Result fuart_discard_transmit(fuart_t *p_obj);
|
||||
TXZ_Result fuart_discard_receive(fuart_t *p_obj);
|
||||
TXZ_Result fuart_transmitIt(fuart_t *p_obj, fuart_transmit_t *p_info);
|
||||
TXZ_Result fuart_receiveIt(fuart_t *p_obj, fuart_receive_t *p_info);
|
||||
void fuart_transmit_irq_handler(fuart_t *p_obj);
|
||||
void fuart_receive_irq_handler(fuart_t *p_obj);
|
||||
void fuart_error_irq_handler(fuart_t *p_obj);
|
||||
void fuart_irq_handler(fuart_t *p_obj);
|
||||
TXZ_Result fuart_get_status(fuart_t *p_obj, uint32_t *p_status);
|
||||
TXZ_Result fuart_get_error(fuart_t *p_obj, uint32_t *p_error);
|
||||
TXZ_Result fuart_get_boudrate_setting(uint32_t clock, uint32_t boudrate, fuart_boudrate_t *p_setting);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __UART_H */
|
||||
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_fuart_ex.h
|
||||
* @brief This file provides all the functions prototypes for FUART driver.
|
||||
* @brief Extended functionality.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-06 10:43:01 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __FUART_EX_H
|
||||
#define __FUART_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
#include "txz_fuart.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup FUART
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Exported_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result fuart_send_break(fuart_t *p_obj);
|
||||
TXZ_Result fuart_stop_break(fuart_t *p_obj);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __FUART_EX_H */
|
||||
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_fuart_include.h
|
||||
* @brief This file provides internal common definition.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-06 10:43:01 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __FUART_INCLUDE_H
|
||||
#define __FUART_INCLUDE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup FUART
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup FUART_NullPointer Null Pointer
|
||||
* @brief Null Pointer.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_NULL ((void *)0) /*!< Null Pointer. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_NullPointer */
|
||||
|
||||
/**
|
||||
* @defgroup FUART_ParameterResult Parameter Check Result
|
||||
* @brief Whether the parameter is specified or not.
|
||||
* @{
|
||||
*/
|
||||
#define FUART_PARAM_OK ((int32_t)1) /*!< Parameter is valid(specified). */
|
||||
#define FUART_PARAM_NG ((int32_t)0) /*!< Parameter is invalid(not specified). */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_ParameterResult */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxDR FUARTxDR Register
|
||||
* @brief FUARTxDR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
/* DR */
|
||||
#define FUARTxDR_DR_8BIT_MASK ((uint32_t)0x000000FF) /*!< DR :Mask for 8bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxDR */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxCR FUARTxCR Register
|
||||
* @brief FUARTxCR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxCR_CTSEN_MASK ((uint32_t)0x00008000) /*!< CTSEN :MASK. */
|
||||
#define FUARTxCR_RTSEN_MASK ((uint32_t)0x00004000) /*!< RTSEN :MASK. */
|
||||
#define FUARTxCR_RXE_MASK ((uint32_t)0x00000200) /*!< RXE :MASK. */
|
||||
#define FUARTxCR_TXE_MASK ((uint32_t)0x00000100) /*!< TXE :MASK. */
|
||||
#define FUARTxCR_UARTEN_MSK ((uint32_t)0x00000001) /*!< UARTEN :MASK. */
|
||||
|
||||
#define FUARTxCR_CTSEN_DISABLE ((uint32_t)0x00000000) /*!< CTSEN :Not Available. */
|
||||
#define FUARTxCR_RTSEN_DISABLE ((uint32_t)0x00000000) /*!< RTSEN :Not Available. */
|
||||
#define FUARTxCR_RXE_DISABLE ((uint32_t)0x00000000) /*!< RXE :Disable. */
|
||||
#define FUARTxCR_TXE_DISABLE ((uint32_t)0x00000000) /*!< TXE :Disable. */
|
||||
#define FUARTxCR_UARTEN_DISABLE ((uint32_t)0x00000000) /*!< UARTEN :Disable. */
|
||||
|
||||
#define FUARTxCR_CTSEN_ENABLE ((uint32_t)0x00008000) /*!< CTSEN :Available. */
|
||||
#define FUARTxCR_RTSEN_ENABLE ((uint32_t)0x00004000) /*!< RTSEN :Available. */
|
||||
#define FUARTxCR_RXE_ENABLE ((uint32_t)0x00000200) /*!< RXE :Enable. */
|
||||
#define FUARTxCR_TXE_ENABLE ((uint32_t)0x00000100) /*!< TXE :Enable. */
|
||||
#define FUARTxCR_UARTEN_ENABLE ((uint32_t)0x00000001) /*!< UARTEN :Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxRSR */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxRSR FUARTxRSR Register
|
||||
* @brief FUARTxRSR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxRSR_OE_MASK ((uint32_t)0x00000008) /*!< OE :Mask */
|
||||
#define FUARTxRSR_BE_MASK ((uint32_t)0x00000004) /*!< BE :Mask */
|
||||
#define FUARTxRSR_PE_MASK ((uint32_t)0x00000002) /*!< PE :Mask */
|
||||
#define FUARTxRSR_FE_MASK ((uint32_t)0x00000001) /*!< FE :Mask */
|
||||
|
||||
#define FUARTxRSR_OE_ERR ((uint32_t)0x00000008) /*!< OE :Error */
|
||||
#define FUARTxRSR_BE_ERR ((uint32_t)0x00000004) /*!< BE :Error */
|
||||
#define FUARTxRSR_PE_ERR ((uint32_t)0x00000002) /*!< PE :Error */
|
||||
#define FUARTxRSR_FE_ERR ((uint32_t)0x00000001) /*!< FE :Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxRSR */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxECR FUARTxECR Register
|
||||
* @brief FUARTxECR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
/* ECR */
|
||||
#define FUARTxECR_OE_MASK ((uint32_t)0x00000008) /*!< OE :Mask */
|
||||
#define FUARTxECR_BE_MASK ((uint32_t)0x00000004) /*!< BE :Mask */
|
||||
#define FUARTxECR_PE_MASK ((uint32_t)0x00000002) /*!< PE :Mask */
|
||||
#define FUARTxECR_FE_MASK ((uint32_t)0x00000001) /*!< FE :Mask */
|
||||
|
||||
#define FUARTxECR_OE_CLR ((uint32_t)0x00000008) /*!< OE :Clear */
|
||||
#define FUARTxECR_BE_CLR ((uint32_t)0x00000004) /*!< BE :Clear */
|
||||
#define FUARTxECR_PE_CLR ((uint32_t)0x00000002) /*!< PE :Clear */
|
||||
#define FUARTxECR_FE_CLR ((uint32_t)0x00000001) /*!< FE :Clear */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxECR */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxLCR_H FUARTxRSR Register
|
||||
* @brief FUARTxLCR_H Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxLCR_H_BRK_MASK ((uint32_t)0x00000001) /*!< BRK :Mask */
|
||||
|
||||
#define FUARTxLCR_H_BRK_SEND ((uint32_t)0x00000001) /*!< BRK :Send */
|
||||
#define FUARTxLCR_H_BRK_STOP ((uint32_t)0x00000000) /*!< BRK :Stop */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxLCR_H */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxRIS FUARTxRIS Register
|
||||
* @brief FUARTxRIS Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxRIS_OERIS_MASK ((uint32_t)0x00000400) /*!< OERIS :Mask */
|
||||
#define FUARTxRIS_BERIS_MASK ((uint32_t)0x00000200) /*!< BERIS :Mask */
|
||||
#define FUARTxRIS_PERIS_MASK ((uint32_t)0x00000100) /*!< PRRIS :Mask */
|
||||
#define FUARTxRIS_FERIS_MASK ((uint32_t)0x00000080) /*!< FERIS :Mask */
|
||||
#define FUARTxRIS_RTRIS_MASK ((uint32_t)0x00000040) /*!< RTRIS :Mask */
|
||||
#define FUARTxRIS_TXRIS_MASK ((uint32_t)0x00000020) /*!< TXRIS :Mask */
|
||||
#define FUARTxRIS_RXRIS_MASK ((uint32_t)0x00000010) /*!< RXRIS :Mask */
|
||||
|
||||
#define FUARTxRIS_OERIS_REQ ((uint32_t)0x00000400) /*!< OERIS :Request */
|
||||
#define FUARTxRIS_BERIS_REQ ((uint32_t)0x00000200) /*!< BERIS :Request */
|
||||
#define FUARTxRIS_PERIS_REQ ((uint32_t)0x00000100) /*!< PRRIS :Request */
|
||||
#define FUARTxRIS_FERIS_REQ ((uint32_t)0x00000080) /*!< FERIS :Request */
|
||||
#define FUARTxRIS_RTRIS_REQ ((uint32_t)0x00000040) /*!< RTRIS :Request */
|
||||
#define FUARTxRIS_TXRIS_REQ ((uint32_t)0x00000020) /*!< TXRIS :Request */
|
||||
#define FUARTxRIS_RXRIS_REQ ((uint32_t)0x00000010) /*!< RXRIS :Request */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxRIS */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxMIS FUARTxMIS Register
|
||||
* @brief FUARTxMIS Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxMIS_OEMIS_MASK ((uint32_t)0x00000400) /*!< OEMIS :Mask */
|
||||
#define FUARTxMIS_BEMIS_MASK ((uint32_t)0x00000200) /*!< BEMIS :Mask */
|
||||
#define FUARTxMIS_PEMIS_MASK ((uint32_t)0x00000100) /*!< PRMIS :Mask */
|
||||
#define FUARTxMIS_FEMIS_MASK ((uint32_t)0x00000080) /*!< FEMIS :Mask */
|
||||
#define FUARTxMIS_RTMIS_MASK ((uint32_t)0x00000040) /*!< RTMIS :Mask */
|
||||
#define FUARTxMIS_TXMIS_MASK ((uint32_t)0x00000020) /*!< TXMIS :Mask */
|
||||
#define FUARTxMIS_RXMIS_MASK ((uint32_t)0x00000010) /*!< RXMIS :Mask */
|
||||
|
||||
#define FUARTxMIS_OEMIS_REQ ((uint32_t)0x00000400) /*!< OEMIS :Request */
|
||||
#define FUARTxMIS_BEMIS_REQ ((uint32_t)0x00000200) /*!< BEMIS :Request */
|
||||
#define FUARTxMIS_PEMIS_REQ ((uint32_t)0x00000100) /*!< PRMIS :Request */
|
||||
#define FUARTxMIS_FEMIS_REQ ((uint32_t)0x00000080) /*!< FEMIS :Request */
|
||||
#define FUARTxMIS_RTMIS_REQ ((uint32_t)0x00000040) /*!< RTMIS :Request */
|
||||
#define FUARTxMIS_TXMIS_REQ ((uint32_t)0x00000020) /*!< TXMIS :Request */
|
||||
#define FUARTxMIS_RXMIS_REQ ((uint32_t)0x00000010) /*!< RXMIS :Request */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxMIS */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxICR FUARTxICR Register
|
||||
* @brief FUARTxICR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxICR_OEIC_MASK ((uint32_t)0x00000400) /*!< OEIC :Mask */
|
||||
#define FUARTxICR_BEIC_MASK ((uint32_t)0x00000200) /*!< BEIC :Mask */
|
||||
#define FUARTxICR_PEIC_MASK ((uint32_t)0x00000100) /*!< PRIC :Mask */
|
||||
#define FUARTxICR_FEIC_MASK ((uint32_t)0x00000080) /*!< FEIC :Mask */
|
||||
#define FUARTxICR_RTIC_MASK ((uint32_t)0x00000040) /*!< RTIC :Mask */
|
||||
#define FUARTxICR_TXIC_MASK ((uint32_t)0x00000020) /*!< TXIC :Mask */
|
||||
#define FUARTxICR_RXIC_MASK ((uint32_t)0x00000010) /*!< RXIC :Mask */
|
||||
|
||||
#define FUARTxICR_OEIC_CLR ((uint32_t)0x00000400) /*!< OEIC :Request */
|
||||
#define FUARTxICR_BEIC_CLR ((uint32_t)0x00000200) /*!< BEIC :Request */
|
||||
#define FUARTxICR_PEIC_CLR ((uint32_t)0x00000100) /*!< PRIC :Request */
|
||||
#define FUARTxICR_FEIC_CLR ((uint32_t)0x00000080) /*!< FEIC :Request */
|
||||
#define FUARTxICR_RTIC_CLR ((uint32_t)0x00000040) /*!< RTIC :Request */
|
||||
#define FUARTxICR_TXIC_CLR ((uint32_t)0x00000020) /*!< TXIC :Request */
|
||||
#define FUARTxICR_RXIC_CLR ((uint32_t)0x00000010) /*!< RXIC :Request */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxICR */
|
||||
|
||||
/**
|
||||
* @defgroup FUARTxDMACR FUARTxDMACR Register
|
||||
* @brief FUARTxDMACR Register Definition.
|
||||
* @{
|
||||
*/
|
||||
#define FUARTxDMACR_RXDMAE_MASK ((uint32_t)0x00000001) /*!< RXDMAE :Mask */
|
||||
#define FUARTxDMACR_TXDMAE_MASK ((uint32_t)0x00000002) /*!< TXDMAE :Mask */
|
||||
|
||||
#define FUARTxDMACR_RXDMAE_ENABLE ((uint32_t)0x00000001) /*!< RXDMAE :Enable */
|
||||
#define FUARTxDMACR_TXDMAE_ENABLE ((uint32_t)0x00000002) /*!< TXDMAE :Enable */
|
||||
|
||||
#define FUARTxDMACR_RXDMAE_DISABLE ((uint32_t)0x00000000) /*!< RXDMAE :Disable */
|
||||
#define FUARTxDMACR_TXDMAE_DISABLE ((uint32_t)0x00000000) /*!< TXDMAE :Disable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUARTxDMACR */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Inline Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_fuctions
|
||||
* @{
|
||||
*/
|
||||
__STATIC_INLINE void disable_FUARTxCR_TXE(TSB_FURT_TypeDef *p_instance);
|
||||
__STATIC_INLINE void enable_FUARTxCR_TXE(TSB_FURT_TypeDef *p_instance);
|
||||
__STATIC_INLINE void disable_FUARTxCR_RXE(TSB_FURT_TypeDef *p_instance);
|
||||
__STATIC_INLINE void enable_FUARTxCR_RXE(TSB_FURT_TypeDef *p_instance);
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disable FUARTxCR TXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void disable_FUARTxCR_TXE(TSB_FURT_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,8))) = 0;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,8))) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable FUARTxCR TXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void enable_FUARTxCR_TXE(TSB_FURT_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,8))) = 1;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,8))) = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disable FUARTxCR RXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void disable_FUARTxCR_RXE(TSB_FURT_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,9))) = 0;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,9))) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable FUARTxCR RXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void enable_FUARTxCR_RXE(TSB_FURT_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,9))) = 1;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->CR,9))) = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __UART_EX_H */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_hal.h
|
||||
* @brief This file provides all the functions prototypes for driver common part.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-09 11:01:04 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __HAL_H
|
||||
#define __HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup HAL HAL
|
||||
* @brief HAL Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Exported_macro HAL Exported Macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Exported_define HAL Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Exported_define HAL Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Exported_typedef HAL Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Exported_functions HAL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void hal_inc_tick(void);
|
||||
uint32_t hal_get_tick(void);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __HAL_H */
|
||||
|
||||
|
|
@ -0,0 +1,843 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_i2c.h
|
||||
* @brief This file provides all the functions prototypes for I2C Class.
|
||||
* @version V1.0.0.4
|
||||
* $Date:: 2016-11-24 00:00:00 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __I2C_H
|
||||
#define __I2C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Example
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup UTILITIES
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* @name I2C_NULL Pointer
|
||||
* @brief NULL Pointer.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_NULL ((void *)0)
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2C_NULL Pointer */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name I2CxST Macro Definition.
|
||||
* @brief I2CxST Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxST_NACK ((uint32_t)0x00000008) /*!< NACK Interrupt Status. */
|
||||
#define I2CxST_I2CBF ((uint32_t)0x00000004) /*!< I2CBF Interrupt Status. */
|
||||
#define I2CxST_I2CAL ((uint32_t)0x00000002) /*!< I2CAL Interrupt Status. */
|
||||
#define I2CxST_I2C ((uint32_t)0x00000001) /*!< I2C Interrupt Status. */
|
||||
#define I2CxST_CLEAR ((uint32_t)0x0000000F) /*!< All Bits Clear. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxST Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxCR1 Macro Definition.
|
||||
* @brief I2CxCR1 Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxCR1_ACK ((uint32_t)0x00000010) /*!< ACK */
|
||||
#define I2CxCR1_NOACK ((uint32_t)0x00000008) /*!< NOACK */
|
||||
#define I2CxCR1_BC ((uint32_t)0x000000E0) /*!< BC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxCR1 Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxDBR Macro Definition.
|
||||
* @brief I2CxDBR Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxDBR_DB_MASK ((uint32_t)0x000000FF) /* !< DB 7-0 bits mask. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxDBR Macro Definition */
|
||||
|
||||
|
||||
/**
|
||||
* @name I2CxCR2 Macro Definition.
|
||||
* @brief I2CxCR2 Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxCR2_PIN_CLEAR ((uint32_t)0x00000010) /*!< PIN=1 */
|
||||
#define I2CxCR2_I2CM_DISABLE ((uint32_t)0x00000000) /*!< I2CM=0 */
|
||||
#define I2CxCR2_I2CM_ENABLE ((uint32_t)0x00000008) /*!< I2CM=1 */
|
||||
#define I2CxCR2_SWRES_10 ((uint32_t)0x00000002) /*!< SWRES=10 */
|
||||
#define I2CxCR2_SWRES_01 ((uint32_t)0x00000001) /*!< SWRES=01 */
|
||||
#define I2CxCR2_START_CONDITION ((uint32_t)0x000000F8) /*!< MST=1,TRX=1,BB=1,PIN=1,I2CM=1 */
|
||||
#define I2CxCR2_STOP_CONDITION ((uint32_t)0x000000D8) /*!< MST=1,TRX=1,BB=0,PIN=1,I2CM=1 */
|
||||
#define I2CxCR2_INIT ((uint32_t)0x00000008) /*!< MST=0,TRX=0,BB=0,PIN=0,I2CM=1,SWRES=00 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxCR2 Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxSR Macro Definition.
|
||||
* @brief I2CxSR Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxSR_MST ((uint32_t)0x00000080) /*!< MST */
|
||||
#define I2CxSR_TRX ((uint32_t)0x00000040) /*!< TRX */
|
||||
#define I2CxSR_BB ((uint32_t)0x00000020) /*!< BB */
|
||||
#define I2CxSR_PIN ((uint32_t)0x00000010) /*!< PIN */
|
||||
#define I2CxSR_AL ((uint32_t)0x00000008) /*!< AL */
|
||||
#define I2CxSR_AAS ((uint32_t)0x00000004) /*!< AAS */
|
||||
#define I2CxSR_AD0 ((uint32_t)0x00000002) /*!< AD0 */
|
||||
#define I2CxSR_LRB ((uint32_t)0x00000001) /*!< LRB */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxSR Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxPRS Macro Definition.
|
||||
* @brief I2CxPRS Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxPRS_PRCK ((uint32_t)0x0000001F) /*!< PRCK */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxPRS Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxIE Macro Definition.
|
||||
* @brief I2CxIE Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxIE_SELPINCD ((uint32_t)0x00000040) /*!< SELPINCD */
|
||||
#define I2CxIE_DMARI2CTX ((uint32_t)0x00000020) /*!< DMARI2CTX */
|
||||
#define I2CxIE_DMARI2CRX ((uint32_t)0x00000010) /*!< DMARI2CRX */
|
||||
#define I2CxIE_I2C ((uint32_t)0x00000001) /*!< INTI2C */
|
||||
#define I2CxIE_CLEAR ((uint32_t)0x00000000) /*!< All Clear Setting */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxIE Macro Definition */
|
||||
|
||||
|
||||
/**
|
||||
* @name I2CxOP Macro Definition.
|
||||
* @brief I2CxOP Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxOP_DISAL ((uint32_t)0x00000080) /*!< DISAL */
|
||||
#define I2CxOP_SA2ST ((uint32_t)0x00000040) /*!< SA2ST */
|
||||
#define I2CxOP_SAST ((uint32_t)0x00000020) /*!< SAST */
|
||||
#define I2CxOP_NFSEL ((uint32_t)0x00000010) /*!< NFSEL */
|
||||
#define I2CxOP_RSTA ((uint32_t)0x00000008) /*!< RSTA */
|
||||
#define I2CxOP_GCDI ((uint32_t)0x00000004) /*!< GDDI */
|
||||
#define I2CxOP_SREN ((uint32_t)0x00000002) /*!< SREN */
|
||||
#define I2CxOP_MFACK ((uint32_t)0x00000001) /*!< MFACK */
|
||||
#ifndef I2C_MULTI_MASTER
|
||||
#define I2CxOP_INIT ((uint32_t)0x00000084) /*!< Initial Settings. */
|
||||
#else
|
||||
#define I2CxOP_INIT ((uint32_t)0x00000004) /*!< Initial Settings. */
|
||||
#endif
|
||||
#define I2CxOP_SLAVE_INIT ((uint32_t)0x00000084) /*!< Slave Initial Settings. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxOP Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxAR Macro Definition.
|
||||
* @brief I2CxAR Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxAR_ALS ((uint32_t)0x00000001) /*!< ALS. */
|
||||
#define I2CxAR_INIT ((uint32_t)0x00000000) /*!< Initial Settings. */
|
||||
#define I2CxAR2_INIT ((uint32_t)0x00000000) /*!< Initial Settings. */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxAR Macro Definition */
|
||||
|
||||
|
||||
/**
|
||||
* @name I2CxPM Macro Definition.
|
||||
* @brief I2CxPM Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxPM_SDA_SCL ((uint32_t)0x00000003) /* SDA and SCL level. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxPM Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxWUPCR_INT Macro Definition.
|
||||
* @brief I2CxWUPCR_INT Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxWUPCR_INT_RELESE ((uint32_t)0x00000001) /* Interrupt Release. */
|
||||
#define I2CxWUPCR_INT_HOLD ((uint32_t)0x00000000) /* Interrupt setting keep it. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxWUPCR_INT Macro Definition */
|
||||
|
||||
/**
|
||||
* @name I2CxWUPCR_RST Macro Definition.
|
||||
* @brief I2CxWUPCR_RST Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxWUPCR_RST_RESET ((uint32_t)0x00000010) /* I2C BUS Reset. */
|
||||
#define I2CxWUPCR_RST_RELEASE ((uint32_t)0x00000000) /* I2C BUS Reset Release. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxWUPCR_RST Macro Definition */
|
||||
|
||||
|
||||
/**
|
||||
* @name I2CxWUPCR_ACK Macro Definition.
|
||||
* @brief I2CxWUPCR_ACK Register Macro Definition.
|
||||
* @{
|
||||
*/
|
||||
#define I2CxWUPCR_ACK ((uint32_t)0x00000020) /* ACK Output. Output "0" */
|
||||
#define I2CxWUPCR_NACK ((uint32_t)0x00000000) /* ACL No Output. Output "1" NACK Output */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of name I2CxWUPCR_RST Macro Definition */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Clock setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t sck; /*!< Select internal SCL output clock frequency. */
|
||||
uint32_t prsck; /*!< Prescaler clock frequency for generating the Serial clock. */
|
||||
} I2C_clock_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Wakeup Control setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t sgcdi; /*!< Select general call detect ON/OFF. */
|
||||
uint32_t ack; /*!< Select ACK output. */
|
||||
uint32_t reset; /*!< I2C BUS Rest. */
|
||||
uint32_t intend; /*!< Interrupt release. */
|
||||
} I2CS_wup_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Initial setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
I2C_clock_setting_t clock; /*!< Serial clock setting. */
|
||||
} I2C_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Initial setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
I2CS_wup_setting_t wup; /*!< Wakeup Control setting. */
|
||||
} I2CS_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief I2C handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_I2C_TypeDef *p_instance; /*!< Registers base address. */
|
||||
I2C_initial_setting_t init; /*!< Initial setting. */
|
||||
} I2C_t;
|
||||
#if defined(I2CSxWUP_EN)
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief I2CS handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_I2CS_TypeDef *p_instance; /*!< Registers base address. */
|
||||
I2CS_initial_setting_t init; /*!< Initial setting. */
|
||||
} I2CS_t;
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Inline Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_functions
|
||||
* @{
|
||||
*/
|
||||
__STATIC_INLINE void I2C_reset(I2C_t *p_obj);
|
||||
__STATIC_INLINE int32_t I2C_port_high(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_stop_condition(I2C_t *p_obj);
|
||||
__STATIC_INLINE uint32_t I2C_read_data(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_write_data(I2C_t *p_obj, uint32_t data);
|
||||
__STATIC_INLINE int32_t I2C_restart(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_set_ack(I2C_t *p_obj, int32_t nack);
|
||||
__STATIC_INLINE int32_t I2C_get_ack(I2C_t *p_obj);
|
||||
__STATIC_INLINE int32_t I2C_status_busy(I2C_t *p_obj);
|
||||
__STATIC_INLINE int32_t I2C_master(I2C_t *p_obj);
|
||||
__STATIC_INLINE int32_t I2C_transmitter(I2C_t *p_obj);
|
||||
__STATIC_INLINE int32_t I2C_int_status(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_clear_int_status(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_enable_interrupt(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_enable_interrupt_dma(I2C_t *p_obj, int32_t tx);
|
||||
__STATIC_INLINE void I2C_disable_interrupt(I2C_t *p_obj);
|
||||
__STATIC_INLINE void I2C_set_address(I2C_t *p_obj, uint32_t addr);
|
||||
__STATIC_INLINE int32_t I2C_slave_detected(I2C_t *p_obj);
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief I2C software reset.
|
||||
* @param p_obj :I2C object.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_reset(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->CR2 = I2CxCR2_SWRES_10;
|
||||
p_obj->p_instance->CR2 = I2CxCR2_SWRES_01;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->CR2 = I2CxCR2_SWRES_10;
|
||||
p_obj->p_instance->CR2 = I2CxCR2_SWRES_01;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief I2C bus port high
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :SDA and SCL Port High.
|
||||
* @retval false :Bus Error.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_port_high(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return (((p_obj->p_instance->PM & I2CxPM_SDA_SCL) == I2CxPM_SDA_SCL));
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return (((p_obj->p_instance->PM & I2CxPM_SDA_SCL) == I2CxPM_SDA_SCL));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Generate stop condition.
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_stop_condition(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->CR2 = I2CxCR2_STOP_CONDITION;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->CR2 = I2CxCR2_STOP_CONDITION;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Read from Data buffer
|
||||
* @param p_obj :I2C object.
|
||||
* @retval result :Read data.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE uint32_t I2C_read_data(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return (p_obj->p_instance->DBR & I2CxDBR_DB_MASK);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return (p_obj->p_instance->DBR & I2CxDBR_DB_MASK);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Write to Data buffer.
|
||||
* @param p_obj :I2C object.
|
||||
* @param data :Write data.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_write_data(I2C_t *p_obj, uint32_t data)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->DBR = (data & I2CxDBR_DB_MASK);
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->DBR = (data & I2CxDBR_DB_MASK);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return restart condition
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :Restart Detected.
|
||||
* @retval false :Restart Non-Detected.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_restart(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
__IO uint32_t opreg = p_obj->p_instance->OP;
|
||||
p_obj->p_instance->OP &= ~I2CxOP_RSTA;
|
||||
return ((opreg & I2CxOP_RSTA) == I2CxOP_RSTA);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
__IO uint32_t opreg = p_obj->p_instance->OP;
|
||||
p_obj->p_instance->OP &= ~I2CxOP_RSTA;
|
||||
return ((opreg & I2CxOP_RSTA) == I2CxOP_RSTA);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Set Ack condition
|
||||
* @param p_obj :I2C object.
|
||||
* @param nack :1 NACK, 0 ACK.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_set_ack(I2C_t *p_obj, int32_t nack)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
if (nack)
|
||||
{
|
||||
p_obj->p_instance->OP |= I2CxOP_MFACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_obj->p_instance->OP &= ~I2CxOP_MFACK;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (nack)
|
||||
{
|
||||
p_obj->p_instance->OP |= I2CxOP_MFACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_obj->p_instance->OP &= ~I2CxOP_MFACK;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return received Ack condition
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :NACK Received.
|
||||
* @retval false :ACK Received.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_get_ack(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return ((p_obj->p_instance->SR & I2CxSR_LRB) == I2CxSR_LRB);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return ((p_obj->p_instance->SR & I2CxSR_LRB) == I2CxSR_LRB);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return Busy condition
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :I2C bus busy.
|
||||
* @retval false :I2C bus free.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_status_busy(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return ((p_obj->p_instance->SR & I2CxSR_BB) == I2CxSR_BB);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return ((p_obj->p_instance->SR & I2CxSR_BB) == I2CxSR_BB);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return The Master status
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :Master mode.
|
||||
* @retval false :Slave mode.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_master(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return ((p_obj->p_instance->SR & I2CxSR_MST) == I2CxSR_MST);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return ((p_obj->p_instance->SR & I2CxSR_MST) == I2CxSR_MST);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return The Transmitter
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :Transmitter.
|
||||
* @retval false :Receiver.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_transmitter(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return ((p_obj->p_instance->SR & I2CxSR_TRX) == I2CxSR_TRX);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return ((p_obj->p_instance->SR & I2CxSR_TRX) == I2CxSR_TRX);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Interrupt Status
|
||||
* @param p_obj :I2C object.
|
||||
* @retval true :Interruput Occured.
|
||||
* @retval false :No Interruput Occured.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_int_status(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return ((p_obj->p_instance->ST & I2CxST_I2C) == I2CxST_I2C);
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return ((p_obj->p_instance->ST & I2CxST_I2C) == I2CxST_I2C);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Interrupt Status Clear
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_clear_int_status(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->ST = I2CxST_CLEAR;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->ST = I2CxST_CLEAR;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable Interrupt setting.
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_enable_interrupt(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->IE = I2CxIE_I2C;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->IE = I2CxIE_I2C;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable Interrupt setting.
|
||||
* @param p_obj :I2C object.
|
||||
* @param tx :Direction of transfer(1=tx 0=rx).
|
||||
* @retval -
|
||||
* @note For DMA transfer.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_enable_interrupt_dma(I2C_t *p_obj, int32_t tx)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
if (tx)
|
||||
{
|
||||
p_obj->p_instance->IE = (I2CxIE_SELPINCD | I2CxIE_DMARI2CTX);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_obj->p_instance->IE = (I2CxIE_SELPINCD | I2CxIE_DMARI2CRX);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (tx)
|
||||
{
|
||||
p_obj->p_instance->IE = (I2CxIE_SELPINCD | I2CxIE_DMARI2CTX);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_obj->p_instance->IE = (I2CxIE_SELPINCD | I2CxIE_DMARI2CRX);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disable Interrupt setting.
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_disable_interrupt(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->IE = I2CxIE_CLEAR;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->IE = I2CxIE_CLEAR;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Set slave address.
|
||||
* @param p_obj :I2C object.
|
||||
* @param addr :slave address.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void I2C_set_address(I2C_t *p_obj, uint32_t addr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
p_obj->p_instance->AR = (addr & ~I2CxAR_ALS);
|
||||
p_obj->p_instance->AR2 = I2CxAR2_INIT;
|
||||
}
|
||||
#else
|
||||
p_obj->p_instance->AR = (addr & ~I2CxAR_ALS);
|
||||
p_obj->p_instance->AR2 = I2CxAR2_INIT;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Detecting Slave Address
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE int32_t I2C_slave_detected(I2C_t *p_obj)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((p_obj != I2C_NULL) && (p_obj->p_instance != I2C_NULL))
|
||||
{
|
||||
return (((p_obj->p_instance->SR & I2CxSR_AAS) == I2CxSR_AAS)
|
||||
&& ((p_obj->p_instance->OP & I2CxOP_SAST) == I2CxOP_SAST));
|
||||
}
|
||||
return (0);
|
||||
#else
|
||||
return (((p_obj->p_instance->SR & I2CxSR_AAS) == I2CxSR_AAS)
|
||||
&& ((p_obj->p_instance->OP & I2CxOP_SAST) == I2CxOP_SAST));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_functions */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_functions
|
||||
* @{
|
||||
*/
|
||||
void I2C_init(I2C_t *p_obj);
|
||||
void I2C_start_condition(I2C_t *p_obj, uint32_t data);
|
||||
uint32_t I2C_get_clock_setting(I2C_t *p_obj, uint32_t frequency, uint32_t fsys, I2C_clock_setting_t *p_setting);
|
||||
void I2C_slave_init(I2C_t *p_obj);
|
||||
#if defined(I2CSxWUP_EN)
|
||||
void I2CS_init(I2CS_t *p_obj);
|
||||
void I2CS_Primary_slave_adr_set(I2CS_t *p_obj, uint32_t adr);
|
||||
void I2CS_Secondary_slave_adr_set(I2CS_t *p_obj, uint32_t adr);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Example */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __I2C_H */
|
||||
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file bsp_i2c.h
|
||||
* @brief This file provides all the functions prototypes for I2C Driver.
|
||||
* @version V1.0.0.2
|
||||
* $Date:: 2017-10-03 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __BSP_I2C_H
|
||||
#define __BSP_I2C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_i2c.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Example
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup UTILITIES
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @defgroup I2C_NullPointer Null Pointer
|
||||
* @brief I2C NULL Pointer.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_NULL ((void *)0)
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group I2C_NullPointer */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup I2C_ACK I2C ACK Macros
|
||||
* @brief I2C Type of Acknowledge.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_NACK (0) /*!< NACK Received. */
|
||||
#define I2C_ACK (1) /*!< ACK Received. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group I2C_ACK */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup I2C_ERROR I2C ERROR Macros
|
||||
* @brief I2C Error definitions.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_ERROR_NO_ERROR (0) /*!< No Error. */
|
||||
#if 0
|
||||
#define I2C_ERROR_NO_SLAVE (-1) /*!< No Slave Error. */
|
||||
#define I2C_ERROR_BUS_BUSY (-2) /*!< Bus Busy Error.(now, not support) */
|
||||
#endif
|
||||
#define I2C_ERROR_PARAM (-3) /*!< Parameter Error. */
|
||||
#define I2C_ERROR_OTHERS (-4) /*!< Others Error. */
|
||||
#define I2C_ERROR_ARBITRATION (-5) /*!< Arbitration Error. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group I2C_ERROR */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup I2C_Events I2C Events Macros
|
||||
* @brief I2C Asynch Events.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_EVENT_ERROR (1 << 1) /*!< Error. */
|
||||
#define I2C_EVENT_ERROR_NO_SLAVE (1 << 2) /*!< No Slave. */
|
||||
#define I2C_EVENT_TRANSFER_COMPLETE (1 << 3) /*!< Transfer Complete. */
|
||||
#define I2C_EVENT_TRANSFER_EARLY_NACK (1 << 4) /*!< End of Transfer. */
|
||||
#define I2C_EVENT_ALL (I2C_EVENT_ERROR | I2C_EVENT_TRANSFER_COMPLETE | I2C_EVENT_ERROR_NO_SLAVE | I2C_EVENT_TRANSFER_EARLY_NACK)
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group I2C_Events */
|
||||
|
||||
/**
|
||||
* @defgroup I2C_SlaveReceive I2C Slave Receive Return Macros
|
||||
* @brief I2C Received Contents of Slave.
|
||||
* @{
|
||||
*/
|
||||
#define I2C_NO_DATA (0) /*!< the slave has not been addressed. */
|
||||
#define I2C_READ_ADDRESSED (1) /*!< the master has requested a read from this slave. */
|
||||
#define I2C_WRITE_GENERAL (2) /*!< the master is writing to all slave.(now, not support) */
|
||||
#define I2C_WRITE_ADDRESSED (3) /*!< the master is writing to this slave. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group I2C_SlaveReceive */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief i2c Port Enumerated Type Definition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef enum {
|
||||
I2C_PORT_PG2 = 0, /*!< 0: PG2 I2C0 */
|
||||
I2C_PORT_PG3, /*!< 1: PG3 I2C0 */
|
||||
I2C_PORT_PF2, /*!< 2: PF2 I2C1 */
|
||||
I2C_PORT_PF3, /*!< 3: PF3 I2C1 */
|
||||
I2C_PORT_PG4, /*!< 4: PG4 I2C2 */
|
||||
I2C_PORT_PG5, /*!< 5: PG5 I2C2 */
|
||||
I2C_PORT_PJ6, /*!< 6: PJ6 I2C3 */
|
||||
I2C_PORT_PJ7, /*!< 7: PJ7 I2C3 */
|
||||
I2C_PORT_PJ2, /*!< 8: PJ2 I2C4 */
|
||||
I2C_PORT_PJ3, /*!< 9: PJ3 I2C4 */}
|
||||
i2c_port_t;
|
||||
|
||||
/*----------------------*/
|
||||
/* I2C Setting */
|
||||
/*----------------------*/
|
||||
/* #define I2C_CHANNEL0 */
|
||||
#define I2C_CHANNEL3
|
||||
/* #define I2C_CHANNEL2 */
|
||||
/* #define I2C_CHANNEL3 */
|
||||
/* #define I2C_CHANNEL4 */
|
||||
#if defined(I2C_CHANNEL0)
|
||||
#define I2Cx_TEXT "I2C0"
|
||||
#define I2C_CFG_PORT_SCL (I2C_PORT_PG3) /*!< SCL Port. */
|
||||
#define I2C_CFG_PORT_SDA (I2C_PORT_PG2) /*!< SDA Port. */
|
||||
#elif defined(I2C_CHANNEL1)
|
||||
#define I2Cx_TEXT "I2C1"
|
||||
#define I2C_CFG_PORT_SCL (I2C_PORT_PF3) /*!< SCL Port. */
|
||||
#define I2C_CFG_PORT_SDA (I2C_PORT_PF2) /*!< SDA Port. */
|
||||
#elif defined(I2C_CHANNEL2)
|
||||
#define I2Cx_TEXT "I2C2"
|
||||
#define I2C_CFG_PORT_SCL (I2C_PORT_PG5) /*!< SCL Port. */
|
||||
#define I2C_CFG_PORT_SDA (I2C_PORT_PG4) /*!< SDA Port. */
|
||||
#elif defined(I2C_CHANNEL3)
|
||||
#define I2Cx_TEXT "I2C3"
|
||||
#define I2C_CFG_PORT_SCL (I2C_PORT_PJ7) /*!< SCL Port. */
|
||||
#define I2C_CFG_PORT_SDA (I2C_PORT_PJ6) /*!< SDA Port. */
|
||||
#elif defined(I2C_CHANNEL4)
|
||||
#define I2Cx_TEXT "I2C4"
|
||||
#define I2C_CFG_PORT_SCL (I2C_PORT_PJ3) /*!< SCL Port. */
|
||||
#define I2C_CFG_PORT_SDA (I2C_PORT_PJ2) /*!< SDA Port. */
|
||||
#else
|
||||
#error "target channel is non-select."
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_typedef
|
||||
* @{
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief I2C internal information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bus_free; /*!< Bus free information. */
|
||||
uint8_t start; /*!< Start condition information. */
|
||||
uint32_t irqn; /*!< IRQ number table pointer. */
|
||||
struct
|
||||
{
|
||||
uint32_t address; /*!< Slave address. */
|
||||
uint32_t stop; /*!< Stop control */
|
||||
uint32_t event; /*!< I2C Event information. */
|
||||
uint32_t state; /*!< Transfer State. */
|
||||
} asynch;
|
||||
} i2c_internal_info_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief I2C buffer structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_buffer; /*!< Buffer address. */
|
||||
uint32_t length; /*!< Buffer length. */
|
||||
uint32_t pos; /*!< Buffer pointer. */
|
||||
} i2c_buffer_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief I2C handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
I2C_t i2c; /*!< I2C class structure. */
|
||||
i2c_internal_info_t info; /*!< Internal Information. */
|
||||
i2c_buffer_t tx_buff; /*!< Tx buffer structure. */
|
||||
i2c_buffer_t rx_buff; /*!< Rx buffer structure. */
|
||||
} _i2c_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result i2c_init_t(_i2c_t *p_obj, i2c_port_t sda, i2c_port_t scl);
|
||||
TXZ_Result i2c_frequency_t(_i2c_t *p_obj, int32_t hz);
|
||||
void i2c_reset_t(_i2c_t *p_obj);
|
||||
TXZ_Result i2c_check_bus_free_t(_i2c_t *p_obj);
|
||||
TXZ_Result i2c_start_t(_i2c_t *p_obj);
|
||||
TXZ_Result i2c_stop_t(_i2c_t *p_obj);
|
||||
int32_t i2c_read_t(_i2c_t *p_obj, int32_t address, uint8_t *p_data, int32_t length, int32_t stop);
|
||||
int32_t i2c_write_t(_i2c_t *p_obj, int32_t address, uint8_t *p_data, int32_t length, int32_t stop);
|
||||
int32_t i2c_byte_read_t(_i2c_t *p_obj, int32_t last);
|
||||
int32_t i2c_byte_write_t(_i2c_t *p_obj, int32_t data);
|
||||
uint8_t i2c_active_t(_i2c_t *p_obj);
|
||||
TXZ_Result i2c_transfer_asynch_t(_i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length, uint8_t *p_rx, int32_t rx_length, int32_t address, int32_t stop);
|
||||
uint32_t i2c_irq_handler_asynch_t(_i2c_t *p_obj);
|
||||
void i2c_abort_asynch_t(_i2c_t *p_obj);
|
||||
|
||||
/* For slave */
|
||||
void i2c_slave_mode_t(_i2c_t *p_obj, int32_t enable_slave);
|
||||
int32_t i2c_slave_receive_t(_i2c_t *p_obj);
|
||||
int32_t i2c_slave_read_t(_i2c_t *p_obj, uint8_t *p_data, int32_t length);
|
||||
int32_t i2c_slave_write_t(_i2c_t *p_obj, uint8_t *p_data, int32_t length);
|
||||
void i2c_slave_address_t(_i2c_t *p_obj, uint32_t address);
|
||||
TXZ_Result i2c_slave_transfer_asynch_t(_i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length, uint8_t *p_rx, int32_t rx_length);
|
||||
uint32_t i2c_slave_irq_handler_asynch_t(_i2c_t *p_obj);
|
||||
void i2c_slave_abort_asynch_t(_i2c_t *p_obj);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Example */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __BSP_I2C_H */
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_sample_def.h
|
||||
* @brief This file includes header files for sample application.
|
||||
* @version V1.0.0.3
|
||||
* $Date:: 2017-10-26 13:33:43 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TXZ_SAMPLE_DEF_H
|
||||
#define __TXZ_SAMPLE_DEF_H
|
||||
|
||||
#include "txz_driver_def.h"
|
||||
#include "txz_hal.h"
|
||||
#if defined(TMPM4G9)
|
||||
#include "txz_cg.h"
|
||||
#include "txz_gpio.h"
|
||||
#else
|
||||
#include "txz_cg.h"
|
||||
#include "txz_gpio.h"
|
||||
#include "txz_dma.h"
|
||||
#endif
|
||||
#include "txz_uart.h"
|
||||
#include "txz_t32a.h"
|
||||
#endif /* __TXZ_SAMPLE_DEF_H */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,812 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_uart.h
|
||||
* @brief This file provides all the functions prototypes for UART driver.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-07-21 15:39:36 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __UART_H
|
||||
#define __UART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup UART UART
|
||||
* @brief UART Driver.
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup UART_Exported_define UART Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup UART_FifoMax Max Num of FIFO
|
||||
* @brief Max Num of Tx/Rx Fifo.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_FIFO_MAX ((uint32_t)0x00000008) /*!< TX FIFO Max. */
|
||||
#define UART_RX_FIFO_MAX ((uint32_t)0x00000008) /*!< RX FIFO Max. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_FifoMax */
|
||||
|
||||
/**
|
||||
* @defgroup UART_HalfClockSelect Half Clock Select
|
||||
* @brief Output Terminal Select
|
||||
* @{
|
||||
*/
|
||||
#define UART_HALF_CLOCK_UTxTXDA ((uint32_t)0x00000000) /*!< Half Clock output terminal select UTxTXDA. */
|
||||
#define UART_HALF_CLOCK_UTxTXDB ((uint32_t)0x00040000) /*!< Half Clock output terminal select UTxTXDB. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_HalfClockSelect */
|
||||
|
||||
/**
|
||||
* @defgroup UART_HalfClockMode Half Clock Mode
|
||||
* @brief Half Clock Mode Setting.
|
||||
* @{
|
||||
*/
|
||||
#define UART_HALF_CLOCK_MODE_1 ((uint32_t)0x00000000) /*!< Half Clock 1 terminal Mode. */
|
||||
#define UART_HALF_CLOCK_MODE_2 ((uint32_t)0x00020000) /*!< Half Clock 2 terminal Mode. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_HalfClockMode */
|
||||
|
||||
/**
|
||||
* @defgroup UART_HalfClockCTR Half Clock Mode Control
|
||||
* @brief Half Clock Control.
|
||||
* @{
|
||||
*/
|
||||
#define UART_HALF_CLOCK_DISABLE ((uint32_t)0x00000000) /*!< Half Clock Mode Disable. */
|
||||
#define UART_HALF_CLOCK_ENABLE ((uint32_t)0x00010000) /*!< Half Clock Mode Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_HalfClockCTR */
|
||||
|
||||
/**
|
||||
* @defgroup UART_LoopBack Loop Back Function
|
||||
* @brief Half Clock Control.
|
||||
* @{
|
||||
*/
|
||||
#define UART_LOOPBACK_DISABLE ((uint32_t)0x00000000) /*!< Loop Back Function Disable. */
|
||||
#define UART_LOOPBACK_ENABLE ((uint32_t)0x00008000) /*!< Loop Back Function Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_LoopBack */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_NoiseFilter Noise Filter
|
||||
* @brief Noise Filter Setting.
|
||||
* @{
|
||||
*/
|
||||
#define UART_NOISE_FILTER_NON ((uint32_t)0x00000000) /*!< No Filetering. */
|
||||
#define UART_NOISE_FILTER_2_T0 ((uint32_t)0x00001000) /*!< A signal below the 2/T0 is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_4_T0 ((uint32_t)0x00002000) /*!< A signal below the 4/T0 is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_8_T0 ((uint32_t)0x00003000) /*!< A signal below the 8/T0 is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_2_CLOCK ((uint32_t)0x00004000) /*!< A signal below the 2/Clock is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_3_CLOCK ((uint32_t)0x00005000) /*!< A signal below the 3/Clock is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_4_CLOCK ((uint32_t)0x00006000) /*!< A signal below the 4/Clock is filtering as noise. */
|
||||
#define UART_NOISE_FILTER_5_CLOCK ((uint32_t)0x00007000) /*!< A signal below the 5/Clock is filtering as noise */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_NoiseFilter */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_CTSHandshake CTS Handshake
|
||||
* @brief Available CTS Handshake Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_CTS_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_CTS_ENABLE ((uint32_t)0x00000400) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_CTSHandshake */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RTSHandshake RTS Handshake
|
||||
* @brief Available RTS Handshake Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RTS_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_RTS_ENABLE ((uint32_t)0x00000200) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RTSHandshake */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_DataComplementation Data Complementation
|
||||
* @brief Enable/Disable Data Signal Complementation Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_DATA_COMPLEMENTION_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define UART_DATA_COMPLEMENTION_ENABLE ((uint32_t)0x00000040) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_DataComplementation */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_DataDirection Data Direction
|
||||
* @brief Data Direction Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_DATA_DIRECTION_LSB ((uint32_t)0x00000000) /*!< LSB first */
|
||||
#define UART_DATA_DIRECTION_MSB ((uint32_t)0x00000020) /*!< MSB first */
|
||||
/*!
|
||||
* @}
|
||||
*/ /* End of group UART_DataDirection */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_StopBit Stop Bit
|
||||
* @brief Stop Bit Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_STOP_BIT_1 ((uint32_t)0x00000000) /*!< 1 bit */
|
||||
#define UART_STOP_BIT_2 ((uint32_t)0x00000010) /*!< 2 bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_StopBit */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_ParityBit Parity Bit
|
||||
* @brief Parity Bit Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_PARITY_BIT_ODD ((uint32_t)0x00000000) /*!< Odd Parity */
|
||||
#define UART_PARITY_BIT_EVEN ((uint32_t)0x00000008) /*!< Even Parity */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_ParityBit */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_ParityEnable Parity Enable
|
||||
* @brief Enable/Disable Parity Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_PARITY_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define UART_PARITY_ENABLE ((uint32_t)0x00000004) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_ParityEnable */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_DataLength Data Length
|
||||
* @brief Data Length Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_DATA_LENGTH_7 ((uint32_t)0x00000000) /*!< 7 bit */
|
||||
#define UART_DATA_LENGTH_8 ((uint32_t)0x00000001) /*!< 8 bit */
|
||||
#define UART_DATA_LENGTH_9 ((uint32_t)0x00000002) /*!< 9 bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_DataLength */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxFillLevelRange Tx Fill Level Range
|
||||
* @brief Transmit Fill Level Range Macro Definisiton.
|
||||
* @brief Range of Value be set "(UART_TX_FILL_LEVEL_MIN <= Value <= UART_TX_FILL_LEVEL_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_FILL_RANGE_MIN ((uint32_t)0x00000000) /*!< Minimum Value :1 */
|
||||
#define UART_TX_FILL_RANGE_MAX ((uint32_t)0x00000007) /*!< Maximum Value :7 */
|
||||
/*!
|
||||
* @}
|
||||
*/ /* End of group UART_TxFillLevelRange */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxFillLevelRange Rx Fill Level Range
|
||||
* @brief Receive Fill Level Range Macro Definisiton.
|
||||
* @brief Range of Value be set "(UART_RX_FILL_LEVEL_MIN <= Value <= UART_RX_FILL_LEVEL_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_FILL_RANGE_MIN ((uint32_t)0x00000001) /*!< Minimum Value :1 */
|
||||
#define UART_RX_FILL_RANGE_MAX ((uint32_t)0x00000008) /*!< Maximum Value :8 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxFillLevelRange */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxFIFOInterrupt Tx FIFO Interrpt
|
||||
* @brief Available Transmit FIFO Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_FIFO_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_TX_FIFO_INT_ENABLE ((uint32_t)0x00000080) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxFIFOInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxInterrupt Tx Interrpt
|
||||
* @brief Available Transmit Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_TX_INT_ENABLE ((uint32_t)0x00000040) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxFIFOInterrupt Rx FIFO Interrpt
|
||||
* @brief Available Receive FIFO Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_FIFO_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_RX_FIFO_INT_ENABLE ((uint32_t)0x00000020) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxFIFOInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxInterrupt Rx Interrpt
|
||||
* @brief Available Receive Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_INT_DISABLE ((uint32_t)0x00000000) /*!< Not Available. */
|
||||
#define UART_RX_INT_ENABLE ((uint32_t)0x00000010) /*!< Available. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_ErrorInterrupt Error Interrupt
|
||||
* @brief Enable/Disable Error Interrupt Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_ERR_INT_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define UART_ERR_INT_ENABLE ((uint32_t)0x00000004) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_ErrorInterrupt */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_Prescaler Prescaler
|
||||
* @brief Prescaler Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_PLESCALER_1 ((uint32_t)0x00000000) /*!< 1/1 */
|
||||
#define UART_PLESCALER_2 ((uint32_t)0x00000010) /*!< 1/2 */
|
||||
#define UART_PLESCALER_4 ((uint32_t)0x00000020) /*!< 1/4 */
|
||||
#define UART_PLESCALER_8 ((uint32_t)0x00000030) /*!< 1/8 */
|
||||
#define UART_PLESCALER_16 ((uint32_t)0x00000040) /*!< 1/16 */
|
||||
#define UART_PLESCALER_32 ((uint32_t)0x00000050) /*!< 1/32 */
|
||||
#define UART_PLESCALER_64 ((uint32_t)0x00000060) /*!< 1/64 */
|
||||
#define UART_PLESCALER_128 ((uint32_t)0x00000070) /*!< 1/128 */
|
||||
#define UART_PLESCALER_256 ((uint32_t)0x00000080) /*!< 1/256 */
|
||||
#define UART_PLESCALER_512 ((uint32_t)0x00000090) /*!< 1/512 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Prescaler */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_Clock_Mask Clock Mask
|
||||
* @brief Clock Mask Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_UARTxCLK_MASK ((uint32_t)0x00000000) /*!< [1:0] is always 0 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Clock_Mask */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_Division Division
|
||||
* @brief Enable/Disable Division Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_DIVISION_DISABLE ((uint32_t)0x00000000) /*!< Disable */
|
||||
#define UART_DIVISION_ENABLE ((uint32_t)0x00800000) /*!< Enable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Division */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RangeK Range K
|
||||
* @brief Range of K Macro Definisiton.
|
||||
* @brief Range of K be set "(UART_RANGE_K_MIN <= Value <= UART_RANGE_K_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define UART_RANGE_K_MIN ((uint32_t)0x00000000) /*!< Minimum Value :K=0 */
|
||||
#define UART_RANGE_K_MAX ((uint32_t)0x0000003F) /*!< Maximum Value :K=63 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RangeK */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RangeN Range N
|
||||
* @brief Range of N Macro Definisiton.
|
||||
* @brief Range of N be set "(UART_RANGE_N_MIN <= Value <= UART_RANGE_N_MAX)".
|
||||
* @{
|
||||
*/
|
||||
#define UART_RANGE_N_MIN ((uint32_t)0x00000001) /*!< Minimum Value :N=1 */
|
||||
#define UART_RANGE_N_MAX ((uint32_t)0x0000FFFF) /*!< Maximum Value :N=65535 */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RangeN */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_SettingEnable Setting Enable
|
||||
* @brief Enable/Disable Setting Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_SETTING_MASK ((uint32_t)0x80000000) /*!< for Mask */
|
||||
#define UART_SETTING_ENABLE ((uint32_t)0x00000000) /*!< Setting Enable */
|
||||
#define UART_SETTING_DISABLE ((uint32_t)0x80000000) /*!< Setting Disable */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_SettingEnable */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxState Tx State
|
||||
* @brief Transmitting State Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_STATE_MASK ((uint32_t)0x00008000) /*!< for Mask */
|
||||
#define UART_TX_STATE_SLEEP ((uint32_t)0x00000000) /*!< Sleep */
|
||||
#define UART_TX_STATE_RUN ((uint32_t)0x00008000) /*!< Run */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxState */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxDone Transmitting Done
|
||||
* @brief Transmitting Done Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_MASK ((uint32_t)0x00004000) /*!< for Mask */
|
||||
#define UART_TX_DONE ((uint32_t)0x00004000) /*!< Transmitting Done */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxDone */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxReachFillLevel Tx Reach Fill Level
|
||||
* @brief Reach Transmitting Fill Level Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_REACH_FILL_MASK ((uint32_t)0x00002000) /*!< for Mask */
|
||||
#define UART_TX_REACH_FILL_LEVEL ((uint32_t)0x00002000) /*!< Reach Transmitting Fill Level */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxReachFillLevel */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TxFifoLevel Tx FIFO Fill Level
|
||||
* @brief Transmitting FIFO Fill Level Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TX_FIFO_LEVEL_MASK ((uint32_t)0x00000F00) /*!< for Mask */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxFifoLevel */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxState Rx State
|
||||
* @brief Receive State Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_STATE_MASK ((uint32_t)0x00000080) /*!< for Mask */
|
||||
#define UART_RX_STATE_SLEEP ((uint32_t)0x00000000) /*!< Sleep */
|
||||
#define UART_RX_STATE_RUN ((uint32_t)0x00000080) /*!< Run */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxState */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxDone Rx Done
|
||||
* @brief Receive Done Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_MASK ((uint32_t)0x00000040) /*!< for Mask */
|
||||
#define UART_RX_DONE ((uint32_t)0x00000040) /*!< Receive Done */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxDone */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxReachFillLevel Rx Reach Fill Level
|
||||
* @brief Reach Receive Fill Level Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_REACH_FILL_MASK ((uint32_t)0x00000020) /*!< for Mask */
|
||||
#define UART_RX_REACH_FILL_LEVEL ((uint32_t)0x00000020) /*!< Reach Receive Fill Level */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxReachFillLevel */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_RxFifoLevel Rx FIFO Fill Level
|
||||
* @brief Receive FIFO Fill Level Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_RX_FIFO_LEVEL_MASK ((uint32_t)0x0000000F) /*!< for Mask */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_RxFifoLevel */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_TriggerErr Trigger Error
|
||||
* @brief Trigger Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_TRIGGER_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define UART_TRIGGER_ERR ((uint32_t)0x00000010) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_TxTriggerErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_OverrunErr Overrun Error
|
||||
* @brief Overrun Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_OVERRUN_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define UART_OVERRUN_ERR ((uint32_t)0x00000008) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_OverrunErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_ParityErr Parity Error
|
||||
* @brief Parity Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_PARITY_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define UART_PARITY_ERR ((uint32_t)0x00000004) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_ParityErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_FramingErr Framing Error
|
||||
* @brief Framing Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_FRAMING_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define UART_FRAMING_ERR ((uint32_t)0x00000002) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_FramingErr */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup UART_BreakErr Break Error
|
||||
* @brief Break Error Macro Definisiton.
|
||||
* @{
|
||||
*/
|
||||
#define UART_BREAK_NO_ERR ((uint32_t)0x00000000) /*!< No Error */
|
||||
#define UART_BREAK_ERR ((uint32_t)0x00000001) /*!< Error */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_BreakErr */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup UART_Exported_define UART Exported Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Exported_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup UART_Exported_typedef UART Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive event information structure definenition.
|
||||
* @brief When data length definenition is "7 or 8bit"( @ref UART_DataLength ), use this.
|
||||
* @attention "num" must be over FIFO max num.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_data; /*!< The buffer to receive data. */
|
||||
uint32_t num; /*!< The number of receive data. */
|
||||
} uart_receive8_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive event information structure definenition.
|
||||
* @brief When data length definenition is "9bit"( @ref UART_DataLength ), use this.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t *p_data; /*!< The buffer to receive data. */
|
||||
uint32_t num; /*!< The number of receive data. */
|
||||
} uart_receive16_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive event information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef union
|
||||
{
|
||||
uart_receive8_t rx8; /*!< @ref uart_receive8_t */
|
||||
uart_receive16_t rx16; /*!< @ref uart_receive16_t */
|
||||
} uart_receive_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit data information structure definenition.
|
||||
* @brief When data length definenition is "7 or 8bit"( @ref UART_DataLength ), use this.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_data; /*!< The buffer to transmit data. */
|
||||
uint32_t num; /*!< The number of transmit data. */
|
||||
} uart_transmit8_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit data information structure definenition.
|
||||
* @brief When data length definenition is "9bit"( @ref UART_DataLength ), use this.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t *p_data; /*!< The buffer to transmit data.
|
||||
Rransmit data valid range is ( 0x0000 <= range <= 0x01FF ) */
|
||||
uint32_t num; /*!< The number of transmit data. */
|
||||
} uart_transmit16_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit data information structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef union
|
||||
{
|
||||
uart_transmit8_t tx8; /*!< @ref uart_transmit8_t */
|
||||
uart_transmit16_t tx16; /*!< @ref uart_transmit16_t */
|
||||
} uart_transmit_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Clock setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t prsel; /*!< Prescaler.
|
||||
: Use @ref UART_Prescaler */
|
||||
} uart_clock_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Boudrate setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ken; /*!< Enable/Disable Division Definisiton.
|
||||
: Use @ref UART_Division */
|
||||
uint32_t brk; /*!< Division Value K.
|
||||
: K Range ( UART_RANGE_K_MIN <= K =< UART_RANGE_K_MAX ) @ref UART_RangeK */
|
||||
uint32_t brn; /*!< Division Value N.
|
||||
: N Range ( UART_RANGE_N_MIN <= N =< UART_RANGE_N_MAX ) @ref UART_RangeN */
|
||||
} uart_boudrate_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Transmit FIFO setting.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t inttx; /*!< Available Transmit FIFO Interrupt.
|
||||
: Use @ref UART_TxFIFOInterrupt */
|
||||
uint32_t level; /*!< Transmit Fill Level.
|
||||
: Range ( UART_TX_FILL_RANGE_MIN <= K =< UART_TX_FILL_RANGE_MAX ) @ref UART_TxFillLevelRange */
|
||||
} uart_tx_fifo_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Receive FIFO setting.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t intrx; /*!< Available Receive FIFO Interrupt.
|
||||
: Use @ref UART_RxFIFOInterrupt */
|
||||
uint32_t level; /*!< Receive Fill Level.
|
||||
: Range ( UART_RX_FILL_RANGE_MIN <= K =< UART_RX_FILL_RANGE_MAX ) @ref UART_RxFillLevelRange */
|
||||
} uart_rx_fifo_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief Initial setting structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t id; /*!< ID: User value. */
|
||||
uart_clock_t clock; /*!< Clock setting.
|
||||
: Use @ref uart_clock_t */
|
||||
uart_boudrate_t boudrate; /*!< Boudrate setting.
|
||||
: Use @ref uart_boudrate_t */
|
||||
uint32_t inttx; /*!< Available Transmit Interrupt.
|
||||
: Use @ref UART_TxInterrupt */
|
||||
uint32_t intrx; /*!< Available Receive Interrupt.
|
||||
: Use @ref UART_RxInterrupt */
|
||||
uint32_t interr; /*!< Available Error Interrupt.
|
||||
: Use @ref UART_ErrorInterrupt */
|
||||
uart_tx_fifo_t txfifo; /*!< Transmit FIFO setting.
|
||||
: Use @ref uart_tx_fifo_t */
|
||||
uart_rx_fifo_t rxfifo; /*!< Receive FIFO setting.
|
||||
: Use @ref uart_rx_fifo_t */
|
||||
uint32_t hct; /*!< Half Clock Terminal Select.
|
||||
: Use @ref UART_HalfClockSelect */
|
||||
uint32_t hcm; /*!< Half Clock Mode Select.
|
||||
: Use @ref UART_HalfClockMode */
|
||||
uint32_t hcc; /*!< Half Clock Control.
|
||||
: Use @ref UART_HalfClockCTR */
|
||||
uint32_t lbc; /*!< Loop Back Control.
|
||||
: Use @ref UART_LoopBack */
|
||||
uint32_t nf; /*!< UTxRXD Noise Filter.
|
||||
: Use @ref UART_NoiseFilter */
|
||||
uint32_t ctse; /*!< Available CTS Handshake.
|
||||
: Use @ref UART_CTSHandshake */
|
||||
uint32_t rtse; /*!< Available RTS Handshake.
|
||||
: Use @ref UART_RTSHandshake */
|
||||
uint32_t iv; /*!< Data Signal Complementation.
|
||||
: Use @ref UART_DataComplementation */
|
||||
uint32_t dir; /*!< Data Direction.
|
||||
: Use @ref UART_DataDirection */
|
||||
uint32_t sblen; /*!< Stop Bit.
|
||||
: Use @ref UART_StopBit */
|
||||
uint32_t even; /*!< Odd/Even Parity Bit.
|
||||
: Use @ref UART_ParityBit */
|
||||
uint32_t pe; /*!< Enable/Disable Parity Bit.
|
||||
: Use @ref UART_ParityEnable */
|
||||
uint32_t sm; /*!< Data Length.
|
||||
: Use @ref UART_DataLength */
|
||||
} uart_initial_setting_t;
|
||||
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief UART handle structure definenition.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
TSB_UART_TypeDef *p_instance; /*!< Registers base address. */
|
||||
uart_initial_setting_t init; /*!< Initial setting. */
|
||||
/*------------------------------------------*/
|
||||
/*!
|
||||
@brief Transmit Informatin.
|
||||
*/
|
||||
/*------------------------------------------*/
|
||||
struct
|
||||
{
|
||||
uint32_t rp; /*!< Num of transmited data. */
|
||||
uart_transmit_t info; /*!< Transmit Data Information. */
|
||||
void (*handler)(uint32_t id, TXZ_Result result); /*!< Transmit Event handler. */
|
||||
} transmit;
|
||||
/*------------------------------------------*/
|
||||
/*!
|
||||
@brief Receive Informatin.
|
||||
*/
|
||||
/*------------------------------------------*/
|
||||
struct
|
||||
{
|
||||
uart_receive_t info; /*!< Receive Data Information. */
|
||||
void (*handler)(uint32_t id, TXZ_Result result, uart_receive_t *p_info); /*!< Receive Event handler. */
|
||||
} receive;
|
||||
} uart_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Exported_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup UART_Exported_functions UART Exported Functions
|
||||
* @{
|
||||
*/
|
||||
TXZ_Result uart_init(uart_t *p_obj);
|
||||
TXZ_Result uart_deinit(uart_t *p_obj);
|
||||
TXZ_Result uart_discard_transmit(uart_t *p_obj);
|
||||
TXZ_Result uart_discard_receive(uart_t *p_obj);
|
||||
TXZ_Result uart_transmitIt(uart_t *p_obj, uart_transmit_t *p_info);
|
||||
TXZ_Result uart_receiveIt(uart_t *p_obj, uart_receive_t *p_info);
|
||||
void uart_transmit_irq_handler(uart_t *p_obj);
|
||||
void uart_receive_irq_handler(uart_t *p_obj);
|
||||
void uart_error_irq_handler(uart_t *p_obj);
|
||||
TXZ_Result uart_get_status(uart_t *p_obj, uint32_t *p_status);
|
||||
TXZ_Result uart_get_error(uart_t *p_obj, uint32_t *p_error);
|
||||
TXZ_Result uart_get_boudrate_setting(uint32_t clock, uart_clock_t *p_clk, uint32_t boudrate, uart_boudrate_t *p_setting);
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __UART_H */
|
||||
|
||||
|
|
@ -0,0 +1,476 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_uart_include.h
|
||||
* @brief This file provides internal common definition.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-07-21 15:39:36 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Define to prevent recursive inclusion */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#ifndef __UART_INCLUDE_H
|
||||
#define __UART_INCLUDE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_driver_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup UART
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup UART_NullPointer Null Pointer
|
||||
* @brief Null Pointer.
|
||||
* @{
|
||||
*/
|
||||
#define UART_NULL ((void *)0)
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_NullPointer */
|
||||
|
||||
/**
|
||||
* @defgroup UART_ParameterResult Parameter Check Result
|
||||
* @brief Whether the parameter is specified or not.
|
||||
* @{
|
||||
*/
|
||||
#define UART_PARAM_OK ((int32_t)1) /*!< Parameter is valid(specified). */
|
||||
#define UART_PARAM_NG ((int32_t)0) /*!< Parameter is invalid(not specified). */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_ParameterResult */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxSWRST UARTxSWRST Register
|
||||
* @brief UARTxSWRST Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-8 | - |
|
||||
* | 7 | SWRSTF |
|
||||
* | 6:2 | - |
|
||||
* | 1:0 | SWRST |
|
||||
* @{
|
||||
*/
|
||||
/* SWRSTF */
|
||||
#define UARTxSWRST_SWRSTF_MASK ((uint32_t)0x00000080) /*!< SWRSTF :Mask. */
|
||||
#define UARTxSWRST_SWRSTF_IDLE ((uint32_t)0x00000000) /*!< SWRSTF :Not be "Software Reset". */
|
||||
#define UARTxSWRST_SWRSTF_RUN ((uint32_t)0x00000080) /*!< SWRSTF :During "Software Reset". */
|
||||
/* SWRST */
|
||||
#define UARTxSWRST_SWRST_10 ((uint32_t)0x00000002) /*!< SWRST :"10" */
|
||||
#define UARTxSWRST_SWRST_01 ((uint32_t)0x00000001) /*!< SWRST :"01" */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxSWRST */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxCR0 UARTxCR0 Register
|
||||
* @brief UARTxCR0 Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-19 | - |
|
||||
* | 18 | HBSST |
|
||||
* | 17 | HBSMD |
|
||||
* | 16 | HBSEN |
|
||||
* | 15 | LPB |
|
||||
* | 14-12 | NF[2:0] |
|
||||
* | 11 | - |
|
||||
* | 10 | CTSE |
|
||||
* | 9 | RTSE |
|
||||
* | 8 | WU |
|
||||
* | 7 | - |
|
||||
* | 6 | IV |
|
||||
* | 5 | DIR |
|
||||
* | 4 | SBLEN |
|
||||
* | 3 | EVEN |
|
||||
* | 2 | PE |
|
||||
* | 1-0 | SM[1:0] |
|
||||
* @{
|
||||
*/
|
||||
/* HBSST */
|
||||
#define UARTxCR0_HBSST_MASK ((uint32_t)0x00040000) /*!< HBSST :Mask. */
|
||||
/* HBSMD */
|
||||
#define UARTxCR0_HBSMD_MASK ((uint32_t)0x00020000) /*!< HBSMD :Mask. */
|
||||
/* HBSEN */
|
||||
#define UARTxCR0_HBSEN_MASK ((uint32_t)0x00010000) /*!< HBSEN :Mask. */
|
||||
#define UARTxCR0_HBSEN_DISABLE ((uint32_t)0x00000000) /*!< HBSEN :Disable. */
|
||||
#define UARTxCR0_HBSEN_ENABLE ((uint32_t)0x00010000) /*!< HBSEN :Enable. */
|
||||
/* LPB */
|
||||
#define UARTxCR0_LPB_MASK ((uint32_t)0x00008000) /*!< LPB :Mask. */
|
||||
#define UARTxCR0_LPB_DISABLE ((uint32_t)0x00000000) /*!< LPB :Disable. */
|
||||
#define UARTxCR0_LPB_ENABLE ((uint32_t)0x00008000) /*!< LPB :Enable. */
|
||||
/* WU */
|
||||
#define UARTxCR0_WU_MASK ((uint32_t)0x00000100) /*!< WU :Mask. */
|
||||
#define UARTxCR0_WU_DISABLE ((uint32_t)0x00000000) /*!< WU :Disable. */
|
||||
#define UARTxCR0_WU_ENABLE ((uint32_t)0x00000100) /*!< WU :Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxCR0 */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxCR1 UARTxCR1 Register
|
||||
* @brief UARTxCR1 Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-15 | - |
|
||||
* | 14-12 | TIL[2:0] |
|
||||
* | 11 | - |
|
||||
* | 10-8 | RIL[2:0] |
|
||||
* | 7 | INTTXFE |
|
||||
* | 6 | INTTXWE |
|
||||
* | 5 | INTRXFE |
|
||||
* | 4 | INTRXWE |
|
||||
* | 3 | - |
|
||||
* | 2 | INTERR |
|
||||
* | 1 | DMATE |
|
||||
* | 0 | DMARE |
|
||||
* @{
|
||||
*/
|
||||
/* RIL */
|
||||
#define UARTxCR1_RIL_MASK ((uint32_t)0x00000700) /*!< RIL :Mask. */
|
||||
/* DMATE */
|
||||
#define UARTxCR1_DMATE_MASK ((uint32_t)0x00000002) /*!< DMATE :Mask. */
|
||||
#define UARTxCR1_DMATE_DISABLE ((uint32_t)0x00000000) /*!< DMATE :Disable. */
|
||||
#define UARTxCR1_DMATE_ENABLE ((uint32_t)0x00000002) /*!< DMATE :Enable. */
|
||||
/* DMARE */
|
||||
#define UARTxCR1_DMARE_MASK ((uint32_t)0x00000001) /*!< DMARE :Mask. */
|
||||
#define UARTxCR1_DMARE_DISABLE ((uint32_t)0x00000000) /*!< DMARE :Disable. */
|
||||
#define UARTxCR1_DMARE_ENABLE ((uint32_t)0x00000001) /*!< DMARE :Enable. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxCR1 */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxTRANS UARTxTRANS Register
|
||||
* @brief UARTxTRANS Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-4 | - |
|
||||
* | 3 | BK |
|
||||
* | 2 | TXTRG |
|
||||
* | 1 | TXE |
|
||||
* | 0 | RXE |
|
||||
* @{
|
||||
*/
|
||||
/* BK */
|
||||
#define UARTxTRANS_BK_MASK ((uint32_t)0x00000008) /*!< BK :Mask */
|
||||
#define UARTxTRANS_BK_STOP ((uint32_t)0x00000000) /*!< BK :Stop */
|
||||
#define UARTxTRANS_BK_SEND ((uint32_t)0x00000008) /*!< BK :Send */
|
||||
/* TXTRG */
|
||||
#define UARTxTRANS_TXTRG_MASK ((uint32_t)0x00000004) /*!< TXTRG :Mask */
|
||||
#define UARTxTRANS_TXTRG_DISABLE ((uint32_t)0x00000000) /*!< TXTRG :Disable */
|
||||
#define UARTxTRANS_TXTRG_ENABLE ((uint32_t)0x00000004) /*!< TXTRG :Enable */
|
||||
/* TXE */
|
||||
#define UARTxTRANS_TXE_MASK ((uint32_t)0x00000002) /*!< TXE :Mask */
|
||||
#define UARTxTRANS_TXE_DISABLE ((uint32_t)0x00000000) /*!< TXE :Disable */
|
||||
#define UARTxTRANS_TXE_ENABLE ((uint32_t)0x00000002) /*!< TXE :Enable */
|
||||
/* RXE */
|
||||
#define UARTxTRANS_RXE_MASK ((uint32_t)0x00000001) /*!< RXE :Mask */
|
||||
#define UARTxTRANS_RXE_DISABLE ((uint32_t)0x00000000) /*!< RXE :Disable */
|
||||
#define UARTxTRANS_RXE_ENABLE ((uint32_t)0x00000001) /*!< RXE :Enable */
|
||||
/* TXE,RXE */
|
||||
#define UARTxTRANS_TXE_RXE_MASK ((uint32_t)0x00000003) /*!< TXE/RXE:Mask */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxTRANS */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxDR UARTxDR Register
|
||||
* @brief UARTxDR Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-19 | - |
|
||||
* | 18 | PERR |
|
||||
* | 17 | FERR |
|
||||
* | 16 | BERR |
|
||||
* | 15:9 | - |
|
||||
* | 8:0 | DR |
|
||||
* @{
|
||||
*/
|
||||
/* DR */
|
||||
#define UARTxDR_DR_9BIT_MASK ((uint32_t)0x000001FF) /*!< DR :Mask for 9bit */
|
||||
#define UARTxDR_DR_8BIT_MASK ((uint32_t)0x000000FF) /*!< DR :Mask for 8bit */
|
||||
#define UARTxDR_DR_7BIT_MASK ((uint32_t)0x0000007F) /*!< DR :Mask for 7bit */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxDR */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxSR UARTxSR Register
|
||||
* @brief UARTxSR Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31 | SUE |
|
||||
* | 30:16 | - |
|
||||
* | 15 | TXRUN |
|
||||
* | 14 | TXEND |
|
||||
* | 13 | TXFF |
|
||||
* | 12 | - |
|
||||
* | 11:8 | TLVL |
|
||||
* | 7 | RXRUN |
|
||||
* | 6 | RXEND |
|
||||
* | 5 | RXFF |
|
||||
* | 4 | - |
|
||||
* | 3:0 | RLVL |
|
||||
* @{
|
||||
*/
|
||||
/* SUE */
|
||||
#define UARTxSR_SUE_MASK ((uint32_t)0x80000000) /*!< SUE :Mask. */
|
||||
/* TXEND */
|
||||
#define UARTxSR_TXEND_MASK ((uint32_t)0x00004000) /*!< TEXND :Mask. */
|
||||
#define UARTxSR_TXEND_R_END ((uint32_t)0x00004000) /*!< TXEND :[read] Transfer done. */
|
||||
#define UARTxSR_TXEND_W_CLEAR ((uint32_t)0x00004000) /*!< TXEND :[write] Clear Flag. */
|
||||
/* TXFF */
|
||||
#define UARTxSR_TXFF_MASK ((uint32_t)0x00002000) /*!< TXFF :Mask. */
|
||||
#define UARTxSR_TXFF_R_REACHED ((uint32_t)0x00002000) /*!< TXFF :[read] Reached the transfer level. */
|
||||
#define UARTxSR_TXFF_W_CLEAR ((uint32_t)0x00002000) /*!< TXFF :[write] Clear Flag. */
|
||||
/* TLVL */
|
||||
#define UARTxSR_TLVL_MASK ((uint32_t)0x00000F00) /*!< TLVL :Mask. */
|
||||
/* RXEND */
|
||||
#define UARTxSR_RXEND_MASK ((uint32_t)0x00000040) /*!< RXEND :Mask. */
|
||||
#define UARTxSR_RXEND_R_END ((uint32_t)0x00000040) /*!< RXEND :[read] Receive done. */
|
||||
#define UARTxSR_RXEND_W_CLEAR ((uint32_t)0x00000040) /*!< RXEND :[write] Clear Flag. */
|
||||
/* RXFF */
|
||||
#define UARTxSR_RXFF_MASK ((uint32_t)0x00000020) /*!< RXFF :Mask. */
|
||||
#define UARTxSR_RXFF_R_REACHED ((uint32_t)0x00000020) /*!< RXFF :[read] Receive done. */
|
||||
#define UARTxSR_RXFF_W_CLEAR ((uint32_t)0x00000020) /*!< RXFF :[write] Clear Flag. */
|
||||
/* RLVL */
|
||||
#define UARTxSR_RLVL_MASK ((uint32_t)0x0000000F) /*!< RLVL :Mask. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxSR */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxFIFOCLR UARTxFIFOCLR Register
|
||||
* @brief UARTxFIFOCLR Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-2 | - |
|
||||
* | 1 | TFCLR |
|
||||
* | 0 | RFCLR |
|
||||
* @{
|
||||
*/
|
||||
/* TFCLR */
|
||||
#define UARTxFIFOCLR_TFCLR_CLEAR ((uint32_t)0x00000002) /*!< TFCLR :Clear the transmit buff. */
|
||||
/* RFCLR */
|
||||
#define UARTxFIFOCLR_RFCLR_CLEAR ((uint32_t)0x00000001) /*!< RFCLR :Clear the receive buff. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxFIFOCLR */
|
||||
|
||||
/**
|
||||
* @defgroup UARTxERR UARTxERR Register
|
||||
* @brief UARTxERR Register Definition.
|
||||
* @details Detail.
|
||||
* | Bit | Bit Symbol |
|
||||
* | :--- | :--- |
|
||||
* | 31-5 | - |
|
||||
* | 4 | TRGERR |
|
||||
* | 3 | OVRERR |
|
||||
* | 2 | PERR |
|
||||
* | 1 | FERR |
|
||||
* | 0 | BERR |
|
||||
* @{
|
||||
*/
|
||||
/* TRGERR */
|
||||
#define UARTxERR_TRGERR_MASK ((uint32_t)0x00000010) /*!< TRGERR :Mask. */
|
||||
#define UARTxERR_TRGERR_R_NO_ERR ((uint32_t)0x00000000) /*!< TRGERR :[read] No Error. */
|
||||
#define UARTxERR_TRGERR_R_ERR ((uint32_t)0x00000010) /*!< TRGERR :[read] Error. */
|
||||
#define UARTxERR_TRGERR_W_CLEAR ((uint32_t)0x00000010) /*!< TRGERR :[write] Clear Flag. */
|
||||
/* OVRERR */
|
||||
#define UARTxERR_OVRERR_MASK ((uint32_t)0x00000008) /*!< OVRERR :Mask. */
|
||||
#define UARTxERR_OVRERR_R_NO_ERR ((uint32_t)0x00000000) /*!< OVRERR :[read] No Error. */
|
||||
#define UARTxERR_OVRERR_R_ERR ((uint32_t)0x00000008) /*!< OVRERR :[read] Error. */
|
||||
#define UARTxERR_OVRERR_W_CLEAR ((uint32_t)0x00000008) /*!< OVRERR :[write] Clear Flag. */
|
||||
/* PERR */
|
||||
#define UARTxERR_PERR_MASK ((uint32_t)0x00000004) /*!< PERR :Mask. */
|
||||
#define UARTxERR_PERR_R_NO_ERR ((uint32_t)0x00000000) /*!< PERR :[read] No Error. */
|
||||
#define UARTxERR_PERR_R_ERR ((uint32_t)0x00000004) /*!< PERR :[read] Error. */
|
||||
#define UARTxERR_PERR_W_CLEAR ((uint32_t)0x00000004) /*!< PERR :[write] Clear Flag. */
|
||||
/* FERR */
|
||||
#define UARTxERR_FERR_MASK ((uint32_t)0x00000002) /*!< FERR :Mask. */
|
||||
#define UARTxERR_FERR_R_NO_ERR ((uint32_t)0x00000000) /*!< FERR :[read] No Error. */
|
||||
#define UARTxERR_FERR_R_ERR ((uint32_t)0x00000002) /*!< FERR :[read] Error. */
|
||||
#define UARTxERR_FERR_W_CLEAR ((uint32_t)0x00000002) /*!< FERR :[write] Clear Flag. */
|
||||
/* BERR */
|
||||
#define UARTxERR_BERR_MASK ((uint32_t)0x00000001) /*!< BERR :Mask. */
|
||||
#define UARTxERR_BERR_R_NO_ERR ((uint32_t)0x00000000) /*!< BERR :[read] No Error. */
|
||||
#define UARTxERR_BERR_R_ERR ((uint32_t)0x00000001) /*!< BERR :[read] Error. */
|
||||
#define UARTxERR_BERR_W_CLEAR ((uint32_t)0x00000001) /*!< BERR :[write] Clear Flag. */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UARTxERR */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UART_Private_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Inline Functions */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UART_Private_fuctions
|
||||
* @{
|
||||
*/
|
||||
__STATIC_INLINE void disable_UARTxTRANS_TXE(TSB_UART_TypeDef *p_instance);
|
||||
__STATIC_INLINE void enable_UARTxTRANS_TXE(TSB_UART_TypeDef *p_instance);
|
||||
__STATIC_INLINE void disable_UARTxTRANS_RXE(TSB_UART_TypeDef *p_instance);
|
||||
__STATIC_INLINE void enable_UARTxTRANS_RXE(TSB_UART_TypeDef *p_instance);
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disable UARTxTRANS TXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void disable_UARTxTRANS_TXE(TSB_UART_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,1))) = 0;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,1))) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable UARTxTRANS TXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void enable_UARTxTRANS_TXE(TSB_UART_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,1))) = 1;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,1))) = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disable UARTxTRANS RXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void disable_UARTxTRANS_RXE(TSB_UART_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,0))) = 0;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,0))) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enable UARTxTRANS RXE.
|
||||
* @param p_instance: Instance address.
|
||||
* @retval -
|
||||
* @note Bitband Access
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
__STATIC_INLINE void enable_UARTxTRANS_RXE(TSB_UART_TypeDef *p_instance)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if ((uint32_t)p_instance >= (uint32_t)PERI_BASE)
|
||||
{
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,0))) = 1;
|
||||
}
|
||||
#else
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_instance->TRANS,0))) = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART_Private_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __UART_EX_H */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,351 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file adc_ch.c
|
||||
* @brief This file provides API functions for ADC driver. \n
|
||||
* Channel Class.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-09-07 13:52:12 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "adc_include.h"
|
||||
#include "adc_ch.h"
|
||||
|
||||
#if defined(__ADC_CH_H)
|
||||
/**
|
||||
* @addtogroup Periph_Driver Peripheral Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup ADC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_define ADC Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_define ADC Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_define ADC Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_typedef ADC Private Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup ADC_Private_fuctions ADC Private Fuctions
|
||||
* @{
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
/* no define */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Private_functions */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup ADC_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn static uint32_t get_conversion_data(uint32_t reg)
|
||||
* @brief Get convertion data from ADxREGn.
|
||||
* @param[in] reg :ADxREGn data.
|
||||
* @retval Convertion data.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t get_conversion_data(uint32_t reg)
|
||||
{
|
||||
uint32_t result = (uint32_t)((reg & ADxREGn_ADRn_MASK) >> 4);
|
||||
|
||||
return (result);
|
||||
}
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn TXZ_Result adc_ch_init(adc_ch_t *p_obj)
|
||||
* @brief Initialize the ADC Channel object.
|
||||
* @param[in][out] p_obj :ADC Channel object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @pre Conversion has stoped.
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result adc_ch_init(adc_ch_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
if (((void*)(p_obj) == (void*)0) ||
|
||||
((volatile void*)(p_obj->p_tset) == (volatile void*)0) ||
|
||||
((volatile const void*)(p_obj->p_reg) == (volatile const void*)0))
|
||||
{
|
||||
result = TXZ_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Register Setting */
|
||||
/*------------------------------*/
|
||||
/*--- ADxREGx ---*/
|
||||
/* Read is needed before the next convertion. */
|
||||
{
|
||||
volatile uint32_t reg;
|
||||
reg = *p_obj->p_reg;
|
||||
}
|
||||
/*--- ADxTSET ---*/
|
||||
*p_obj->p_tset = (p_obj->init.interrupt | p_obj->init.type | p_obj->init.ain);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn TXZ_Result adc_ch_deinit(adc_ch_t *p_obj)
|
||||
* @brief Release the ADC Channel object.
|
||||
* @param[in][out] p_obj :ADC Channel object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result adc_ch_deinit(adc_ch_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
if ((void*)(p_obj) == (void*)0)
|
||||
{
|
||||
result = TXZ_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Register Setting */
|
||||
/*------------------------------*/
|
||||
/*--- ADxTSET ---*/
|
||||
*p_obj->p_tset = (ADxTSETn_ENINT_DISABLE | ADxTSETn_TRGS_DISABLE | 0);
|
||||
/*--- ADxREGx ---*/
|
||||
/* Read is needed before the next convertion. */
|
||||
{
|
||||
volatile uint32_t reg;
|
||||
reg = *p_obj->p_reg;
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn TXZ_Result adc_ch_int_enable(adc_ch_t *p_obj)
|
||||
* @brief Enable Interrupt.
|
||||
* @param[in][out] p_obj :ADC Channel object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @pre Conversion has stoped.
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result adc_ch_int_enable(adc_ch_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
if (((void*)(p_obj) == (void*)0) ||
|
||||
((volatile void*)(p_obj->p_tset) == (volatile void*)0) ||
|
||||
((volatile const void*)(p_obj->p_reg) == (volatile const void*)0))
|
||||
{
|
||||
result = TXZ_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Register Setting */
|
||||
/*------------------------------*/
|
||||
/*--- ADxTSET ---*/
|
||||
{
|
||||
uint32_t tset = (*p_obj->p_tset & ~ADxTSETn_ENINT_MASK);
|
||||
|
||||
*p_obj->p_tset = (tset | ADxTSETn_ENINT_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn TXZ_Result adc_ch_int_disable(adc_ch_t *p_obj)
|
||||
* @brief Disable Interrupt.
|
||||
* @param[in][out] p_obj :ADC Channel object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @pre Conversion has stoped.
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result adc_ch_int_disable(adc_ch_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
if (((void*)(p_obj) == (void*)0) ||
|
||||
((volatile void*)(p_obj->p_tset) == (volatile void*)0) ||
|
||||
((volatile const void*)(p_obj->p_reg) == (volatile const void*)0))
|
||||
{
|
||||
result = TXZ_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Register Setting */
|
||||
/*------------------------------*/
|
||||
/*--- ADxTSET ---*/
|
||||
{
|
||||
uint32_t tset = (*p_obj->p_tset & ~ADxTSETn_ENINT_MASK);
|
||||
|
||||
*p_obj->p_tset = (tset | ADxTSETn_ENINT_DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/*!
|
||||
* @fn TXZ_Result adc_ch_get_value(adc_ch_t *p_obj, uint32_t *p_value)
|
||||
* @brief Get conversion value.
|
||||
* @param p_obj :ADC Channel object.
|
||||
* @param p_value :AD value. Destination address.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @pre Conversion has done.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result adc_ch_get_value(adc_ch_t *p_obj, uint32_t *p_value)
|
||||
{
|
||||
TXZ_Result result = TXZ_ERROR;
|
||||
uint32_t reg;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
if ((void*)(p_obj) == (void*)0)
|
||||
{
|
||||
result = TXZ_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
reg = *p_obj->p_reg;
|
||||
/*------------------------------*/
|
||||
/* Check Result */
|
||||
/*------------------------------*/
|
||||
if ((reg & ADxREGn_ADRFn_MASK) == ADxREGn_ADRFn_ON)
|
||||
{
|
||||
*p_value = get_conversion_data(reg);
|
||||
result = TXZ_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group ADC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#endif /* defined(__ADC_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
@ -0,0 +1,646 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file fc.c
|
||||
* @brief Flash_Userboot Sample Application.
|
||||
* @version V1.0.1.0
|
||||
* $Date:: 2017-06-23 13:52:12 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
#include "tmpm4g9_fc.h"
|
||||
//#include "txz_sample_def.h"
|
||||
|
||||
/**
|
||||
* @addtogroup Example
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Flash_Userboot Flash_Userboot Sample Appli
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_macro Flash_Userboot Private Macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_define Flash_Userboot Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_define Flash_Userboot Private Define
|
||||
* @{
|
||||
*/
|
||||
#define FC_KCR_KEYCODE (0xA74A9D23UL) /*!< The specific code that writes the FCKCR register. */
|
||||
#define FC_BRANK_VALUE (uint32_t)(0xFFFFFFFFUL) /*!< Brank value */
|
||||
#define FC_MAX_PAGES (uint8_t)(0x20) /*!< Maxmum pages */
|
||||
#define FC_CMD_ADDRESS_MASK (uint32_t)(0xFFFF0000UL) /*!< Upper address mask of the upper address */
|
||||
#define FC_CMD_BC1_ADDR (0x00000550UL) /*!< The lower address of the first bus cycle when uses commans */
|
||||
#define FC_CMD_BC2_ADDR (0x00000AA0UL) /*!< The lower address of the second bus cycle when uses commans */
|
||||
|
||||
/****************** Changed by TSIP *************************************/
|
||||
///* Area Selection All */
|
||||
#define FC_AREASEL_EXPECT_AREA0 (uint32_t)(0x00000000UL)
|
||||
#define FC_AREASEL_AREA0 (uint32_t)(0x00000777UL) //select Area 0,1 and 2
|
||||
#define FC_AREASEL_MASK_AREA0 (uint32_t)(0xFF8F0888UL) //mask Area 0,1 and 2
|
||||
#define FC_AREASEL_WRITE_MODE (uint32_t)(0x1C000000UL)
|
||||
|
||||
static uint32_t fc_const_code_flash_address[FC_MAX_PAGES] = {
|
||||
(0x5E000000UL), /*!< CODE FLASH Page0 */
|
||||
(0x5E001000UL), /*!< CODE FLASH Page1 */
|
||||
(0x5E002000UL), /*!< CODE FLASH Page2 */
|
||||
(0x5E003000UL), /*!< CODE FLASH Page3 */
|
||||
(0x5E004000UL), /*!< CODE FLASH Page4 */
|
||||
(0x5E005000UL), /*!< CODE FLASH Page5 */
|
||||
(0x5E006000UL), /*!< CODE FLASH Page6 */
|
||||
(0x5E007000UL), /*!< CODE FLASH Page7 */
|
||||
(0x5E008000UL), /*!< CODE FLASH Page8 */
|
||||
(0x5E009000UL), /*!< CODE FLASH Page9 */
|
||||
(0x5E00A000UL), /*!< CODE FLASH Page10 */
|
||||
(0x5E00B000UL), /*!< CODE FLASH Page11 */
|
||||
(0x5E00C000UL), /*!< CODE FLASH Page12 */
|
||||
(0x5E00D000UL), /*!< CODE FLASH Page13 */
|
||||
(0x5E00E000UL), /*!< CODE FLASH Page14 */
|
||||
(0x5E00F000UL), /*!< CODE FLASH Page15 */
|
||||
(0x5E010000UL), /*!< CODE FLASH Page16 */
|
||||
(0x5E011000UL), /*!< CODE FLASH Page17 */
|
||||
(0x5E012000UL), /*!< CODE FLASH Page18 */
|
||||
(0x5E013000UL), /*!< CODE FLASH Page19 */
|
||||
(0x5E014000UL), /*!< CODE FLASH Page20 */
|
||||
(0x5E015000UL), /*!< CODE FLASH Page21 */
|
||||
(0x5E016000UL), /*!< CODE FLASH Page22 */
|
||||
(0x5E017000UL), /*!< CODE FLASH Page23 */
|
||||
(0x5E018000UL), /*!< CODE FLASH Page24 */
|
||||
(0x5E019000UL), /*!< CODE FLASH Page25 */
|
||||
(0x5E01A000UL), /*!< CODE FLASH Page26 */
|
||||
(0x5E01B000UL), /*!< CODE FLASH Page27 */
|
||||
(0x5E01C000UL), /*!< CODE FLASH Page28 */
|
||||
(0x5E01D000UL), /*!< CODE FLASH Page29 */
|
||||
(0x5E01E000UL), /*!< CODE FLASH Page30 */
|
||||
(0x5E01F000UL) /*!< CODE FLASH Page31 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_define Flash_Userboot Private Define
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_typedef Flash_Userboot Private Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Member */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_variables Flash_Userboot Private Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_variables */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Private_fuctions Flash_Userboot Private Fuctions
|
||||
* @{
|
||||
*/
|
||||
__STATIC_INLINE TXZ_Result fc_enable_areasel(void);
|
||||
__STATIC_INLINE TXZ_Result fc_disable_areasel(void);
|
||||
static void fc_write_command(uint32_t* src_address, uint32_t* dst_address, uint32_t size);
|
||||
static TXZ_Result fc_verify_check(uint32_t* src_address, uint32_t* dst_address, uint32_t size);
|
||||
static TXZ_Result fc_erase_command(uint32_t* flash_top_address, uint32_t* erase_top_address, fc_erase_kind_t kind);
|
||||
static TXZ_Result fc_blank_check(uint32_t* address, uint32_t size);
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Enables the AREA0.
|
||||
* @param -
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
* This function write the FCAREASEL regiset.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
__STATIC_INLINE TXZ_Result fc_enable_areasel(void)
|
||||
{
|
||||
TXZ_Result retval = TXZ_ERROR;
|
||||
/* Writes the FCKER register the KEYCODE. */
|
||||
TSB_FC->KCR = FC_KCR_KEYCODE;
|
||||
|
||||
/* Selects the area0 */
|
||||
{
|
||||
uint32_t reg = TSB_FC->AREASEL & FC_AREASEL_MASK_AREA0;
|
||||
TSB_FC->AREASEL = reg | FC_AREASEL_AREA0;
|
||||
}
|
||||
|
||||
/* Confirms the FCAREASEL register the SSF0 was set. */
|
||||
while(1){
|
||||
uint32_t i = TSB_FC->AREASEL;
|
||||
if((i & FC_AREASEL_WRITE_MODE) == FC_AREASEL_WRITE_MODE){
|
||||
retval = TXZ_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Disables the AREA0.
|
||||
* @param -
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
* This function write the FCAREASEL regiset.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
__STATIC_INLINE TXZ_Result fc_disable_areasel(void)
|
||||
{
|
||||
TXZ_Result retval = TXZ_ERROR;
|
||||
|
||||
/* Writes the FCKER register the KEYCODE. */
|
||||
TSB_FC->KCR = FC_KCR_KEYCODE;
|
||||
|
||||
/* Selects the area0 */
|
||||
{
|
||||
uint32_t reg = TSB_FC->AREASEL & FC_AREASEL_MASK_AREA0;
|
||||
TSB_FC->AREASEL = reg | FC_AREASEL_EXPECT_AREA0;
|
||||
}
|
||||
|
||||
/* Confirms the SSF0 of the FCAREASEL register is not set. */
|
||||
while(1){
|
||||
uint32_t i = TSB_FC->AREASEL;
|
||||
if((i & FC_AREASEL_WRITE_MODE) != FC_AREASEL_WRITE_MODE){
|
||||
retval = TXZ_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Writes data of the Flash ROM.
|
||||
* @param uint32_t* : src_address
|
||||
* @param uint32_t* : dst_address
|
||||
* @param uint32_t : size
|
||||
* @return -
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
static void fc_write_command(uint32_t* src_address, uint32_t* dst_address, uint32_t size)
|
||||
{
|
||||
TXZ_Result retval;
|
||||
/******** Changed/Added by TSIP next 12 lines *************/
|
||||
volatile uint32_t* addr1;
|
||||
volatile uint32_t* addr2;
|
||||
if(dst_address <= (uint32_t *)0x0007FFFFUL) {
|
||||
addr1 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC1_ADDR);
|
||||
addr2 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC2_ADDR);
|
||||
} else if(dst_address <= (uint32_t *)0x000FFFFF) {
|
||||
addr1 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC1_ADDR + 0x10000);
|
||||
addr2 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC2_ADDR + 0x10000);
|
||||
} else {
|
||||
addr1 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC1_ADDR + 0x100000);
|
||||
addr2 = (uint32_t *) ((uint32_t)FC_CODE_FLASH_ADDRESS_TOP + FC_CMD_BC2_ADDR + 0x100000);
|
||||
}
|
||||
volatile uint32_t* addr3 = (uint32_t *) ((uint32_t)dst_address + FC_CODE_FLASH_ADDRESS_TOP);
|
||||
uint32_t* source = (uint32_t *) src_address;
|
||||
|
||||
/* Enables the AREA0. Write Mode. */
|
||||
retval = fc_enable_areasel();
|
||||
|
||||
if(retval == TXZ_SUCCESS){
|
||||
uint32_t i;
|
||||
|
||||
*addr1 = (0x000000AAUL); /* bus cycle 1 */
|
||||
*addr2 = (0x00000055UL); /* bus cycle 2 */
|
||||
*addr1 = (0x000000A0UL); /* bus cycle 3 */
|
||||
for(i=(0UL); i<size; i+=(0x4UL)){
|
||||
*addr3 = *source;
|
||||
source++;
|
||||
}
|
||||
|
||||
/* Confirmation of the works start of ROM. */
|
||||
while(fc_get_status(FC_SR0_RDYBSY) == TXZ_DONE){
|
||||
};
|
||||
|
||||
/* Waits for a finish of the works in the code Flash ROM. */
|
||||
while(fc_get_status(FC_SR0_RDYBSY) == TXZ_BUSY){
|
||||
};
|
||||
}
|
||||
|
||||
/* Disables the AREA0. Read Mode. */
|
||||
retval = fc_disable_areasel();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Verifies data of the Flash ROM.
|
||||
* @param uint32_t* : src_address
|
||||
* @param uint32_t* : dst_address
|
||||
* @param uint32_t : size
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
static TXZ_Result fc_verify_check(uint32_t* src_address, uint32_t* dst_address, uint32_t size)
|
||||
{
|
||||
TXZ_Result retval = TXZ_ERROR;
|
||||
int res = memcmp(src_address, dst_address, size);
|
||||
if(res == 0){
|
||||
retval = TXZ_SUCCESS;
|
||||
}
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Auro page erase command of the flash ROM.
|
||||
* @param uint32_t* flash_top_address : flash top address
|
||||
* @param uint32_t* erase_top_address : erase top address
|
||||
* @param fc_erase_kind_t kind : Chip, Area, Block, Page, etc.
|
||||
* @return -
|
||||
* @note This function erases specified place of the flash ROM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
//TXZ_Result fc_erase_pages_flash(uint32_t* top_address, uint32_t* erase_top_address)
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
static TXZ_Result fc_erase_command(uint32_t* flash_top_address, uint32_t* erase_top_address, fc_erase_kind_t kind)
|
||||
{
|
||||
TXZ_Result retval;
|
||||
|
||||
/******** Changed/Added by TSIP next 12 lines *************/
|
||||
volatile uint32_t *addr1;
|
||||
volatile uint32_t *addr2;
|
||||
if(erase_top_address <= (uint32_t *)0x5E07FFFFUL) {
|
||||
addr1 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC1_ADDR);
|
||||
addr2 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC2_ADDR);
|
||||
} else if(erase_top_address <= (uint32_t *)0x5E0FFFFF) {
|
||||
addr1 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC1_ADDR + 0x10000);
|
||||
addr2 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC2_ADDR + 0x10000);
|
||||
} else {
|
||||
addr1 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC1_ADDR + 0x100000);
|
||||
addr2 = (uint32_t *) ((uint32_t)flash_top_address + FC_CMD_BC2_ADDR + 0x100000);
|
||||
}
|
||||
volatile uint32_t *addr3 = (uint32_t *) erase_top_address;
|
||||
/* Enables the AREA0. Write Mode. */
|
||||
retval = fc_enable_areasel();
|
||||
// printf("Areasel done\n\r");
|
||||
|
||||
if(retval == TXZ_SUCCESS){
|
||||
*addr1 = (0x000000AAUL);
|
||||
*addr2 = (0x00000055UL);
|
||||
*addr1 = (0x00000080UL);
|
||||
*addr1 = (0x000000AAUL);
|
||||
*addr2 = (0x00000055UL);
|
||||
*addr3 = kind;
|
||||
|
||||
/* Confirmation of the works start of ROM. */
|
||||
while(fc_get_status(FC_SR0_RDYBSY) == TXZ_DONE){
|
||||
};
|
||||
|
||||
/* Waits for a finish of the works in the code Flash ROM. */
|
||||
while(fc_get_status(FC_SR0_RDYBSY) == TXZ_BUSY){
|
||||
};
|
||||
}
|
||||
|
||||
/* Disables the AREA0. Read Mode. */
|
||||
retval = fc_disable_areasel();
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Checks a blank of the Flash ROM every 4bytes.
|
||||
* @param uint32_t* : addrress
|
||||
* @param uint32_t : size
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
static TXZ_Result fc_blank_check(uint32_t* address, uint32_t size)
|
||||
{
|
||||
TXZ_Result retval = TXZ_SUCCESS;
|
||||
|
||||
uint32_t i;
|
||||
|
||||
for(i=0; i<(size/sizeof(uint32_t)); i++){
|
||||
uint32_t* addr = &address[i];
|
||||
if(*addr != FC_BRANK_VALUE){
|
||||
retval = TXZ_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Private_fuctions */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup Flash_Userboot_Exported_functions Flash_Userboot Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Get the status of the flash auto operation.
|
||||
* @param fc_sr0_t : status
|
||||
* @return Result.
|
||||
* @retval TXZ_BUSY : Busy.
|
||||
* @retval TXZ_DONE : Done.
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
TXZ_WorkState fc_get_status(fc_sr0_t status)
|
||||
{
|
||||
TXZ_WorkState retval = TXZ_BUSY;
|
||||
uint32_t work32;
|
||||
|
||||
/* Reads the FCSR0. Masks the other specfic status */
|
||||
work32 = TSB_FC->SR0 & (uint32_t)status;
|
||||
|
||||
/* Confirms the specific status of the flash ROM */
|
||||
if(work32 == (uint32_t)status){
|
||||
retval = TXZ_DONE;
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Auto write command of the code flash ROM.
|
||||
* @param uint32_t* : src_address
|
||||
* @param uint32_t* : dst_address
|
||||
* @param uint32_t : size
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
* This function writes 16bytes data to the code Flash ROM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
TXZ_Result fc_write_code_flash(uint32_t* src_address, uint32_t* dst_address, uint32_t size)
|
||||
{
|
||||
TXZ_Result retval = TXZ_SUCCESS;
|
||||
|
||||
/* Checks the code Flash ROM status */
|
||||
if(fc_get_status(FC_SR0_RDYBSY) == TXZ_DONE){
|
||||
|
||||
uint32_t i;
|
||||
/* Checks the code Flash ROM status */
|
||||
for(i=0;i<size;i+=(uint32_t)(0x10UL)){
|
||||
/* Writes 16bytes data. */
|
||||
fc_write_command((uint32_t*)((uint32_t)src_address+i), (uint32_t*)((uint32_t)dst_address+i), (uint32_t)(0x10UL));
|
||||
}
|
||||
|
||||
/* Verifies user data and data of the Flash ROM. */
|
||||
retval = fc_verify_check(src_address, dst_address, size);
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Auro page erase command of the code flash ROM.
|
||||
* @param first_page : The first page to erase
|
||||
* @param num_of_pages : The number of pages to erase.
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
* This function erases specified page of the code Flash ROM and checks a blank.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result fc_erase_page_code_flash(fc_code_flash_page_number_t first_page, uint8_t num_of_pages)
|
||||
{
|
||||
TXZ_Result retval = TXZ_SUCCESS;
|
||||
|
||||
/* Checks the code Flash ROM status */
|
||||
if(fc_get_status(FC_SR0_RDYBSY) == TXZ_DONE){
|
||||
/* Checks the number of maximum pages. */
|
||||
if((first_page + num_of_pages) <= FC_MAX_PAGES){
|
||||
uint8_t i;
|
||||
for(i=0; i<num_of_pages ; i++){
|
||||
/* Erases the specific page. */
|
||||
fc_erase_command((uint32_t*)FC_CODE_FLASH_ADDRESS_TOP,
|
||||
(uint32_t*)fc_const_code_flash_address[first_page+i],
|
||||
FC_ERASE_KIND_PAGE);
|
||||
}
|
||||
/* Checks a blank of the specific page. */
|
||||
if(fc_blank_check((uint32_t*)fc_const_code_flash_address[first_page], FC_PAGE_SIZE*(uint32_t)num_of_pages) == TXZ_ERROR){
|
||||
retval = TXZ_ERROR;
|
||||
}
|
||||
}
|
||||
else{
|
||||
retval = TXZ_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
retval = TXZ_ERROR;
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Checks a blank of the code Flash ROM of specified pages.
|
||||
* @param first_page : The first page which checks a blank.
|
||||
* @param last_page : The last page which checks a blank..
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
TXZ_Result fc_blank_check_page_code_flash(fc_code_flash_page_number_t first_page, fc_code_flash_page_number_t last_page)
|
||||
{
|
||||
TXZ_Result retval;
|
||||
|
||||
uint32_t* address = (uint32_t*)fc_const_code_flash_address[first_page];
|
||||
uint32_t size = ((uint32_t)(last_page - first_page + 1) * (uint32_t)FC_PAGE_SIZE);
|
||||
|
||||
retval = fc_blank_check(address, size);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/*************** written by TSIP ******************/
|
||||
/**
|
||||
* @brief Erases the entire block of code Flash ROM of specified address.
|
||||
* @param uint32_t *top_addr : top address of Flash ROM.
|
||||
* @param uint32_t *blk_addr : start address of block to be erased.
|
||||
* @return Result.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note It works in the inner RAM.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
#if defined ( __GNUC__ ) /* GCC Compiler */
|
||||
__attribute__((section(".ram_func")))
|
||||
#endif
|
||||
#if defined ( __ICCARM__ ) // IAR Compiler
|
||||
__ramfunc
|
||||
#endif
|
||||
TXZ_Result fc_erase_block_code_flash(uint32_t *top_addr, uint32_t *blk_addr)
|
||||
{
|
||||
TXZ_Result retval = TXZ_SUCCESS;
|
||||
/* Checks the code Flash ROM status */
|
||||
if(fc_get_status(FC_SR0_RDYBSY) == TXZ_DONE){
|
||||
/* Erases the specific block. */
|
||||
fc_erase_command((uint32_t*)FC_CODE_FLASH_ADDRESS_TOP, blk_addr, FC_ERASE_KIND_BLOCK);
|
||||
/* Checks a blank of the specific block. */
|
||||
if(fc_blank_check(blk_addr, (uint32_t)0x8000) == TXZ_ERROR){
|
||||
retval = TXZ_ERROR;
|
||||
} else{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
else {
|
||||
retval = TXZ_ERROR;
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Flash_Userboot */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Example */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
|
@ -0,0 +1,492 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_cg.c
|
||||
* @brief This file provides API functions for CG driver.
|
||||
* @version V1.0.0.1
|
||||
* $Date:: 2018-04-04 18:04:44 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_cg.h"
|
||||
|
||||
#if defined(__CG_H)
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup CG
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Private_define CG Private Define
|
||||
* @{
|
||||
*/
|
||||
/* no define */
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Private_define CG Private Define
|
||||
* @{
|
||||
*/
|
||||
#define CG_FSYS_MASK ((uint32_t)0x00070000) /*!< CG FSYS mask */
|
||||
|
||||
#define CG_FSYS_1 ((uint32_t)0x00000000) /*!< CG fc register value */
|
||||
#define CG_FSYS_2 ((uint32_t)0x00010000) /*!< CG fc/2 register value */
|
||||
#define CG_FSYS_4 ((uint32_t)0x00020000) /*!< CG fc/4 register value */
|
||||
#define CG_FSYS_8 ((uint32_t)0x00030000) /*!< CG fc/8 register value */
|
||||
#define CG_FSYS_16 ((uint32_t)0x00040000) /*!< CG fc/16 register value */
|
||||
|
||||
#define CG_FSYS_1_MUL ((uint32_t)0x00000001) /*!< CG fc multiplication value */
|
||||
#define CG_FSYS_2_MUL ((uint32_t)0x00000002) /*!< CG fc/2 multiplication value */
|
||||
#define CG_FSYS_4_MUL ((uint32_t)0x00000004) /*!< CG fc/4 multiplication value */
|
||||
#define CG_FSYS_8_MUL ((uint32_t)0x00000008) /*!< CG fc/8 multiplication value */
|
||||
#define CG_FSYS_16_MUL ((uint32_t)0x00000010) /*!< CG fc/16 multiplication value */
|
||||
|
||||
#define CG_PRCK_MASK ((uint32_t)0x00000F00) /*!< CG PRCK mask */
|
||||
|
||||
#define CG_PRCK_1 ((uint32_t)0x00000000) /*!< CG ƒÓT0 fc register value */
|
||||
#define CG_PRCK_2 ((uint32_t)0x00000100) /*!< CG ƒÓT0 fc/2 register value */
|
||||
#define CG_PRCK_4 ((uint32_t)0x00000200) /*!< CG ƒÓT0 fc/4 register value */
|
||||
#define CG_PRCK_8 ((uint32_t)0x00000300) /*!< CG ƒÓT0 fc/8 register value */
|
||||
#define CG_PRCK_16 ((uint32_t)0x00000400) /*!< CG ƒÓT0 fc/16 register value */
|
||||
#define CG_PRCK_32 ((uint32_t)0x00000500) /*!< CG ƒÓT0 fc/32 register value */
|
||||
#define CG_PRCK_64 ((uint32_t)0x00000600) /*!< CG ƒÓT0 fc/64 register value */
|
||||
#define CG_PRCK_128 ((uint32_t)0x00000700) /*!< CG ƒÓT0 fc/128 register value */
|
||||
#define CG_PRCK_256 ((uint32_t)0x00000800) /*!< CG ƒÓT0 fc/256 register value */
|
||||
#define CG_PRCK_512 ((uint32_t)0x00000900) /*!< CG ƒÓT0 fc/512 register value */
|
||||
|
||||
#define CG_PRCKST_MASK ((uint32_t)0x0F000000) /*!< CG PRCKST mask */
|
||||
|
||||
#define CG_PRCKST_1 ((uint32_t)0x00000000) /*!< CG ƒÓT0 fc register status */
|
||||
#define CG_PRCKST_2 ((uint32_t)0x01000000) /*!< CG ƒÓT0 fc/2 register status */
|
||||
#define CG_PRCKST_4 ((uint32_t)0x02000000) /*!< CG ƒÓT0 fc/4 register status */
|
||||
#define CG_PRCKST_8 ((uint32_t)0x03000000) /*!< CG ƒÓT0 fc/8 register status */
|
||||
#define CG_PRCKST_16 ((uint32_t)0x04000000) /*!< CG ƒÓT0 fc/16 register status */
|
||||
#define CG_PRCKST_32 ((uint32_t)0x05000000) /*!< CG ƒÓT0 fc/32 register status */
|
||||
#define CG_PRCKST_64 ((uint32_t)0x06000000) /*!< CG ƒÓT0 fc/64 register status */
|
||||
#define CG_PRCKST_128 ((uint32_t)0x07000000) /*!< CG ƒÓT0 fc/128 register status */
|
||||
#define CG_PRCKST_256 ((uint32_t)0x08000000) /*!< CG ƒÓT0 fc/256 register status */
|
||||
#define CG_PRCKST_512 ((uint32_t)0x09000000) /*!< CG ƒÓT0 fc/512 register status */
|
||||
|
||||
#define CG_PRCK_1_DIV ((uint32_t)0x00000001) /*!< CG ƒÓT0 fc division value */
|
||||
#define CG_PRCK_2_DIV ((uint32_t)0x00000002) /*!< CG ƒÓT0 fc/2 division value */
|
||||
#define CG_PRCK_4_DIV ((uint32_t)0x00000004) /*!< CG ƒÓT0 fc/4 division value */
|
||||
#define CG_PRCK_8_DIV ((uint32_t)0x00000008) /*!< CG ƒÓT0 fc/8 division value */
|
||||
#define CG_PRCK_16_DIV ((uint32_t)0x00000010) /*!< CG ƒÓT0 fc/16 division value */
|
||||
#define CG_PRCK_32_DIV ((uint32_t)0x00000020) /*!< CG ƒÓT0 fc/32 division value */
|
||||
#define CG_PRCK_64_DIV ((uint32_t)0x00000040) /*!< CG ƒÓT0 fc/64 division value */
|
||||
#define CG_PRCK_128_DIV ((uint32_t)0x00000080) /*!< CG ƒÓT0 fc/128 division value */
|
||||
#define CG_PRCK_256_DIV ((uint32_t)0x00000100) /*!< CG ƒÓT0 fc/256 division value */
|
||||
#define CG_PRCK_512_DIV ((uint32_t)0x00000200) /*!< CG ƒÓT0 fc/512 division value */
|
||||
|
||||
|
||||
#define CG_MCKSELPST_MASK ((uint32_t)0xC0000000) /*!< CG MCKSEL mask */
|
||||
|
||||
#define CG_MCKSELPST_1 ((uint32_t)0x00000000) /*!< CG ƒÓT0 fc/PRCK value */
|
||||
#define CG_MCKSELPST_2 ((uint32_t)0x40000000) /*!< CG ƒÓT0 fc/PRCK/2 value */
|
||||
#define CG_MCKSELPST_4 ((uint32_t)0x80000000) /*!< CG ƒÓT0 fc/PRCK/4 value */
|
||||
|
||||
#define CG_FSYSM_1_DIV ((uint32_t)0x00000001) /*!< CG fsysm ƒÓT0 division value */
|
||||
#define CG_FSYSM_2_DIV ((uint32_t)0x00000002) /*!< CG fsysm ƒÓT0/2 division value */
|
||||
#define CG_FSYSM_4_DIV ((uint32_t)0x00000004) /*!< CG fsysm ƒÓT0/4 division value */
|
||||
|
||||
#define CG_IHOSC_DISABLE ((uint32_t)0x00000000) /*!< Internal high-speed oscillator disable */
|
||||
#define CG_IHOSC_ENABLE ((uint32_t)0x00000001) /*!< Internal high-speed oscillator enable */
|
||||
|
||||
#define CG_IHOSC1EN ((uint32_t)0x00000000) /*!< CG OSCCR bit0 */
|
||||
|
||||
#define CG_MCKSELGST_MASK ((uint32_t)0x00C00000) /*!< CG MCKSELGST mask */
|
||||
#define CG_MCKSELGST_1 ((uint32_t)0x00000000) /*!< CG fsysm fc/PRCK value */
|
||||
#define CG_MCKSELGST_2 ((uint32_t)0x00400000) /*!< CG fsysm fc/PRCK/2 value */
|
||||
#define CG_MCKSELGST_4 ((uint32_t)0x00800000) /*!< CG fsysm fc/PRCK/4 value */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Private_define CG Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Private_typedef CG Private Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Private_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Private_fuctions CG Private Fuctions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Private_functions */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup CG_Exported_functions CG Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Update Middle PrescalerClock according register values.
|
||||
* @param p_obj :CG object.
|
||||
* @retval Middle PrescalerClock Frequency.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t cg_get_fsysm(cg_t *p_obj)
|
||||
{
|
||||
uint32_t result = 0U;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the CG_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
/* System core clock update */
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
switch (p_obj->p_instance->SYSCR & CG_MCKSELGST_MASK)
|
||||
{
|
||||
case CG_MCKSELGST_1: /* fsysm -> fc/PRCK */
|
||||
result = SystemCoreClock / CG_FSYSM_1_DIV;
|
||||
break;
|
||||
case CG_MCKSELGST_2: /* fsysm -> fc/PRCK/2 */
|
||||
result = SystemCoreClock / CG_FSYSM_2_DIV;
|
||||
break;
|
||||
case CG_MCKSELGST_4: /* fsysm -> fc/PRCK/4 */
|
||||
result = SystemCoreClock / CG_FSYSM_4_DIV;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
return (result);
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Update PrescalerClock according register values.
|
||||
* @param p_obj :CG object.
|
||||
* @retval PrescalerClock Frequency.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t cg_get_phyt0(cg_t *p_obj)
|
||||
{
|
||||
uint32_t result = 0U;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the CG_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
/* System core clock update */
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/* Get Gear status. */
|
||||
switch (p_obj->p_instance->SYSCR & CG_FSYS_MASK)
|
||||
{
|
||||
case CG_FSYS_1: /* Gear -> fc */
|
||||
result = SystemCoreClock * CG_FSYS_1_MUL;
|
||||
break;
|
||||
case CG_FSYS_2: /* Gear -> fc/2 */
|
||||
result = SystemCoreClock * CG_FSYS_2_MUL;
|
||||
break;
|
||||
case CG_FSYS_4: /* Gear -> fc/4 */
|
||||
result = SystemCoreClock * CG_FSYS_4_MUL;
|
||||
break;
|
||||
case CG_FSYS_8: /* Gear -> fc/8 */
|
||||
result = SystemCoreClock * CG_FSYS_8_MUL;
|
||||
break;
|
||||
case CG_FSYS_16: /* Gear -> fc/16 */
|
||||
result = SystemCoreClock * CG_FSYS_16_MUL;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (p_obj->p_instance->SYSCR & CG_PRCKST_MASK)
|
||||
{
|
||||
case CG_PRCKST_1: /* ƒÓT0 -> fc */
|
||||
result /= CG_PRCK_1_DIV;
|
||||
break;
|
||||
case CG_PRCKST_2: /* ƒÓT0 -> fc/2 */
|
||||
result /= CG_PRCK_2_DIV;
|
||||
break;
|
||||
case CG_PRCKST_4: /* ƒÓT0 -> fc/4 */
|
||||
result /= CG_PRCK_4_DIV;
|
||||
break;
|
||||
case CG_PRCKST_8: /* ƒÓT0 -> fc/8 */
|
||||
result /= CG_PRCK_8_DIV;
|
||||
break;
|
||||
case CG_PRCKST_16: /* ƒÓT0 -> fc/16 */
|
||||
result /= CG_PRCK_16_DIV;
|
||||
break;
|
||||
case CG_PRCKST_32: /* ƒÓT0 -> fc/32 */
|
||||
result /= CG_PRCK_32_DIV;
|
||||
break;
|
||||
case CG_PRCKST_64: /* ƒÓT0 -> fc/64 */
|
||||
result /= CG_PRCK_64_DIV;
|
||||
break;
|
||||
case CG_PRCKST_128: /* ƒÓT0 -> fc/128 */
|
||||
result /= CG_PRCK_128_DIV;
|
||||
break;
|
||||
case CG_PRCKST_256: /* ƒÓT0 -> fc/256 */
|
||||
result /= CG_PRCK_256_DIV;
|
||||
break;
|
||||
case CG_PRCKST_512: /* ƒÓT0 -> fc/512 */
|
||||
result /= CG_PRCK_512_DIV;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Update Middle PrescalerClock according register values.
|
||||
* @param p_obj :CG object.
|
||||
* @retval Middle PrescalerClock Frequency.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t cg_get_mphyt0(cg_t *p_obj)
|
||||
{
|
||||
uint32_t result = 0U;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the CG_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
/* System core clock update */
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/* Get Gear status. */
|
||||
switch (p_obj->p_instance->SYSCR & CG_FSYS_MASK)
|
||||
{
|
||||
case CG_FSYS_1: /* Gear -> fc */
|
||||
result = SystemCoreClock * CG_FSYS_1_MUL;
|
||||
break;
|
||||
case CG_FSYS_2: /* Gear -> fc/2 */
|
||||
result = SystemCoreClock * CG_FSYS_2_MUL;
|
||||
break;
|
||||
case CG_FSYS_4: /* Gear -> fc/4 */
|
||||
result = SystemCoreClock * CG_FSYS_4_MUL;
|
||||
break;
|
||||
case CG_FSYS_8: /* Gear -> fc/8 */
|
||||
result = SystemCoreClock * CG_FSYS_8_MUL;
|
||||
break;
|
||||
case CG_FSYS_16: /* Gear -> fc/16 */
|
||||
result = SystemCoreClock * CG_FSYS_16_MUL;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
switch (p_obj->p_instance->SYSCR & CG_PRCKST_MASK)
|
||||
{
|
||||
case CG_PRCKST_1: /* ƒÓT0 -> fc */
|
||||
result /= CG_PRCK_1_DIV;
|
||||
break;
|
||||
case CG_PRCKST_2: /* ƒÓT0 -> fc/2 */
|
||||
result /= CG_PRCK_2_DIV;
|
||||
break;
|
||||
case CG_PRCKST_4: /* ƒÓT0 -> fc/4 */
|
||||
result /= CG_PRCK_4_DIV;
|
||||
break;
|
||||
case CG_PRCKST_8: /* ƒÓT0 -> fc/8 */
|
||||
result /= CG_PRCK_8_DIV;
|
||||
break;
|
||||
case CG_PRCKST_16: /* ƒÓT0 -> fc/16 */
|
||||
result /= CG_PRCK_16_DIV;
|
||||
break;
|
||||
case CG_PRCKST_32: /* ƒÓT0 -> fc/32 */
|
||||
result /= CG_PRCK_32_DIV;
|
||||
break;
|
||||
case CG_PRCKST_64: /* ƒÓT0 -> fc/64 */
|
||||
result /= CG_PRCK_64_DIV;
|
||||
break;
|
||||
case CG_PRCKST_128: /* ƒÓT0 -> fc/128 */
|
||||
result /= CG_PRCK_128_DIV;
|
||||
break;
|
||||
case CG_PRCKST_256: /* ƒÓT0 -> fc/256 */
|
||||
result /= CG_PRCK_256_DIV;
|
||||
break;
|
||||
case CG_PRCKST_512: /* ƒÓT0 -> fc/512 */
|
||||
result /= CG_PRCK_512_DIV;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (p_obj->p_instance->SYSCR & CG_MCKSELPST_MASK)
|
||||
{
|
||||
case CG_MCKSELPST_1: /* ƒÓT0 -> fc/PRCK */
|
||||
result /= CG_FSYSM_1_DIV;
|
||||
break;
|
||||
case CG_MCKSELPST_2: /* ƒÓT0 -> fc/PRCK/2 */
|
||||
result /= CG_FSYSM_2_DIV;
|
||||
break;
|
||||
case CG_MCKSELPST_4: /* ƒÓT0 -> fc/PRCK/4 */
|
||||
result /= CG_FSYSM_4_DIV;
|
||||
break;
|
||||
default:
|
||||
result = 0U;
|
||||
break;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Set Internal high-speed oscillator enable.
|
||||
* @param p_obj :CG object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result cg_ihosc_enable(cg_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the CG_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
/* Internal high-speed oscillator is enable. */
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_obj->p_instance->OSCCR,CG_IHOSC1EN))) = CG_IHOSC_ENABLE;
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Set Internal high-speed oscillator disable.
|
||||
* @param p_obj :CG object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result cg_ihosc_disable(cg_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the CG_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
/* Internal high-speed oscillator is disable. */
|
||||
(*((__IO uint32_t *)BITBAND_PERI(&p_obj->p_instance->OSCCR,CG_IHOSC1EN))) = CG_IHOSC_DISABLE;
|
||||
|
||||
return (result);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group CG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#endif /* defined(__CG_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_fuart_ex.c
|
||||
* @brief This file provides API functions for FUART driver.
|
||||
* @brief Extended functionality.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-06 10:43:01 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_fuart_include.h"
|
||||
#include "txz_fuart_ex.h"
|
||||
|
||||
#if defined(__FUART_EX_H)
|
||||
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup UART
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Private_fuctions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Private_functions */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup FUART_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Send Break.
|
||||
* @param p_obj :UART object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
* @attention Use after interrupt is disabled.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result fuart_send_break(fuart_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the FUART_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
#endif /* #ifdef DEBUG */
|
||||
/*------------------------------*/
|
||||
/* Set Break */
|
||||
/*------------------------------*/
|
||||
{
|
||||
uint32_t trans = p_obj->p_instance->LCR_H;
|
||||
|
||||
trans &= ~FUARTxLCR_H_BRK_MASK;
|
||||
trans |= FUARTxLCR_H_BRK_SEND;
|
||||
p_obj->p_instance->LCR_H = trans;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Stop Break.
|
||||
* @param p_obj :UART object.
|
||||
* @retval TXZ_SUCCESS :Success.
|
||||
* @retval TXZ_ERROR :Failure.
|
||||
* @note -
|
||||
* @attention This function is not available in interrupt.
|
||||
* @attention Use after interrupt is disabled.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
TXZ_Result fuart_stop_break(fuart_t *p_obj)
|
||||
{
|
||||
TXZ_Result result = TXZ_SUCCESS;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
/* Check the FUART_NULL of address. */
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
#endif /* #ifdef DEBUG */
|
||||
/*------------------------------*/
|
||||
/* Set Break */
|
||||
/*------------------------------*/
|
||||
{
|
||||
uint32_t trans = p_obj->p_instance->LCR_H;
|
||||
|
||||
trans &= ~FUARTxLCR_H_BRK_MASK;
|
||||
trans |= FUARTxLCR_H_BRK_STOP;
|
||||
p_obj->p_instance->LCR_H = trans;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group FUART */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#endif /* defined(__UART_EX_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,175 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_hal.c
|
||||
* @brief This file provides API functions for driver common part.
|
||||
* @version V1.0.0.0
|
||||
* $Date:: 2017-08-09 11:01:04 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_hal.h"
|
||||
|
||||
#if defined(__HAL_H)
|
||||
/**
|
||||
* @addtogroup Periph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup HAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_macro HAL Private Macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_macro */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_define HAL Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_define HAL Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_define HAL Private Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_define */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_typedef HAL Private Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_typedef */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @defgroup HAL_Private_fuctions HAL Private Fuctions
|
||||
* @{
|
||||
*/
|
||||
|
||||
static uint32_t tick;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Private_functions */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup HAL_Exported_functions
|
||||
* @{
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Increment a tick value.
|
||||
* @param -
|
||||
* @retval -
|
||||
* @note Please call by user.
|
||||
* @note In the sample, this variable is incremented each 1ms timer interrupt.
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void hal_inc_tick(void)
|
||||
{
|
||||
tick++;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Provides a tick value.
|
||||
* @param -
|
||||
* @return Tick value.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t hal_get_tick(void)
|
||||
{
|
||||
return(tick);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL_Exported_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group HAL */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Periph_Driver */
|
||||
|
||||
#endif /* defined(__HAL_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
@ -0,0 +1,415 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file txz_i2c.c
|
||||
* @brief This file provides API functions for I2C Class.
|
||||
* @version V1.0.0.2
|
||||
* $Date:: 2016-11-08 00:00:00 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENSE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA MICROELECTRONICS CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Includes */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
#include "txz_i2c.h"
|
||||
|
||||
#if defined(__I2C_H)
|
||||
|
||||
/**
|
||||
* @addtogroup Example
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup UTILITIES
|
||||
* @{
|
||||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_macro */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Configuration */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Macro Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Enumerated Type Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_define */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Structure Definition */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_typedef */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Member */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_variables */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Const Table */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_const
|
||||
* @{
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
/**
|
||||
* @brief SCK Divider value table.
|
||||
* @details SCK = b000 - b111.
|
||||
* @note NFSEL=0 (Digital Setting) Divider value.
|
||||
*/
|
||||
/*----------------------------------*/
|
||||
static const uint32_t I2C_SCK_DIVIDER_TBL[8] = { 20,24,32,48,80,144,272,528 };
|
||||
static const uint32_t I2C_SCK_LOW_MUL_TBL[8] = { 12, 14, 18, 26, 42, 74, 138, 266 };
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_const */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Private Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* no define */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_functions */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Public Function */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @addtogroup UTILITIES_Private_functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Initializing I2C Regester
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2C_init(I2C_t *p_obj)
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
p_obj->p_instance->CR2 = I2CxCR2_I2CM_ENABLE;
|
||||
p_obj->p_instance->OP = I2CxOP_INIT;
|
||||
p_obj->p_instance->CR1 = (I2CxCR1_ACK | /* I2CxCR1_NOACK | */ p_obj->init.clock.sck);
|
||||
p_obj->p_instance->AR = I2CxAR_INIT;
|
||||
p_obj->p_instance->AR2 = I2CxAR2_INIT;
|
||||
p_obj->p_instance->CR2 = I2CxCR2_INIT;
|
||||
p_obj->p_instance->PRS = (I2CxPRS_PRCK & p_obj->init.clock.prsck);
|
||||
p_obj->p_instance->IE = I2CxIE_CLEAR;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Generate start condition
|
||||
* @param p_obj :I2C object.
|
||||
* @param data :Slave address.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2C_start_condition(I2C_t *p_obj, uint32_t data)
|
||||
{
|
||||
__IO uint32_t opreg;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
opreg = p_obj->p_instance->OP;
|
||||
opreg &= ~(I2CxOP_RSTA | I2CxOP_SREN);
|
||||
if(I2C_master(p_obj)){
|
||||
if ((p_obj->p_instance->SR & I2CxSR_BB))
|
||||
{
|
||||
opreg |= I2CxOP_SREN;
|
||||
}
|
||||
}
|
||||
p_obj->p_instance->CR1 = (I2CxCR1_ACK | I2CxCR1_NOACK | p_obj->init.clock.sck);
|
||||
p_obj->p_instance->OP = opreg;
|
||||
p_obj->p_instance->DBR = (data & I2CxDBR_DB_MASK);
|
||||
p_obj->p_instance->CR2 = I2CxCR2_START_CONDITION;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return the I2c clock setting
|
||||
* @param p_obj :I2C object.
|
||||
* @param frequency :Maximum frequency.
|
||||
* @param fsys :SystemCoreClock.
|
||||
* @param p_setting :Clock data pointer.
|
||||
* @retval Non-zero :Scl frequency.
|
||||
* @retval 0 :Error.
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
uint32_t I2C_get_clock_setting(I2C_t *p_obj, uint32_t frequency, uint32_t fsys, I2C_clock_setting_t *p_setting)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_setting));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
if (frequency <= 1000000)
|
||||
{
|
||||
uint64_t sck, tmp_sck;
|
||||
uint64_t prsck, tmp_prsck;
|
||||
uint64_t fscl, tmp_fscl;
|
||||
uint64_t fx;
|
||||
uint64_t max_fx, min_fx;
|
||||
uint64_t low_width,low_width_min;
|
||||
|
||||
sck = tmp_sck = 0;
|
||||
prsck = tmp_prsck = 1;
|
||||
fscl = tmp_fscl = 0;
|
||||
|
||||
if(frequency <= 400000)
|
||||
{
|
||||
max_fx = 11428572U; /* Tpresck: 87.5ns 1/87.5 = 0.0114285714 */
|
||||
min_fx = 6666666U; /* Tpresck:150.0ns 1/150 = 0.0066666667 */
|
||||
low_width_min = 1600;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_fx = 26666667U; /* Tpresck:37.5ns 1/37.5 = 0.0266666667 */
|
||||
min_fx = 15384615U; /* Tpresck:65.0ns 1/65 = 0.0153846154 */
|
||||
low_width_min = 675;
|
||||
}
|
||||
for (prsck = 1; prsck <= 32; prsck++)
|
||||
{
|
||||
fx = ((uint64_t)fsys / prsck);
|
||||
|
||||
if ((fx < max_fx) && (fx >= min_fx))
|
||||
{
|
||||
for (sck = 0; sck <= 7; sck++)
|
||||
{
|
||||
low_width = (uint64_t)(1000000000 * prsck * I2C_SCK_LOW_MUL_TBL[sck]) / fsys;
|
||||
if(low_width < low_width_min)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
fscl = (fx / (uint64_t)I2C_SCK_DIVIDER_TBL[sck]);
|
||||
|
||||
if ((fscl <= frequency) && (fscl > tmp_fscl))
|
||||
{
|
||||
tmp_fscl = fscl;
|
||||
tmp_sck = sck;
|
||||
tmp_prsck = (prsck < 32)? prsck: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = (uint32_t)tmp_fscl;
|
||||
p_setting->sck = (uint32_t)tmp_sck;
|
||||
p_setting->prsck = (tmp_prsck < 32)? (uint32_t)tmp_prsck: 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Slave mode setting.
|
||||
* @param p_obj :I2C object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2C_slave_init(I2C_t *p_obj)
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
p_obj->p_instance->OP = I2CxOP_SLAVE_INIT;
|
||||
p_obj->p_instance->CR1 = (I2CxCR1_ACK | p_obj->init.clock.sck);
|
||||
p_obj->p_instance->CR2 = (I2CxCR2_INIT | I2CxCR2_PIN_CLEAR);
|
||||
p_obj->p_instance->CR2 = I2CxCR2_INIT;
|
||||
p_obj->p_instance->PRS = (I2CxPRS_PRCK & p_obj->init.clock.prsck);
|
||||
p_obj->p_instance->IE = 1;
|
||||
}
|
||||
#if defined(I2CSxWUP_EN)
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief I2C Wakeup Control setting.
|
||||
* @param p_obj :I2CS object.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2CS_init(I2CS_t *p_obj)
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
p_obj->p_instance->WUPCR1 = (p-obj->init.wup.sgcdi | p_obj->init.wup.ack | p_obj->init.wup.reset | p_obj->init.wup.intend);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Primary Slave Address setting.
|
||||
* @param p_obj :I2CS object.
|
||||
* @param addr :Primary Slave Address.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2CS_Primary_slave_adr_set(I2CS_t *p_obj, uint32_t adr)
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
p_obj->p_instance->WUPCR2 = (0x0000000E & adr);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
/**
|
||||
* @brief Secondary Slave Address setting.
|
||||
* @param p_obj :I2CS object.
|
||||
* @param addr :Secondary Slave Address.
|
||||
* @retval -
|
||||
* @note -
|
||||
*/
|
||||
/*--------------------------------------------------*/
|
||||
void I2CS_Secondary_slave_adr_set(I2CS_t *p_obj, uint32_t adr)
|
||||
{
|
||||
/*------------------------------*/
|
||||
/* Parameter Check */
|
||||
/*------------------------------*/
|
||||
#ifdef DEBUG
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj));
|
||||
assert_param(IS_POINTER_NOT_NULL(p_obj->p_instance));
|
||||
#endif /* #ifdef DEBUG */
|
||||
|
||||
p_obj->p_instance->WUPCR3 = (0x0000000E & adr);
|
||||
p_obj->p_instance->WUPCR3 |= 0x00000001; /* WUPSA2EN: Secondary Slave Address Use Setting */
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES_Private_functions */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group UTILITIES */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/ /* End of group Example */
|
||||
|
||||
#endif /* defined(__I2C_H) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,192 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PERIPHERALNAMES_H
|
||||
#define MBED_PERIPHERALNAMES_H
|
||||
|
||||
#include "PinNames.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SERIAL_0 = 0,
|
||||
SERIAL_1,
|
||||
SERIAL_2,
|
||||
SERIAL_3,
|
||||
SERIAL_4,
|
||||
SERIAL_5,
|
||||
SERIAL_6,
|
||||
SERIAL_7,
|
||||
INVALID_SERIAL = (int)NC
|
||||
} UARTName;
|
||||
|
||||
typedef enum {
|
||||
DAC_0 = 0,
|
||||
DAC_1,
|
||||
INVALID_DAC = (int)NC
|
||||
} DACName;
|
||||
|
||||
typedef enum {
|
||||
PWM_0 = 0,
|
||||
PWM_1,
|
||||
PWM_2,
|
||||
PWM_3,
|
||||
PWM_4,
|
||||
PWM_5,
|
||||
PWM_6,
|
||||
PWM_7,
|
||||
PWM_8,
|
||||
PWM_9,
|
||||
PWM_10,
|
||||
PWM_11,
|
||||
PWM_12,
|
||||
INVALID_PWM = (int)NC
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
ADC_A0 = 0,
|
||||
ADC_A1,
|
||||
ADC_A2,
|
||||
ADC_A3,
|
||||
ADC_A4,
|
||||
ADC_A5,
|
||||
ADC_A6,
|
||||
ADC_A7,
|
||||
ADC_A8,
|
||||
ADC_A9,
|
||||
ADC_A10,
|
||||
ADC_A11,
|
||||
ADC_A12,
|
||||
ADC_A13,
|
||||
ADC_A14,
|
||||
ADC_A15,
|
||||
ADC_A16,
|
||||
ADC_A17,
|
||||
ADC_A18,
|
||||
ADC_A19,
|
||||
ADC_A20,
|
||||
ADC_A21,
|
||||
ADC_A22,
|
||||
ADC_A23,
|
||||
INVALID_ADC = (int)NC
|
||||
} ADCName;
|
||||
|
||||
typedef enum {
|
||||
I2C_0 = 0,
|
||||
I2C_1,
|
||||
I2C_2,
|
||||
I2C_3,
|
||||
I2C_4,
|
||||
INVALID_I2C = (int)NC
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
SPI_0 = 0,
|
||||
SPI_1,
|
||||
SPI_2,
|
||||
SPI_3,
|
||||
SPI_4,
|
||||
SPI_5,
|
||||
SPI_6,
|
||||
SPI_7,
|
||||
SPI_8,
|
||||
INVALID_SPI = (int)NC
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
GPIO_IRQ_0 = 0,
|
||||
GPIO_IRQ_1,
|
||||
GPIO_IRQ_2,
|
||||
GPIO_IRQ_3,
|
||||
GPIO_IRQ_4,
|
||||
GPIO_IRQ_5,
|
||||
GPIO_IRQ_6,
|
||||
GPIO_IRQ_7,
|
||||
GPIO_IRQ_8,
|
||||
GPIO_IRQ_9,
|
||||
GPIO_IRQ_A,
|
||||
GPIO_IRQ_B,
|
||||
GPIO_IRQ_C,
|
||||
GPIO_IRQ_D,
|
||||
GPIO_IRQ_E,
|
||||
GPIO_IRQ_F,
|
||||
INVALID_GPIO_IRQ = (int)NC
|
||||
} GPIO_IRQName;
|
||||
|
||||
// DAP UART
|
||||
#define STDIO_UART_TX USBTX
|
||||
#define STDIO_UART_RX USBRX
|
||||
|
||||
#define SERIAL_TX PU0
|
||||
#define SERIAL_RX PU1
|
||||
|
||||
#define STDIO_UART SERIAL_4
|
||||
|
||||
// TxD RxD
|
||||
#define MBED_UART0 PE3, PE2
|
||||
#define MBED_UART1 PH1, PH0
|
||||
#define MBED_UART2 PG1, PG0
|
||||
#define MBED_UART3 PU7, PU6
|
||||
#define MBED_UART4 PM1, PM0
|
||||
#define MBED_UART5 PJ1, PJ0
|
||||
#define MBED_UART6 PG4, PG5
|
||||
#define MBED_UART7 PJ6, PJ7
|
||||
#define MBED_UARTUSB USBTX, USBRX
|
||||
|
||||
// SDA SCK
|
||||
#define MBED_I2C0 PG2, PG3
|
||||
#define MBED_I2C1 PF2, PF3
|
||||
#define MBED_I2C2 PG4, PG5
|
||||
#define MBED_I2C3 PJ6, PJ7
|
||||
#define MBED_I2C4 PJ3, PJ2
|
||||
|
||||
// MOSI, MISO, SCLK SS
|
||||
#define MBED_SPI0 PA3, PA2, PA1, PA0
|
||||
#define MBED_SPI1 PL3, PL2, PL1, PL0
|
||||
#define MBED_SPI2 PA4, PA5, PA6, PA7
|
||||
#define MBED_SPI3 PK4, PK5, PK6, PK7
|
||||
#define MBED_SPI4 PD3, PD2, PD1, PD0
|
||||
#define MBED_SPI5 PV5, PV4, PV6, PV7
|
||||
#define MBED_SPI6 PM0, PM1, PM2, PM3
|
||||
#define MBED_SPI7 PM7, PM6, PM5, PM4
|
||||
#define MBED_SPI8 PW3, PW2, PW1, PW0
|
||||
|
||||
#define MBED_ANALOGIN0 A0
|
||||
#define MBED_ANALOGIN1 A1
|
||||
#define MBED_ANALOGIN2 A2
|
||||
#define MBED_ANALOGIN3 A3
|
||||
#define MBED_ANALOGIN4 A4
|
||||
#define MBED_ANALOGIN5 A5
|
||||
|
||||
#define MBED_PWMOUT0 PA5
|
||||
#define MBED_PWMOUT1 PB2
|
||||
#define MBED_PWMOUT2 PB4
|
||||
#define MBED_PWMOUT3 PD2
|
||||
#define MBED_PWMOUT4 PD4
|
||||
#define MBED_PWMOUT5 PE1
|
||||
#define MBED_PWMOUT6 PE6
|
||||
#define MBED_PWMOUT7 PC2
|
||||
#define MBED_PWMOUT8 PL6
|
||||
#define MBED_PWMOUT9 PC4
|
||||
#define MBED_PWMOUT10 PM2
|
||||
#define MBED_PWMOUT11 PU0
|
||||
#define MBED_PWMOUT12 PU6
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,135 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PIN_PORT(X) (((uint32_t)(X) >> 3) & 0xFF)
|
||||
#define PIN_POS(X) ((uint32_t)(X) & 0x7)
|
||||
|
||||
// Pin data, bit 31..16: Pin Function, bit 15..0: Pin Direction
|
||||
#define PIN_DATA(FUNC, DIR) (int)(((FUNC) << 16) | ((DIR) << 0))
|
||||
#define PIN_FUNC(X) (((X) & 0xffff0000) >> 16)
|
||||
#define PIN_DIR(X) ((X) & 0xffff)
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT,
|
||||
PIN_INOUT
|
||||
} PinDirection;
|
||||
|
||||
typedef enum {
|
||||
// TMPM4G9 Pin Names
|
||||
PA0 = 0 << 3, PA1, PA2, PA3, PA4, PA5, PA6, PA7,
|
||||
PB0 = 1 << 3, PB1, PB2, PB3, PB4, PB5, PB6, PB7,
|
||||
PC0 = 2 << 3, PC1, PC2, PC3, PC4, PC5, PC6, PC7,
|
||||
PD0 = 3 << 3, PD1, PD2, PD3, PD4, PD5, PD6, PD7,
|
||||
PE0 = 4 << 3, PE1, PE2, PE3, PE4, PE5, PE6, PE7,
|
||||
PF0 = 5 << 3, PF1, PF2, PF3, PF4, PF5, PF6, PF7,
|
||||
PG0 = 6 << 3, PG1, PG2, PG3, PG4, PG5, PG6, PG7,
|
||||
PH0 = 7 << 3, PH1, PH2, PH3, PH4, PH5, PH6, PH7,
|
||||
PJ0 = 8 << 3, PJ1, PJ2, PJ3, PJ4, PJ5, PJ6, PJ7,
|
||||
PK0 = 9 << 3, PK1, PK2, PK3, PK4, PK5, PK6, PK7,
|
||||
PL0 = 10 << 3, PL1, PL2, PL3, PL4, PL5, PL6, PL7,
|
||||
PM0 = 11 << 3, PM1, PM2, PM3, PM4, PM5, PM6, PM7,
|
||||
PN0 = 12 << 3, PN1, PN2, PN3, PN4, PN5, PN6, PN7,
|
||||
PP0 = 13 << 3, PP1, PP2, PP3, PP4, PP5, PP6, PP7,
|
||||
PR0 = 14 << 3, PR1, PR2, PR3, PR4, PR5, PR6, PR7,
|
||||
PT0 = 15 << 3, PT1, PT2, PT3, PT4, PT5,
|
||||
PU0 = 16 << 3, PU1, PU2, PU3, PU4, PU5, PU6, PU7,
|
||||
PV0 = 17 << 3, PV1, PV2, PV3, PV4, PV5, PV6, PV7,
|
||||
PW0 = 18 << 3, PW1, PW2, PW3, PW4, PW5, PW6, PW7,
|
||||
PY0 = 19 << 3, PY1, PY2, PY3, PY4,
|
||||
|
||||
// Other mbed Pin Names
|
||||
LED1 = PE4,
|
||||
LED2 = PE5,
|
||||
LED3 = PE6,
|
||||
LED4 = PE7,
|
||||
|
||||
// External data bus Pin Names
|
||||
D0 = PJ0,
|
||||
D1 = PJ1,
|
||||
D2 = PF4,
|
||||
D3 = PB2,
|
||||
D4 = PF5,
|
||||
D5 = PB4,
|
||||
D6 = PC2,
|
||||
D7 = PF6,
|
||||
D8 = PA4,
|
||||
D9 = PC4,
|
||||
D10 = PA0,
|
||||
D11 = PA3,
|
||||
D12 = PA2,
|
||||
D13 = PA1,
|
||||
D14 = PG2,
|
||||
D15 = PG3,
|
||||
|
||||
// Analogue in pins
|
||||
A0 = PN0,
|
||||
A1 = PN1,
|
||||
A2 = PN2,
|
||||
A3 = PN3,
|
||||
A4 = PN4,
|
||||
A5 = PN5,
|
||||
|
||||
// USB2_UART
|
||||
USBTX = PU0,
|
||||
USBRX = PU1,
|
||||
MBEDIF_TXD = USBTX,
|
||||
MBEDIF_RXD = USBRX,
|
||||
|
||||
MBED_CONF_APP_UART0_TX = PE3,
|
||||
MBED_CONF_APP_UART0_RX = PE2,
|
||||
|
||||
// Switches
|
||||
SW1 = PL4,
|
||||
SW2 = PL5,
|
||||
SW3 = PV0,
|
||||
SW4 = PV1,
|
||||
|
||||
// I2C pins
|
||||
SDA = PG2,
|
||||
SCL = PG3,
|
||||
I2C_SDA = SDA,
|
||||
I2C_SCL = SCL,
|
||||
|
||||
// Analogue out
|
||||
DAC0 = PT0,
|
||||
DAC1 = PT1,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF,
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullUp = 0,
|
||||
PullDown,
|
||||
PullNone,
|
||||
OpenDrain,
|
||||
PullDefault = PullDown
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,50 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PORTNAMES_H
|
||||
#define MBED_PORTNAMES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PortA = 0,
|
||||
PortB,
|
||||
PortC,
|
||||
PortD,
|
||||
PortE,
|
||||
PortF,
|
||||
PortG,
|
||||
PortH,
|
||||
PortJ,
|
||||
PortK,
|
||||
PortL,
|
||||
PortM,
|
||||
PortN,
|
||||
PortP,
|
||||
PortR,
|
||||
PortT,
|
||||
PortU,
|
||||
PortV,
|
||||
PortW,
|
||||
PortY
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,139 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "analogin_api.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "pinmap.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "mbed_error.h"
|
||||
#include "adc_include.h"
|
||||
|
||||
#define ADC_12BIT_RANGE 0xFFF
|
||||
#define CONVERSION_FLAG 0x4
|
||||
|
||||
static const PinMap PinMap_ADC[] = {
|
||||
{PN0, ADC_A0, PIN_DATA(0, 0)},
|
||||
{PN1, ADC_A1, PIN_DATA(0, 0)},
|
||||
{PN2, ADC_A2, PIN_DATA(0, 0)},
|
||||
{PN3, ADC_A3, PIN_DATA(0, 0)},
|
||||
{PN4, ADC_A4, PIN_DATA(0, 0)},
|
||||
{PN5, ADC_A5, PIN_DATA(0, 0)},
|
||||
{PN6, ADC_A6, PIN_DATA(0, 0)},
|
||||
{PN7, ADC_A7, PIN_DATA(0, 0)},
|
||||
{PP0, ADC_A8, PIN_DATA(0, 0)},
|
||||
{PP1, ADC_A9, PIN_DATA(0, 0)},
|
||||
{PP2, ADC_A10, PIN_DATA(0, 0)},
|
||||
{PP3, ADC_A11, PIN_DATA(0, 0)},
|
||||
{PP4, ADC_A12, PIN_DATA(0, 0)},
|
||||
{PP5, ADC_A13, PIN_DATA(0, 0)},
|
||||
{PP6, ADC_A14, PIN_DATA(0, 0)},
|
||||
{PP7, ADC_A15, PIN_DATA(0, 0)},
|
||||
{PR0, ADC_A16, PIN_DATA(0, 0)},
|
||||
{PR1, ADC_A17, PIN_DATA(0, 0)},
|
||||
{PR2, ADC_A18, PIN_DATA(0, 0)},
|
||||
{PR3, ADC_A19, PIN_DATA(0, 0)},
|
||||
{PR4, ADC_A20, PIN_DATA(0, 0)},
|
||||
{PR5, ADC_A21, PIN_DATA(0, 0)},
|
||||
{PR6, ADC_A22, PIN_DATA(0, 0)},
|
||||
{PR7, ADC_A23, PIN_DATA(0, 0)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
// Check that pin belong to ADC module
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// Enable ADC clock supply
|
||||
TSB_CG_FSYSMENA_IPMENA03 = TXZ_ENABLE;
|
||||
TSB_CG_SPCLKEN_ADCKEN = TXZ_ENABLE;
|
||||
TSB_CG_SPCLKEN_TRCKEN = TXZ_ENABLE;
|
||||
|
||||
// Enable clock for GPIO
|
||||
if (obj->adc <= ADC_A7) {
|
||||
TSB_CG_FSYSMENB_IPMENB14 = TXZ_ENABLE;
|
||||
} else if (obj->adc <= ADC_A15) {
|
||||
TSB_CG_FSYSMENB_IPMENB15 = TXZ_ENABLE;
|
||||
} else {
|
||||
TSB_CG_FSYSMENB_IPMENB16 = TXZ_ENABLE;
|
||||
}
|
||||
|
||||
// Set pin function as ADC
|
||||
pinmap_pinout(pin, PinMap_ADC);
|
||||
|
||||
// Initialize
|
||||
obj->p_adc.p_instance = TSB_ADA;
|
||||
obj->p_adc.init.clk.exaz0 = ADC_SAMPLING_PERIOD0_XN;
|
||||
obj->p_adc.init.clk.exaz1 = ADC_SAMPLING_PERIOD1_XN;
|
||||
obj->p_adc.init.clk.vadcld = ADC_SCLK_1;
|
||||
obj->p_adc.init.clk.sampling_select = 0;
|
||||
obj->p_adc.init.mod1 = ADC_MOD1_SCLK_3;
|
||||
obj->p_adc.init.mod2 = ADC_MOD2_TMPM4G9;
|
||||
obj->p_adc.handler.single = NULL;
|
||||
obj->p_adc.handler.continuity = NULL;
|
||||
obj->p_adc.handler.trigger = NULL;
|
||||
obj->p_adc.handler.highpriority = NULL;
|
||||
|
||||
if (adc_init(&obj->p_adc) != TXZ_SUCCESS) {
|
||||
error("Failed : ADC Initialization");
|
||||
}
|
||||
|
||||
// ADC channel setting
|
||||
obj->param.interrupt = ADC_INT_DISABLE;
|
||||
obj->param.type = ADC_CONVERSION_SGL;
|
||||
obj->param.ain = obj->adc;
|
||||
|
||||
if (adc_channel_setting(&obj->p_adc, obj->param.ain, &obj->param) != TXZ_SUCCESS) {
|
||||
error("Failed : ADC channel setting");
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t analogin_read_u16(analogin_t *obj)
|
||||
{
|
||||
uint32_t adc_result = 0;
|
||||
|
||||
// Assert that ADC channel is valid
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
if (adc_start(&obj->p_adc) == TXZ_SUCCESS) {
|
||||
// adc started
|
||||
}
|
||||
|
||||
// Wait for Continuous conversion program flag clear.
|
||||
while ((obj->p_adc.p_instance->ST & CONVERSION_FLAG)) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
if (adc_channel_get_value(&obj->p_adc, obj->param.ain, &adc_result) != TXZ_SUCCESS) {
|
||||
error("Failed : To read ADC converted result");
|
||||
}
|
||||
|
||||
if (adc_stop(&obj->p_adc) != TXZ_SUCCESS) {
|
||||
error("Failed : To Stop ADC Conversion");
|
||||
}
|
||||
|
||||
return (uint16_t)adc_result;
|
||||
}
|
||||
|
||||
float analogin_read(analogin_t *obj)
|
||||
{
|
||||
uint16_t value = 0;
|
||||
|
||||
value = analogin_read_u16(obj);
|
||||
|
||||
return (float)(value * (1.0f / (float)ADC_12BIT_RANGE));
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "mbed_assert.h"
|
||||
#include "cmsis.h"
|
||||
#include "analogout_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#define REG_DAC_DAxCR_REN_DISABLE ((uint32_t)0x00000000) // DAC Control Disable.
|
||||
#define REG_DAC_DAxCR_REN_ENABLE ((uint32_t)0x00000001) // DAC Control Enable.
|
||||
#define DAC_RANGE (0xFF) // 8 bits
|
||||
#define DAC_NB_BITS (8)
|
||||
#define DAC0_CLR_IN_CLR_OUT (1) // As per TRM DAC pin inout mode should be neither in nor out
|
||||
#define DAC1_CLR_IN_CLR_OUT (2)
|
||||
#define MAX_ANALOG_VAL (1.0f)
|
||||
#define MIN_ANALOG_VAL (0.0f)
|
||||
#define MAX_DIGITAL_VAL (0xFF)
|
||||
#define MIN_DIGITAL_VAL (0x00)
|
||||
|
||||
static const PinMap PinMap_DAC[] = {
|
||||
{PT0, DAC_0, PIN_DATA(0, 1)},
|
||||
{PT1, DAC_1, PIN_DATA(0, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static inline void dac_write(dac_t *obj,int val)
|
||||
{
|
||||
// Set the DAC output
|
||||
obj->DACx->REG = (val &= DAC_RANGE);
|
||||
}
|
||||
|
||||
static inline int dac_read(dac_t *obj)
|
||||
{
|
||||
return ((obj->DACx->REG) & DAC_RANGE);
|
||||
}
|
||||
|
||||
void analogout_init(dac_t *obj, PinName pin)
|
||||
{
|
||||
DACName dac_name = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
|
||||
MBED_ASSERT(dac_name != (DACName)NC);
|
||||
|
||||
obj->dac = dac_name;
|
||||
switch (dac_name) {
|
||||
case DAC_0:
|
||||
obj->DACx = TSB_DA0;
|
||||
// Enable clock for DAC0 and Port T
|
||||
TSB_CG_FSYSMENA_IPMENA04 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB17 = TXZ_ENABLE;
|
||||
break;
|
||||
case DAC_1:
|
||||
obj->DACx = TSB_DA1;
|
||||
// Enable clock for DAC1 and Port T
|
||||
TSB_CG_FSYSMENA_IPMENA05 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB17 = TXZ_ENABLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Pinout the chosen DAC
|
||||
pinmap_pinout(pin, PinMap_DAC);
|
||||
|
||||
// DAC pins as neither input and nor output
|
||||
if (dac_name == DAC_0) {
|
||||
TSB_PT->CR &= ~(DAC0_CLR_IN_CLR_OUT);
|
||||
TSB_PT->IE &= ~(DAC0_CLR_IN_CLR_OUT);
|
||||
} else if (dac_name == DAC_1) {
|
||||
TSB_PT->CR &= ~(DAC1_CLR_IN_CLR_OUT);
|
||||
TSB_PT->IE &= ~(DAC1_CLR_IN_CLR_OUT);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable DAC
|
||||
obj->DACx->CR = REG_DAC_DAxCR_REN_ENABLE;
|
||||
analogout_write_u16(obj, MIN_DIGITAL_VAL);
|
||||
}
|
||||
|
||||
void analogout_free(dac_t *obj)
|
||||
{
|
||||
obj->DACx->CR = REG_DAC_DAxCR_REN_DISABLE;
|
||||
obj->dac = (DACName)NC;
|
||||
}
|
||||
|
||||
void analogout_write(dac_t *obj, float value)
|
||||
{
|
||||
if (value < MIN_ANALOG_VAL) {
|
||||
dac_write(obj, MIN_DIGITAL_VAL);
|
||||
} else if (value > MAX_ANALOG_VAL) {
|
||||
dac_write(obj,DAC_RANGE);
|
||||
} else {
|
||||
dac_write(obj, value * (float)DAC_RANGE);
|
||||
}
|
||||
}
|
||||
|
||||
void analogout_write_u16(dac_t *obj, uint16_t value)
|
||||
{
|
||||
// Writing higher 8-bits to Data Register
|
||||
dac_write(obj, (value >> (16 - DAC_NB_BITS)));
|
||||
}
|
||||
|
||||
float analogout_read(dac_t *obj)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
value = dac_read(obj);
|
||||
|
||||
return (float)value * (MAX_ANALOG_VAL / (float)DAC_RANGE);
|
||||
}
|
||||
|
||||
uint16_t analogout_read_u16(dac_t *obj)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
value = dac_read(obj);
|
||||
// Upper and lower byte stored with read value
|
||||
return ((value << (16 - DAC_NB_BITS)) | value);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#define DEVICE_ID_LENGTH 32
|
||||
|
||||
#include <stddef.h>
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,534 @@
|
|||
;/**
|
||||
; *******************************************************************************
|
||||
; * @file startup_TMPM4G9.s
|
||||
; * @brief CMSIS Cortex-M4 Core Device Startup File for the
|
||||
; * TOSHIBA 'TMPM4G9' Device Series
|
||||
; * @version V1.0.6.0
|
||||
; * $Date:: 2017-10-04 #$
|
||||
; *------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||
; *
|
||||
; * DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
; *
|
||||
; * (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
; *******************************************************************************
|
||||
; */
|
||||
|
||||
__initial_sp EQU 0x20030000
|
||||
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD INT00_IRQHandler ; 0: Interrupt pin 00a/00b
|
||||
DCD INT01_IRQHandler ; 1: Interrupt pin 01a/00b
|
||||
DCD INT02_IRQHandler ; 2: Interrupt pin 02a/00b
|
||||
DCD INT03_IRQHandler ; 3: Interrupt pin 03a/03b
|
||||
DCD INT04_IRQHandler ; 4: Interrupt pin 04a/04b
|
||||
DCD INT05_IRQHandler ; 5: Interrupt pin 05a/05b
|
||||
DCD INT06_IRQHandler ; 6: Interrupt pin 06a/06b
|
||||
DCD INT07_IRQHandler ; 7: Interrupt pin 07a/07b
|
||||
DCD INT08_IRQHandler ; 8: Interrupt pin 08a/08b
|
||||
DCD INT09_IRQHandler ; 9: Interrupt pin 09a/09b
|
||||
DCD INT10_IRQHandler ; 10: Interrupt pin 10a/10b
|
||||
DCD INT11_IRQHandler ; 11: Interrupt pin 11a/11b
|
||||
DCD INT12_IRQHandler ; 12: Interrupt pin 12a/12b
|
||||
DCD INT13_IRQHandler ; 13: Interrupt pin 13a/13b
|
||||
DCD INT14_IRQHandler ; 14: Interrupt pin 14a/14b
|
||||
DCD INT15_IRQHandler ; 15: Interrupt pin 15a/15b
|
||||
DCD INTRTC_IRQHandler ; 16: Real time clock(XHz) interrupt
|
||||
DCD INTCEC0RX_IRQHandler ; 17: CEC reception interrupt (channel 0)
|
||||
DCD INTCEC0TX_IRQHandler ; 18: CEC transmission interrupt (channel 0)
|
||||
DCD INTISDA_IRQHandler ; 19: Interval Sensing Detector Interrupt (Unit A)
|
||||
DCD INTISDB_IRQHandler ; 20: Interval Sensing Detector Interrupt (Unit B)
|
||||
DCD INTISDC_IRQHandler ; 21: Interval Sensing Detector Interrupt (Unit C)
|
||||
DCD INTRMC0_IRQHandler ; 22: Remote control reception interrupt 0
|
||||
DCD INTRMC1_IRQHandler ; 23: Remote control reception interrupt 1
|
||||
DCD INTLTTMR_IRQHandler ; 24: Long Term Timer Interrupt
|
||||
DCD INTHDMAATC_IRQHandler ; 25: HDMA Complete of transfer(Unit A)
|
||||
DCD INTHDMAAERR_IRQHandler ; 26: HDMA transfer error(Unit A)
|
||||
DCD INTHDMABTC_IRQHandler ; 27: HDMA end of transfer(Unit B)
|
||||
DCD INTHDMABERR_IRQHandler ; 28: HDMA transfer error(Unit B)
|
||||
DCD INTMDMAATC_IRQHandler ; 29: MDMA Complete of transfer(Unit A)
|
||||
DCD INTT32A00_A_CT_IRQHandler ; 30: T32A00 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A00_B_C01_CPC_IRQHandler ; 31: T32A00 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A01_A_CT_IRQHandler ; 32: T32A01 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A01_B_C01_CPC_IRQHandler ; 33: T32A01 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A02_A_CT_IRQHandler ; 34: T32A02 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A02_B_C01_CPC_IRQHandler ; 35: T32A02 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A03_A_CT_IRQHandler ; 36: T32A03 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A03_B_C01_CPC_IRQHandler ; 37: T32A03 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A04_A_CT_IRQHandler ; 38: T32A04 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A04_B_C01_CPC_IRQHandler ; 39: T32A04 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A05_A_CT_IRQHandler ; 40: T32A05 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A05_B_C01_CPC_IRQHandler ; 41: T32A05 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A06_A_CT_IRQHandler ; 42: T32A06 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A06_B_C01_CPC_IRQHandler ; 43: T32A06 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A07_A_CT_IRQHandler ; 44: T32A07 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A07_B_C01_CPC_IRQHandler ; 45: T32A07 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A08_A_CT_IRQHandler ; 46: T32A08 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A08_B_C01_CPC_IRQHandler ; 47: T32A08 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A09_A_CT_IRQHandler ; 48: T32A09 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A09_B_C01_CPC_IRQHandler ; 49: T32A09 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A10_A_CT_IRQHandler ; 50: T32A10 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A10_B_C01_CPC_IRQHandler ; 51: T32A10 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A11_A_CT_IRQHandler ; 52: T32A11 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A11_B_C01_CPC_IRQHandler ; 53: T32A11 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A12_A_CT_IRQHandler ; 54: T32A12 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A12_B_C01_CPC_IRQHandler ; 55: T32A12 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A13_A_CT_IRQHandler ; 56: T32A13 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A13_B_C01_CPC_IRQHandler ; 57: T32A13 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTEMG0_IRQHandler ; 58: PMD0 EMG interrupt
|
||||
DCD INTOVV0_IRQHandler ; 59: PMD0 OVV interrupt
|
||||
DCD INTPWM0_IRQHandler ; 60: PMD0 interrupt
|
||||
DCD INTT0RX_IRQHandler ; 61: TSPI/SIO reception (channel 0)
|
||||
DCD INTT0TX_IRQHandler ; 62: TSPI/SIO transmit (channel 0)
|
||||
DCD INTT0ERR_IRQHandler ; 63: TSPI/SIO error (channel 0)
|
||||
DCD INTT1RX_IRQHandler ; 64: TSPI/SIO reception (channel 1)
|
||||
DCD INTT1TX_IRQHandler ; 65: TSPI/SIO transmit (channel 1)
|
||||
DCD INTT1ERR_IRQHandler ; 66: TSPI/SIO error (channel 1)
|
||||
DCD INTT2RX_IRQHandler ; 67: TSPI/SIO reception (channel 2)
|
||||
DCD INTT2TX_IRQHandler ; 68: TSPI/SIO transmit (channel 2)
|
||||
DCD INTT2ERR_IRQHandler ; 69: TSPI/SIO error (channel 2)
|
||||
DCD INTT3RX_IRQHandler ; 70: TSPI/SIO reception (channel 3)
|
||||
DCD INTT3TX_IRQHandler ; 71: TSPI/SIO transmit (channel 3)
|
||||
DCD INTT3ERR_IRQHandler ; 72: TSPI/SIO error (channel 3)
|
||||
DCD INTT4RX_IRQHandler ; 73: TSPI/SIO reception (channel 4)
|
||||
DCD INTT4TX_IRQHandler ; 74: TSPI/SIO transmit (channel 4)
|
||||
DCD INTT4ERR_IRQHandler ; 75: TSPI/SIO error (channel 4)
|
||||
DCD INTT5RX_IRQHandler ; 76: TSPI/SIO reception (channel 5)
|
||||
DCD INTT5TX_IRQHandler ; 77: TSPI/SIO transmit (channel 5)
|
||||
DCD INTT5ERR_IRQHandler ; 78: TSPI/SIO error (channel 5)
|
||||
DCD INTT6RX_IRQHandler ; 79: TSPI/SIO reception (channel 6)
|
||||
DCD INTT6TX_IRQHandler ; 80: TSPI/SIO transmit (channel 6)
|
||||
DCD INTT6ERR_IRQHandler ; 81: TSPI/SIO error (channel 6)
|
||||
DCD INTT7RX_IRQHandler ; 82: TSPI/SIO reception (channel 7)
|
||||
DCD INTT7TX_IRQHandler ; 83: TSPI/SIO transmit (channel 7)
|
||||
DCD INTT7ERR_IRQHandler ; 84: TSPI/SIO error (channel 7)
|
||||
DCD INTT8RX_IRQHandler ; 85: TSPI/SIO reception (channel 8)
|
||||
DCD INTT8TX_IRQHandler ; 86: TSPI/SIO transmit (channel 8)
|
||||
DCD INTT8ERR_IRQHandler ; 87: TSPI/SIO error (channel 8)
|
||||
DCD INTSMI0_IRQHandler ; 88: Serial Memory Interface Interrupt
|
||||
DCD INTUART0RX_IRQHandler ; 89: UART reception (channel 0)
|
||||
DCD INTUART0TX_IRQHandler ; 90: UART transmit (channel 0)
|
||||
DCD INTUART0ERR_IRQHandler ; 91: UART error (channel 0)
|
||||
DCD INTUART1RX_IRQHandler ; 92: UART reception (channel 1)
|
||||
DCD INTUART1TX_IRQHandler ; 93: UART transmit (channel 1)
|
||||
DCD INTUART1ERR_IRQHandler ; 94: UART error (channel 1)
|
||||
DCD INTUART2RX_IRQHandler ; 95: UART reception (channel 2)
|
||||
DCD INTUART2TX_IRQHandler ; 96: UART transmit (channel 2)
|
||||
DCD INTUART2ERR_IRQHandler ; 97: UART error (channel 2)
|
||||
DCD INTUART3RX_IRQHandler ; 98: UART reception (channel 3)
|
||||
DCD INTUART3TX_IRQHandler ; 99: UART transmit (channel 3)
|
||||
DCD INTUART3ERR_IRQHandler ; 100: UART error (channel 3)
|
||||
DCD INTUART4RX_IRQHandler ; 101: UART reception (channel 4)
|
||||
DCD INTUART4TX_IRQHandler ; 102: UART transmit (channel 4)
|
||||
DCD INTUART4ERR_IRQHandler ; 103: UART error (channel 4)
|
||||
DCD INTUART5RX_IRQHandler ; 104: UART reception (channel 5)
|
||||
DCD INTUART5TX_IRQHandler ; 105: UART transmit (channel 5)
|
||||
DCD INTUART5ERR_IRQHandler ; 106: UART error (channel 5)
|
||||
DCD INTFUART0_IRQHandler ; 107: FUART Interrupt(channel 0)
|
||||
DCD INTFUART1_IRQHandler ; 108: FUART Interrupt(channel 1)
|
||||
DCD INTI2C0_IRQHandler ; 109: I2C0 transmission and reception interrupt
|
||||
DCD INTI2C0AL_IRQHandler ; 110: I2C0 arbitration lost interrupt
|
||||
DCD INTI2C0BF_IRQHandler ; 111: I2C0 bus free interrupt
|
||||
DCD INTI2C0NACK_IRQHandler ; 112: I2C0 no ack interrupt
|
||||
DCD INTI2C1_IRQHandler ; 113: I2C1 transmission and reception interrupt
|
||||
DCD INTI2C1AL_IRQHandler ; 114: I2C1 arbitration lost interrupt
|
||||
DCD INTI2C1BF_IRQHandler ; 115: I2C1 bus free interrupt
|
||||
DCD INTI2C1NACK_IRQHandler ; 116: I2C1 no ack interrupt
|
||||
DCD INTI2C2_IRQHandler ; 117: I2C2 transmission and reception interrupt
|
||||
DCD INTI2C2AL_IRQHandler ; 118: I2C2 arbitration lost interrupt
|
||||
DCD INTI2C2BF_IRQHandler ; 119: I2C2 bus free interrupt
|
||||
DCD INTI2C2NACK_IRQHandler ; 120: I2C2 no ack interrupt
|
||||
DCD INTI2C3_IRQHandler ; 121: I2C3 transmission and reception interrupt
|
||||
DCD INTI2C3AL_IRQHandler ; 122: I2C3 arbitration lost interrupt
|
||||
DCD INTI2C3BF_IRQHandler ; 123: I2C3 bus free interrupt
|
||||
DCD INTI2C3NACK_IRQHandler ; 124: I2C3 no ack interrupt
|
||||
DCD INTI2C4_IRQHandler ; 125: I2C4 transmission and reception interrupt
|
||||
DCD INTI2C4AL_IRQHandler ; 126: I2C4 arbitration lost interrupt
|
||||
DCD INTI2C4BF_IRQHandler ; 127: I2C4 bus free interrupt
|
||||
DCD INTI2C4NACK_IRQHandler ; 128: I2C4 no ack interrupt
|
||||
DCD INTADACP0_IRQHandler ; 129: ADC conversion monitoring function interrupt 0
|
||||
DCD INTADACP1_IRQHandler ; 130: ADC conversion monitoring function interrupt 1
|
||||
DCD INTADATRG_IRQHandler ; 131: ADC conversion triggered by General purpose is finished
|
||||
DCD INTADASGL_IRQHandler ; 132: ADC conversion triggered by Single program is finished
|
||||
DCD INTADACNT_IRQHandler ; 133: ADC conversion triggered by Continuity program is finished
|
||||
DCD INTADAHP_IRQHandler ; 134: ADC High Priority AD conversion interrupt
|
||||
DCD INTFLDRDY_IRQHandler ; 135: Data FLASH Ready interrupt
|
||||
DCD INTFLCRDY0_IRQHandler ; 136: Code FLASH Area0/1 Ready interrupt
|
||||
DCD INTFLCRDY1_IRQHandler ; 137: Code FLASH Area2 Ready interrupt
|
||||
DCD 0 ; 138: Reserved
|
||||
DCD INTMDMAABERR_IRQHandler ; 139: MDMA bus error(Unit A)
|
||||
DCD INTMDMAADERR_IRQHandler ; 140: MDMA descriptor error(Unit A)
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT INT00_IRQHandler [WEAK]
|
||||
EXPORT INT01_IRQHandler [WEAK]
|
||||
EXPORT INT02_IRQHandler [WEAK]
|
||||
EXPORT INT03_IRQHandler [WEAK]
|
||||
EXPORT INT04_IRQHandler [WEAK]
|
||||
EXPORT INT05_IRQHandler [WEAK]
|
||||
EXPORT INT06_IRQHandler [WEAK]
|
||||
EXPORT INT07_IRQHandler [WEAK]
|
||||
EXPORT INT08_IRQHandler [WEAK]
|
||||
EXPORT INT09_IRQHandler [WEAK]
|
||||
EXPORT INT10_IRQHandler [WEAK]
|
||||
EXPORT INT11_IRQHandler [WEAK]
|
||||
EXPORT INT12_IRQHandler [WEAK]
|
||||
EXPORT INT13_IRQHandler [WEAK]
|
||||
EXPORT INT14_IRQHandler [WEAK]
|
||||
EXPORT INT15_IRQHandler [WEAK]
|
||||
EXPORT INTRTC_IRQHandler [WEAK]
|
||||
EXPORT INTCEC0RX_IRQHandler [WEAK]
|
||||
EXPORT INTCEC0TX_IRQHandler [WEAK]
|
||||
EXPORT INTISDA_IRQHandler [WEAK]
|
||||
EXPORT INTISDB_IRQHandler [WEAK]
|
||||
EXPORT INTISDC_IRQHandler [WEAK]
|
||||
EXPORT INTRMC0_IRQHandler [WEAK]
|
||||
EXPORT INTRMC1_IRQHandler [WEAK]
|
||||
EXPORT INTLTTMR_IRQHandler [WEAK]
|
||||
EXPORT INTHDMAATC_IRQHandler [WEAK]
|
||||
EXPORT INTHDMAAERR_IRQHandler [WEAK]
|
||||
EXPORT INTHDMABTC_IRQHandler [WEAK]
|
||||
EXPORT INTHDMABERR_IRQHandler [WEAK]
|
||||
EXPORT INTMDMAATC_IRQHandler [WEAK]
|
||||
EXPORT INTT32A00_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A00_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A01_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A01_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A02_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A02_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A03_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A03_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A04_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A04_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A05_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A05_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A06_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A06_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A07_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A07_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A08_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A08_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A09_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A09_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A10_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A10_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A11_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A11_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A12_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A12_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTT32A13_A_CT_IRQHandler [WEAK]
|
||||
EXPORT INTT32A13_B_C01_CPC_IRQHandler[WEAK]
|
||||
EXPORT INTEMG0_IRQHandler [WEAK]
|
||||
EXPORT INTOVV0_IRQHandler [WEAK]
|
||||
EXPORT INTPWM0_IRQHandler [WEAK]
|
||||
EXPORT INTT0RX_IRQHandler [WEAK]
|
||||
EXPORT INTT0TX_IRQHandler [WEAK]
|
||||
EXPORT INTT0ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT1RX_IRQHandler [WEAK]
|
||||
EXPORT INTT1TX_IRQHandler [WEAK]
|
||||
EXPORT INTT1ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT2RX_IRQHandler [WEAK]
|
||||
EXPORT INTT2TX_IRQHandler [WEAK]
|
||||
EXPORT INTT2ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT3RX_IRQHandler [WEAK]
|
||||
EXPORT INTT3TX_IRQHandler [WEAK]
|
||||
EXPORT INTT3ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT4RX_IRQHandler [WEAK]
|
||||
EXPORT INTT4TX_IRQHandler [WEAK]
|
||||
EXPORT INTT4ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT5RX_IRQHandler [WEAK]
|
||||
EXPORT INTT5TX_IRQHandler [WEAK]
|
||||
EXPORT INTT5ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT6RX_IRQHandler [WEAK]
|
||||
EXPORT INTT6TX_IRQHandler [WEAK]
|
||||
EXPORT INTT6ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT7RX_IRQHandler [WEAK]
|
||||
EXPORT INTT7TX_IRQHandler [WEAK]
|
||||
EXPORT INTT7ERR_IRQHandler [WEAK]
|
||||
EXPORT INTT8RX_IRQHandler [WEAK]
|
||||
EXPORT INTT8TX_IRQHandler [WEAK]
|
||||
EXPORT INTT8ERR_IRQHandler [WEAK]
|
||||
EXPORT INTSMI0_IRQHandler [WEAK]
|
||||
EXPORT INTUART0RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART0TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART0ERR_IRQHandler [WEAK]
|
||||
EXPORT INTUART1RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART1TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART1ERR_IRQHandler [WEAK]
|
||||
EXPORT INTUART2RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART2TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART2ERR_IRQHandler [WEAK]
|
||||
EXPORT INTUART3RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART3TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART3ERR_IRQHandler [WEAK]
|
||||
EXPORT INTUART4RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART4TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART4ERR_IRQHandler [WEAK]
|
||||
EXPORT INTUART5RX_IRQHandler [WEAK]
|
||||
EXPORT INTUART5TX_IRQHandler [WEAK]
|
||||
EXPORT INTUART5ERR_IRQHandler [WEAK]
|
||||
EXPORT INTFUART0_IRQHandler [WEAK]
|
||||
EXPORT INTFUART1_IRQHandler [WEAK]
|
||||
EXPORT INTI2C0_IRQHandler [WEAK]
|
||||
EXPORT INTI2C0AL_IRQHandler [WEAK]
|
||||
EXPORT INTI2C0BF_IRQHandler [WEAK]
|
||||
EXPORT INTI2C0NACK_IRQHandler [WEAK]
|
||||
EXPORT INTI2C1_IRQHandler [WEAK]
|
||||
EXPORT INTI2C1AL_IRQHandler [WEAK]
|
||||
EXPORT INTI2C1BF_IRQHandler [WEAK]
|
||||
EXPORT INTI2C1NACK_IRQHandler [WEAK]
|
||||
EXPORT INTI2C2_IRQHandler [WEAK]
|
||||
EXPORT INTI2C2AL_IRQHandler [WEAK]
|
||||
EXPORT INTI2C2BF_IRQHandler [WEAK]
|
||||
EXPORT INTI2C2NACK_IRQHandler [WEAK]
|
||||
EXPORT INTI2C3_IRQHandler [WEAK]
|
||||
EXPORT INTI2C3AL_IRQHandler [WEAK]
|
||||
EXPORT INTI2C3BF_IRQHandler [WEAK]
|
||||
EXPORT INTI2C3NACK_IRQHandler [WEAK]
|
||||
EXPORT INTI2C4_IRQHandler [WEAK]
|
||||
EXPORT INTI2C4AL_IRQHandler [WEAK]
|
||||
EXPORT INTI2C4BF_IRQHandler [WEAK]
|
||||
EXPORT INTI2C4NACK_IRQHandler [WEAK]
|
||||
EXPORT INTADACP0_IRQHandler [WEAK]
|
||||
EXPORT INTADACP1_IRQHandler [WEAK]
|
||||
EXPORT INTADATRG_IRQHandler [WEAK]
|
||||
EXPORT INTADASGL_IRQHandler [WEAK]
|
||||
EXPORT INTADACNT_IRQHandler [WEAK]
|
||||
EXPORT INTADAHP_IRQHandler [WEAK]
|
||||
EXPORT INTFLDRDY_IRQHandler [WEAK]
|
||||
EXPORT INTFLCRDY0_IRQHandler [WEAK]
|
||||
EXPORT INTFLCRDY1_IRQHandler [WEAK]
|
||||
EXPORT INTMDMAABERR_IRQHandler [WEAK]
|
||||
EXPORT INTMDMAADERR_IRQHandler [WEAK]
|
||||
|
||||
INT00_IRQHandler
|
||||
INT01_IRQHandler
|
||||
INT02_IRQHandler
|
||||
INT03_IRQHandler
|
||||
INT04_IRQHandler
|
||||
INT05_IRQHandler
|
||||
INT06_IRQHandler
|
||||
INT07_IRQHandler
|
||||
INT08_IRQHandler
|
||||
INT09_IRQHandler
|
||||
INT10_IRQHandler
|
||||
INT11_IRQHandler
|
||||
INT12_IRQHandler
|
||||
INT13_IRQHandler
|
||||
INT14_IRQHandler
|
||||
INT15_IRQHandler
|
||||
INTRTC_IRQHandler
|
||||
INTCEC0RX_IRQHandler
|
||||
INTCEC0TX_IRQHandler
|
||||
INTISDA_IRQHandler
|
||||
INTISDB_IRQHandler
|
||||
INTISDC_IRQHandler
|
||||
INTRMC0_IRQHandler
|
||||
INTRMC1_IRQHandler
|
||||
INTLTTMR_IRQHandler
|
||||
INTHDMAATC_IRQHandler
|
||||
INTHDMAAERR_IRQHandler
|
||||
INTHDMABTC_IRQHandler
|
||||
INTHDMABERR_IRQHandler
|
||||
INTMDMAATC_IRQHandler
|
||||
INTT32A00_A_CT_IRQHandler
|
||||
INTT32A00_B_C01_CPC_IRQHandler
|
||||
INTT32A01_A_CT_IRQHandler
|
||||
INTT32A01_B_C01_CPC_IRQHandler
|
||||
INTT32A02_A_CT_IRQHandler
|
||||
INTT32A02_B_C01_CPC_IRQHandler
|
||||
INTT32A03_A_CT_IRQHandler
|
||||
INTT32A03_B_C01_CPC_IRQHandler
|
||||
INTT32A04_A_CT_IRQHandler
|
||||
INTT32A04_B_C01_CPC_IRQHandler
|
||||
INTT32A05_A_CT_IRQHandler
|
||||
INTT32A05_B_C01_CPC_IRQHandler
|
||||
INTT32A06_A_CT_IRQHandler
|
||||
INTT32A06_B_C01_CPC_IRQHandler
|
||||
INTT32A07_A_CT_IRQHandler
|
||||
INTT32A07_B_C01_CPC_IRQHandler
|
||||
INTT32A08_A_CT_IRQHandler
|
||||
INTT32A08_B_C01_CPC_IRQHandler
|
||||
INTT32A09_A_CT_IRQHandler
|
||||
INTT32A09_B_C01_CPC_IRQHandler
|
||||
INTT32A10_A_CT_IRQHandler
|
||||
INTT32A10_B_C01_CPC_IRQHandler
|
||||
INTT32A11_A_CT_IRQHandler
|
||||
INTT32A11_B_C01_CPC_IRQHandler
|
||||
INTT32A12_A_CT_IRQHandler
|
||||
INTT32A12_B_C01_CPC_IRQHandler
|
||||
INTT32A13_A_CT_IRQHandler
|
||||
INTT32A13_B_C01_CPC_IRQHandler
|
||||
INTEMG0_IRQHandler
|
||||
INTOVV0_IRQHandler
|
||||
INTPWM0_IRQHandler
|
||||
INTT0RX_IRQHandler
|
||||
INTT0TX_IRQHandler
|
||||
INTT0ERR_IRQHandler
|
||||
INTT1RX_IRQHandler
|
||||
INTT1TX_IRQHandler
|
||||
INTT1ERR_IRQHandler
|
||||
INTT2RX_IRQHandler
|
||||
INTT2TX_IRQHandler
|
||||
INTT2ERR_IRQHandler
|
||||
INTT3RX_IRQHandler
|
||||
INTT3TX_IRQHandler
|
||||
INTT3ERR_IRQHandler
|
||||
INTT4RX_IRQHandler
|
||||
INTT4TX_IRQHandler
|
||||
INTT4ERR_IRQHandler
|
||||
INTT5RX_IRQHandler
|
||||
INTT5TX_IRQHandler
|
||||
INTT5ERR_IRQHandler
|
||||
INTT6RX_IRQHandler
|
||||
INTT6TX_IRQHandler
|
||||
INTT6ERR_IRQHandler
|
||||
INTT7RX_IRQHandler
|
||||
INTT7TX_IRQHandler
|
||||
INTT7ERR_IRQHandler
|
||||
INTT8RX_IRQHandler
|
||||
INTT8TX_IRQHandler
|
||||
INTT8ERR_IRQHandler
|
||||
INTSMI0_IRQHandler
|
||||
INTUART0RX_IRQHandler
|
||||
INTUART0TX_IRQHandler
|
||||
INTUART0ERR_IRQHandler
|
||||
INTUART1RX_IRQHandler
|
||||
INTUART1TX_IRQHandler
|
||||
INTUART1ERR_IRQHandler
|
||||
INTUART2RX_IRQHandler
|
||||
INTUART2TX_IRQHandler
|
||||
INTUART2ERR_IRQHandler
|
||||
INTUART3RX_IRQHandler
|
||||
INTUART3TX_IRQHandler
|
||||
INTUART3ERR_IRQHandler
|
||||
INTUART4RX_IRQHandler
|
||||
INTUART4TX_IRQHandler
|
||||
INTUART4ERR_IRQHandler
|
||||
INTUART5RX_IRQHandler
|
||||
INTUART5TX_IRQHandler
|
||||
INTUART5ERR_IRQHandler
|
||||
INTFUART0_IRQHandler
|
||||
INTFUART1_IRQHandler
|
||||
INTI2C0_IRQHandler
|
||||
INTI2C0AL_IRQHandler
|
||||
INTI2C0BF_IRQHandler
|
||||
INTI2C0NACK_IRQHandler
|
||||
INTI2C1_IRQHandler
|
||||
INTI2C1AL_IRQHandler
|
||||
INTI2C1BF_IRQHandler
|
||||
INTI2C1NACK_IRQHandler
|
||||
INTI2C2_IRQHandler
|
||||
INTI2C2AL_IRQHandler
|
||||
INTI2C2BF_IRQHandler
|
||||
INTI2C2NACK_IRQHandler
|
||||
INTI2C3_IRQHandler
|
||||
INTI2C3AL_IRQHandler
|
||||
INTI2C3BF_IRQHandler
|
||||
INTI2C3NACK_IRQHandler
|
||||
INTI2C4_IRQHandler
|
||||
INTI2C4AL_IRQHandler
|
||||
INTI2C4BF_IRQHandler
|
||||
INTI2C4NACK_IRQHandler
|
||||
INTADACP0_IRQHandler
|
||||
INTADACP1_IRQHandler
|
||||
INTADATRG_IRQHandler
|
||||
INTADASGL_IRQHandler
|
||||
INTADACNT_IRQHandler
|
||||
INTADAHP_IRQHandler
|
||||
INTFLDRDY_IRQHandler
|
||||
INTFLCRDY0_IRQHandler
|
||||
INTFLCRDY1_IRQHandler
|
||||
INTMDMAABERR_IRQHandler
|
||||
INTMDMAADERR_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
END
|
|
@ -0,0 +1,41 @@
|
|||
#! armcc -E -I. --cpu Cortex-M4
|
||||
;; TMPM4G9F15FG scatter file
|
||||
|
||||
;; Vector table starts at 0
|
||||
;; Initial SP == |Image$$ARM_LIB_STACK$$ZI$$Limit| (for two region model)
|
||||
;; or |Image$$ARM_LIB_STACKHEAP$$ZI$$Limit| (for one region model)
|
||||
;; Initial PC == &__main (with LSB set to indicate Thumb)
|
||||
;; These two values are provided by the library
|
||||
;; Other vectors must be provided by the user
|
||||
;; Code starts after the last possible vector
|
||||
;; Data starts at 0x20000000
|
||||
;; Heap is positioned by ARM_LIB_HEAB (this is the heap managed by the ARM libraries)
|
||||
;; Stack is positioned by ARM_LIB_STACK (library will use this to set SP - see above)
|
||||
|
||||
;; Compatible with ISSM model
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x00000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0x000180000
|
||||
#endif
|
||||
|
||||
; TMPM4G9: 1536 KB FLASH (0x180000) + 192 KB SRAM (0x30000)
|
||||
|
||||
LR_IROM1 MBED_APP_START MBED_APP_SIZE ; load region size_region
|
||||
{
|
||||
ER_IROM1 MBED_APP_START MBED_APP_SIZE
|
||||
{
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
|
||||
RW_IRAM1 0x20000320 (0x30000 - 0x320)
|
||||
{
|
||||
tmpm4g9_fc.o (+RO)
|
||||
.ANY (+RW, +ZI)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,532 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file startup_TMPM4G9.s
|
||||
* @brief CMSIS Cortex-M4F Core Device Startup File for the
|
||||
* TOSHIBA 'TMPM4G9' Device Series
|
||||
* @version
|
||||
* @date
|
||||
*------- <<< Use Configuration Wizard in Context Menu >>> ------------------
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv7-m
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
|
||||
/*
|
||||
// <h> Stack Configuration
|
||||
// <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
// </h>
|
||||
*/
|
||||
|
||||
#ifdef __STACK_SIZE
|
||||
.equ Stack_Size, __STACK_SIZE
|
||||
#else
|
||||
.equ Stack_Size, 0x400
|
||||
#endif
|
||||
.globl __StackTop
|
||||
.globl __StackLimit
|
||||
__StackLimit:
|
||||
.space Stack_Size
|
||||
.size __StackLimit, . - __StackLimit
|
||||
__StackTop:
|
||||
.size __StackTop, . - __StackTop
|
||||
|
||||
/*
|
||||
// <h> Heap Configuration
|
||||
// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
// </h>
|
||||
*/
|
||||
|
||||
.section .heap
|
||||
.align 3
|
||||
#ifdef __HEAP_SIZE
|
||||
.equ Heap_Size, __HEAP_SIZE
|
||||
#else
|
||||
.equ Heap_Size, 0
|
||||
#endif
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
__HeapBase:
|
||||
.if Heap_Size
|
||||
.space Heap_Size
|
||||
.endif
|
||||
.size __HeapBase, . - __HeapBase
|
||||
__HeapLimit:
|
||||
.size __HeapLimit, . - __HeapLimit
|
||||
|
||||
.section .vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler /* Reset Handler */
|
||||
.long NMI_Handler /* NMI Handler */
|
||||
.long HardFault_Handler /* Hard Fault Handler */
|
||||
.long MemManage_Handler /* MPU Fault Handler */
|
||||
.long BusFault_Handler /* Bus Fault Handler */
|
||||
.long UsageFault_Handler /* Usage Fault Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long SVC_Handler /* SVCall Handler */
|
||||
.long DebugMon_Handler /* Debug Monitor Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long PendSV_Handler /* PendSV Handler */
|
||||
.long SysTick_Handler /* SysTick Handler */
|
||||
|
||||
/* External interrupts */
|
||||
.long INT00_IRQHandler // 0: Interrupt pin 00a/00b
|
||||
.long INT01_IRQHandler // 1: Interrupt pin 01a/00b
|
||||
.long INT02_IRQHandler // 2: Interrupt pin 02a/00b
|
||||
.long INT03_IRQHandler // 3: Interrupt pin 03a/03b
|
||||
.long INT04_IRQHandler // 4: Interrupt pin 04a/04b
|
||||
.long INT05_IRQHandler // 5: Interrupt pin 05a/05b
|
||||
.long INT06_IRQHandler // 6: Interrupt pin 06a/06b
|
||||
.long INT07_IRQHandler // 7: Interrupt pin 07a/07b
|
||||
.long INT08_IRQHandler // 8: Interrupt pin 08a/08b
|
||||
.long INT09_IRQHandler // 9: Interrupt pin 09a/09b
|
||||
.long INT10_IRQHandler // 10: Interrupt pin 10a/10b
|
||||
.long INT11_IRQHandler // 11: Interrupt pin 11a/11b
|
||||
.long INT12_IRQHandler // 12: Interrupt pin 12a/12b
|
||||
.long INT13_IRQHandler // 13: Interrupt pin 13a/13b
|
||||
.long INT14_IRQHandler // 14: Interrupt pin 14a/14b
|
||||
.long INT15_IRQHandler // 15: Interrupt pin 15a/15b
|
||||
.long INTRTC_IRQHandler // 16: Real time clock(XHz) interrupt
|
||||
.long INTCEC0RX_IRQHandler // 17: CEC reception interrupt (channel 0)
|
||||
.long INTCEC0TX_IRQHandler // 18: CEC transmission interrupt (channel 0)
|
||||
.long INTISDA_IRQHandler // 19: Interval Sensing Detector Interrupt (Unit A)
|
||||
.long INTISDB_IRQHandler // 20: Interval Sensing Detector Interrupt (Unit B)
|
||||
.long INTISDC_IRQHandler // 21: Interval Sensing Detector Interrupt (Unit C)
|
||||
.long INTRMC0_IRQHandler // 22: Remote control reception interrupt 0
|
||||
.long INTRMC1_IRQHandler // 23: Remote control reception interrupt 1
|
||||
.long INTLTTMR_IRQHandler // 24: Long Term Timer Interrupt
|
||||
.long INTHDMAATC_IRQHandler // 25: HDMA Complete of transfer(Unit A)
|
||||
.long INTHDMAAERR_IRQHandler // 26: HDMA transfer error(Unit A)
|
||||
.long INTHDMABTC_IRQHandler // 27: HDMA end of transfer(Unit B)
|
||||
.long INTHDMABERR_IRQHandler // 28: HDMA transfer error(Unit B)
|
||||
.long INTMDMAATC_IRQHandler // 29: MDMA Complete of transfer(Unit A)
|
||||
.long INTT32A00_A_CT_IRQHandler // 30: T32A00 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A00_B_C01_CPC_IRQHandler// 31: T32A00 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A01_A_CT_IRQHandler // 32: T32A01 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A01_B_C01_CPC_IRQHandler// 33: T32A01 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A02_A_CT_IRQHandler // 34: T32A02 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A02_B_C01_CPC_IRQHandler// 35: T32A02 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A03_A_CT_IRQHandler // 36: T32A03 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A03_B_C01_CPC_IRQHandler// 37: T32A03 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A04_A_CT_IRQHandler // 38: T32A04 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A04_B_C01_CPC_IRQHandler// 39: T32A04 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A05_A_CT_IRQHandler // 40: T32A05 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A05_B_C01_CPC_IRQHandler// 41: T32A05 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A06_A_CT_IRQHandler // 42: T32A06 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A06_B_C01_CPC_IRQHandler// 43: T32A06 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A07_A_CT_IRQHandler // 44: T32A07 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A07_B_C01_CPC_IRQHandler// 45: T32A07 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A08_A_CT_IRQHandler // 46: T32A08 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A08_B_C01_CPC_IRQHandler// 47: T32A08 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A09_A_CT_IRQHandler // 48: T32A09 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A09_B_C01_CPC_IRQHandler// 49: T32A09 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A10_A_CT_IRQHandler // 50: T32A10 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A10_B_C01_CPC_IRQHandler// 51: T32A10 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A11_A_CT_IRQHandler // 52: T32A11 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A11_B_C01_CPC_IRQHandler// 53: T32A11 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A12_A_CT_IRQHandler // 54: T32A12 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A12_B_C01_CPC_IRQHandler// 55: T32A12 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTT32A13_A_CT_IRQHandler // 56: T32A13 TimerA All Interrupt/Timer Interrupt C
|
||||
.long INTT32A13_B_C01_CPC_IRQHandler// 57: T32A13 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
.long INTEMG0_IRQHandler // 58: PMD0 EMG interrupt
|
||||
.long INTOVV0_IRQHandler // 59: PMD0 OVV interrupt
|
||||
.long INTPWM0_IRQHandler // 60: PMD0 interrupt
|
||||
.long INTT0RX_IRQHandler // 61: TSPI/SIO reception (channel 0)
|
||||
.long INTT0TX_IRQHandler // 62: TSPI/SIO transmit (channel 0)
|
||||
.long INTT0ERR_IRQHandler // 63: TSPI/SIO error (channel 0)
|
||||
.long INTT1RX_IRQHandler // 64: TSPI/SIO reception (channel 1)
|
||||
.long INTT1TX_IRQHandler // 65: TSPI/SIO transmit (channel 1)
|
||||
.long INTT1ERR_IRQHandler // 66: TSPI/SIO error (channel 1)
|
||||
.long INTT2RX_IRQHandler // 67: TSPI/SIO reception (channel 2)
|
||||
.long INTT2TX_IRQHandler // 68: TSPI/SIO transmit (channel 2)
|
||||
.long INTT2ERR_IRQHandler // 69: TSPI/SIO error (channel 2)
|
||||
.long INTT3RX_IRQHandler // 70: TSPI/SIO reception (channel 3)
|
||||
.long INTT3TX_IRQHandler // 71: TSPI/SIO transmit (channel 3)
|
||||
.long INTT3ERR_IRQHandler // 72: TSPI/SIO error (channel 3)
|
||||
.long INTT4RX_IRQHandler // 73: TSPI/SIO reception (channel 4)
|
||||
.long INTT4TX_IRQHandler // 74: TSPI/SIO transmit (channel 4)
|
||||
.long INTT4ERR_IRQHandler // 75: TSPI/SIO error (channel 4)
|
||||
.long INTT5RX_IRQHandler // 76: TSPI/SIO reception (channel 5)
|
||||
.long INTT5TX_IRQHandler // 77: TSPI/SIO transmit (channel 5)
|
||||
.long INTT5ERR_IRQHandler // 78: TSPI/SIO error (channel 5)
|
||||
.long INTT6RX_IRQHandler // 79: TSPI/SIO reception (channel 6)
|
||||
.long INTT6TX_IRQHandler // 80: TSPI/SIO transmit (channel 6)
|
||||
.long INTT6ERR_IRQHandler // 81: TSPI/SIO error (channel 6)
|
||||
.long INTT7RX_IRQHandler // 82: TSPI/SIO reception (channel 7)
|
||||
.long INTT7TX_IRQHandler // 83: TSPI/SIO transmit (channel 7)
|
||||
.long INTT7ERR_IRQHandler // 84: TSPI/SIO error (channel 7)
|
||||
.long INTT8RX_IRQHandler // 85: TSPI/SIO reception (channel 8)
|
||||
.long INTT8TX_IRQHandler // 86: TSPI/SIO transmit (channel 8)
|
||||
.long INTT8ERR_IRQHandler // 87: TSPI/SIO error (channel 8)
|
||||
.long INTSMI0_IRQHandler // 88: Serial Memory Interface Interrupt
|
||||
.long INTUART0RX_IRQHandler // 89: UART reception (channel 0)
|
||||
.long INTUART0TX_IRQHandler // 90: UART transmit (channel 0)
|
||||
.long INTUART0ERR_IRQHandler // 91: UART error (channel 0)
|
||||
.long INTUART1RX_IRQHandler // 92: UART reception (channel 1)
|
||||
.long INTUART1TX_IRQHandler // 93: UART transmit (channel 1)
|
||||
.long INTUART1ERR_IRQHandler // 94: UART error (channel 1)
|
||||
.long INTUART2RX_IRQHandler // 95: UART reception (channel 2)
|
||||
.long INTUART2TX_IRQHandler // 96: UART transmit (channel 2)
|
||||
.long INTUART2ERR_IRQHandler // 97: UART error (channel 2)
|
||||
.long INTUART3RX_IRQHandler // 98: UART reception (channel 3)
|
||||
.long INTUART3TX_IRQHandler // 99: UART transmit (channel 3)
|
||||
.long INTUART3ERR_IRQHandler // 100: UART error (channel 3)
|
||||
.long INTUART4RX_IRQHandler // 101: UART reception (channel 4)
|
||||
.long INTUART4TX_IRQHandler // 102: UART transmit (channel 4)
|
||||
.long INTUART4ERR_IRQHandler // 103: UART error (channel 4)
|
||||
.long INTUART5RX_IRQHandler // 104: UART reception (channel 5)
|
||||
.long INTUART5TX_IRQHandler // 105: UART transmit (channel 5)
|
||||
.long INTUART5ERR_IRQHandler // 106: UART error (channel 5)
|
||||
.long INTFUART0_IRQHandler // 107: FUART Interrupt(channel 0)
|
||||
.long INTFUART1_IRQHandler // 108: FUART Interrupt(channel 1)
|
||||
.long INTI2C0_IRQHandler // 109: I2C0 transmission and reception interrupt
|
||||
.long INTI2C0AL_IRQHandler // 110: I2C0 arbitration lost interrupt
|
||||
.long INTI2C0BF_IRQHandler // 111: I2C0 bus free interrupt
|
||||
.long INTI2C0NACK_IRQHandler // 112: I2C0 no ack interrupt
|
||||
.long INTI2C1_IRQHandler // 113: I2C1 transmission and reception interrupt
|
||||
.long INTI2C1AL_IRQHandler // 114: I2C1 arbitration lost interrupt
|
||||
.long INTI2C1BF_IRQHandler // 115: I2C1 bus free interrupt
|
||||
.long INTI2C1NACK_IRQHandler // 116: I2C1 no ack interrupt
|
||||
.long INTI2C2_IRQHandler // 117: I2C2 transmission and reception interrupt
|
||||
.long INTI2C2AL_IRQHandler // 118: I2C2 arbitration lost interrupt
|
||||
.long INTI2C2BF_IRQHandler // 119: I2C2 bus free interrupt
|
||||
.long INTI2C2NACK_IRQHandler // 120: I2C2 no ack interrupt
|
||||
.long INTI2C3_IRQHandler // 121: I2C3 transmission and reception interrupt
|
||||
.long INTI2C3AL_IRQHandler // 122: I2C3 arbitration lost interrupt
|
||||
.long INTI2C3BF_IRQHandler // 123: I2C3 bus free interrupt
|
||||
.long INTI2C3NACK_IRQHandler // 124: I2C3 no ack interrupt
|
||||
.long INTI2C4_IRQHandler // 125: I2C4 transmission and reception interrupt
|
||||
.long INTI2C4AL_IRQHandler // 126: I2C4 arbitration lost interrupt
|
||||
.long INTI2C4BF_IRQHandler // 127: I2C4 bus free interrupt
|
||||
.long INTI2C4NACK_IRQHandler // 128: I2C4 no ack interrupt
|
||||
.long INTADACP0_IRQHandler // 129: ADC conversion monitoring function interrupt 0
|
||||
.long INTADACP1_IRQHandler // 130: ADC conversion monitoring function interrupt 1
|
||||
.long INTADATRG_IRQHandler // 131: ADC conversion triggered by General purpose is finished
|
||||
.long INTADASGL_IRQHandler // 132: ADC conversion triggered by Single program is finished
|
||||
.long INTADACNT_IRQHandler // 133: ADC conversion triggered by Continuity program is finished
|
||||
.long INTADAHP_IRQHandler // 134: ADC High Priority AD conversion interrupt
|
||||
.long INTFLDRDY_IRQHandler // 135: Data FLASH Ready interrupt
|
||||
.long INTFLCRDY0_IRQHandler // 136: Code FLASH Area0/1 Ready interrupt
|
||||
.long INTFLCRDY1_IRQHandler // 137: Code FLASH Area2 Ready interrupt
|
||||
.long 0 // 138: Reserved
|
||||
.long INTMDMAABERR_IRQHandler // 139: MDMA bus error(Unit A)
|
||||
.long INTMDMAADERR_IRQHandler // 140: MDMA descriptor error(Unit A)
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 2
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
/* Firstly it copies data from read only memory to RAM. There are two schemes
|
||||
* to copy. One can copy more than one sections. Another can only copy
|
||||
* one section. The former scheme needs more instructions and read-only
|
||||
* data to implement than the latter.
|
||||
* Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
|
||||
|
||||
#ifdef __STARTUP_COPY_MULTIPLE
|
||||
/* Multiple sections scheme.
|
||||
*
|
||||
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||
* there are array of triplets, each of which specify:
|
||||
* offset 0: LMA of start of a section to copy from
|
||||
* offset 4: VMA of start of a section to copy to
|
||||
* offset 8: size of the section to copy. Must be multiply of 4
|
||||
*
|
||||
* All addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r4, =__copy_table_start__
|
||||
ldr r5, =__copy_table_end__
|
||||
|
||||
.L_loop0:
|
||||
cmp r4, r5
|
||||
bge .L_loop0_done
|
||||
ldr r1, [r4]
|
||||
ldr r2, [r4, #4]
|
||||
ldr r3, [r4, #8]
|
||||
|
||||
.L_loop0_0:
|
||||
subs r3, #4
|
||||
ittt ge
|
||||
ldrge r0, [r1, r3]
|
||||
strge r0, [r2, r3]
|
||||
bge .L_loop0_0
|
||||
|
||||
adds r4, #12
|
||||
b .L_loop0
|
||||
|
||||
.L_loop0_done:
|
||||
#else
|
||||
/* Single section scheme.
|
||||
*
|
||||
* The ranges of copy from/to are specified by following symbols
|
||||
* __etext: LMA of start of the section to copy from. Usually end of text
|
||||
* __data_start__: VMA of start of the section to copy to
|
||||
* __data_end__: VMA of end of the section to copy to
|
||||
*
|
||||
* All addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
.L_loop1:
|
||||
cmp r2, r3
|
||||
ittt lt
|
||||
ldrlt r0, [r1], #4
|
||||
strlt r0, [r2], #4
|
||||
blt .L_loop1
|
||||
#endif /*__STARTUP_COPY_MULTIPLE */
|
||||
|
||||
/* This part of work usually is done in C library startup code. Otherwise,
|
||||
* define this macro to enable it in this startup.
|
||||
*
|
||||
* There are two schemes too. One can clear multiple BSS sections. Another
|
||||
* can only clear one section. The former is more size expensive than the
|
||||
* latter.
|
||||
*
|
||||
* Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
|
||||
* Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later.
|
||||
*/
|
||||
#ifdef __STARTUP_CLEAR_BSS_MULTIPLE
|
||||
/* Multiple sections scheme.
|
||||
*
|
||||
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||
* there are array of tuples specifying:
|
||||
* offset 0: Start of a BSS section
|
||||
* offset 4: Size of this BSS section. Must be multiply of 4
|
||||
*/
|
||||
ldr r3, =__zero_table_start__
|
||||
ldr r4, =__zero_table_end__
|
||||
|
||||
.L_loop2:
|
||||
cmp r3, r4
|
||||
bge .L_loop2_done
|
||||
ldr r1, [r3]
|
||||
ldr r2, [r3, #4]
|
||||
movs r0, 0
|
||||
|
||||
.L_loop2_0:
|
||||
subs r2, #4
|
||||
itt ge
|
||||
strge r0, [r1, r2]
|
||||
bge .L_loop2_0
|
||||
|
||||
adds r3, #8
|
||||
b .L_loop2
|
||||
.L_loop2_done:
|
||||
#elif defined (__STARTUP_CLEAR_BSS)
|
||||
/* Single BSS section scheme.
|
||||
*
|
||||
* The BSS section is specified by following symbols
|
||||
* __bss_start__: start of the BSS section.
|
||||
* __bss_end__: end of the BSS section.
|
||||
*
|
||||
* Both addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r1, =__bss_start__
|
||||
ldr r2, =__bss_end__
|
||||
|
||||
movs r0, 0
|
||||
.L_loop3:
|
||||
cmp r1, r2
|
||||
itt lt
|
||||
strlt r0, [r1], #4
|
||||
blt .L_loop3
|
||||
#endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
bl SystemInit
|
||||
#endif
|
||||
|
||||
#ifndef __START
|
||||
#define __START _start
|
||||
#endif
|
||||
bl __START
|
||||
|
||||
.pool
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
.align 1
|
||||
.thumb_func
|
||||
.weak Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
b .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
/* Macro to define default handlers. Default handler
|
||||
* will be weak symbol and just dead loops. They can be
|
||||
* overwritten by other handlers */
|
||||
.macro def_irq_handler handler_name
|
||||
.weak \handler_name
|
||||
.set \handler_name, Default_Handler
|
||||
.endm
|
||||
|
||||
def_irq_handler NMI_Handler
|
||||
def_irq_handler HardFault_Handler
|
||||
def_irq_handler MemManage_Handler
|
||||
def_irq_handler BusFault_Handler
|
||||
def_irq_handler UsageFault_Handler
|
||||
def_irq_handler SVC_Handler
|
||||
def_irq_handler DebugMon_Handler
|
||||
def_irq_handler PendSV_Handler
|
||||
def_irq_handler SysTick_Handler
|
||||
|
||||
def_irq_handler INT00_IRQHandler
|
||||
def_irq_handler INT01_IRQHandler
|
||||
def_irq_handler INT02_IRQHandler
|
||||
def_irq_handler INT03_IRQHandler
|
||||
def_irq_handler INT04_IRQHandler
|
||||
def_irq_handler INT05_IRQHandler
|
||||
def_irq_handler INT06_IRQHandler
|
||||
def_irq_handler INT07_IRQHandler
|
||||
def_irq_handler INT08_IRQHandler
|
||||
def_irq_handler INT09_IRQHandler
|
||||
def_irq_handler INT10_IRQHandler
|
||||
def_irq_handler INT11_IRQHandler
|
||||
def_irq_handler INT12_IRQHandler
|
||||
def_irq_handler INT13_IRQHandler
|
||||
def_irq_handler INT14_IRQHandler
|
||||
def_irq_handler INT15_IRQHandler
|
||||
def_irq_handler INTRTC_IRQHandler
|
||||
def_irq_handler INTCEC0RX_IRQHandler
|
||||
def_irq_handler INTCEC0TX_IRQHandler
|
||||
def_irq_handler INTISDA_IRQHandler
|
||||
def_irq_handler INTISDB_IRQHandler
|
||||
def_irq_handler INTISDC_IRQHandler
|
||||
def_irq_handler INTRMC0_IRQHandler
|
||||
def_irq_handler INTRMC1_IRQHandler
|
||||
def_irq_handler INTLTTMR_IRQHandler
|
||||
def_irq_handler INTHDMAATC_IRQHandler
|
||||
def_irq_handler INTHDMAAERR_IRQHandler
|
||||
def_irq_handler INTHDMABTC_IRQHandler
|
||||
def_irq_handler INTHDMABERR_IRQHandler
|
||||
def_irq_handler INTMDMAATC_IRQHandler
|
||||
def_irq_handler INTT32A00_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A00_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A01_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A01_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A02_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A02_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A03_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A03_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A04_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A04_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A05_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A05_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A06_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A06_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A07_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A07_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A08_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A08_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A09_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A09_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A10_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A10_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A11_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A11_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A12_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A12_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTT32A13_A_CT_IRQHandler
|
||||
def_irq_handler INTT32A13_B_C01_CPC_IRQHandler
|
||||
def_irq_handler INTEMG0_IRQHandler
|
||||
def_irq_handler INTOVV0_IRQHandler
|
||||
def_irq_handler INTPWM0_IRQHandler
|
||||
def_irq_handler INTT0RX_IRQHandler
|
||||
def_irq_handler INTT0TX_IRQHandler
|
||||
def_irq_handler INTT0ERR_IRQHandler
|
||||
def_irq_handler INTT1RX_IRQHandler
|
||||
def_irq_handler INTT1TX_IRQHandler
|
||||
def_irq_handler INTT1ERR_IRQHandler
|
||||
def_irq_handler INTT2RX_IRQHandler
|
||||
def_irq_handler INTT2TX_IRQHandler
|
||||
def_irq_handler INTT2ERR_IRQHandler
|
||||
def_irq_handler INTT3RX_IRQHandler
|
||||
def_irq_handler INTT3TX_IRQHandler
|
||||
def_irq_handler INTT3ERR_IRQHandler
|
||||
def_irq_handler INTT4RX_IRQHandler
|
||||
def_irq_handler INTT4TX_IRQHandler
|
||||
def_irq_handler INTT4ERR_IRQHandler
|
||||
def_irq_handler INTT5RX_IRQHandler
|
||||
def_irq_handler INTT5TX_IRQHandler
|
||||
def_irq_handler INTT5ERR_IRQHandler
|
||||
def_irq_handler INTT6RX_IRQHandler
|
||||
def_irq_handler INTT6TX_IRQHandler
|
||||
def_irq_handler INTT6ERR_IRQHandler
|
||||
def_irq_handler INTT7RX_IRQHandler
|
||||
def_irq_handler INTT7TX_IRQHandler
|
||||
def_irq_handler INTT7ERR_IRQHandler
|
||||
def_irq_handler INTT8RX_IRQHandler
|
||||
def_irq_handler INTT8TX_IRQHandler
|
||||
def_irq_handler INTT8ERR_IRQHandler
|
||||
def_irq_handler INTSMI0_IRQHandler
|
||||
def_irq_handler INTUART0RX_IRQHandler
|
||||
def_irq_handler INTUART0TX_IRQHandler
|
||||
def_irq_handler INTUART0ERR_IRQHandler
|
||||
def_irq_handler INTUART1RX_IRQHandler
|
||||
def_irq_handler INTUART1TX_IRQHandler
|
||||
def_irq_handler INTUART1ERR_IRQHandler
|
||||
def_irq_handler INTUART2RX_IRQHandler
|
||||
def_irq_handler INTUART2TX_IRQHandler
|
||||
def_irq_handler INTUART2ERR_IRQHandler
|
||||
def_irq_handler INTUART3RX_IRQHandler
|
||||
def_irq_handler INTUART3TX_IRQHandler
|
||||
def_irq_handler INTUART3ERR_IRQHandler
|
||||
def_irq_handler INTUART4RX_IRQHandler
|
||||
def_irq_handler INTUART4TX_IRQHandler
|
||||
def_irq_handler INTUART4ERR_IRQHandler
|
||||
def_irq_handler INTUART5RX_IRQHandler
|
||||
def_irq_handler INTUART5TX_IRQHandler
|
||||
def_irq_handler INTUART5ERR_IRQHandler
|
||||
def_irq_handler INTFUART0_IRQHandler
|
||||
def_irq_handler INTFUART1_IRQHandler
|
||||
def_irq_handler INTI2C0_IRQHandler
|
||||
def_irq_handler INTI2C0AL_IRQHandler
|
||||
def_irq_handler INTI2C0BF_IRQHandler
|
||||
def_irq_handler INTI2C0NACK_IRQHandler
|
||||
def_irq_handler INTI2C1_IRQHandler
|
||||
def_irq_handler INTI2C1AL_IRQHandler
|
||||
def_irq_handler INTI2C1BF_IRQHandler
|
||||
def_irq_handler INTI2C1NACK_IRQHandler
|
||||
def_irq_handler INTI2C2_IRQHandler
|
||||
def_irq_handler INTI2C2AL_IRQHandler
|
||||
def_irq_handler INTI2C2BF_IRQHandler
|
||||
def_irq_handler INTI2C2NACK_IRQHandler
|
||||
def_irq_handler INTI2C3_IRQHandler
|
||||
def_irq_handler INTI2C3AL_IRQHandler
|
||||
def_irq_handler INTI2C3BF_IRQHandler
|
||||
def_irq_handler INTI2C3NACK_IRQHandler
|
||||
def_irq_handler INTI2C4_IRQHandler
|
||||
def_irq_handler INTI2C4AL_IRQHandler
|
||||
def_irq_handler INTI2C4BF_IRQHandler
|
||||
def_irq_handler INTI2C4NACK_IRQHandler
|
||||
def_irq_handler INTADACP0_IRQHandler
|
||||
def_irq_handler INTADACP1_IRQHandler
|
||||
def_irq_handler INTADATRG_IRQHandler
|
||||
def_irq_handler INTADASGL_IRQHandler
|
||||
def_irq_handler INTADACNT_IRQHandler
|
||||
def_irq_handler INTADAHP_IRQHandler
|
||||
def_irq_handler INTFLDRDY_IRQHandler
|
||||
def_irq_handler INTFLCRDY0_IRQHandler
|
||||
def_irq_handler INTFLCRDY1_IRQHandler
|
||||
//def_irq_handler 0
|
||||
def_irq_handler INTMDMAABERR_IRQHandler
|
||||
def_irq_handler INTMDMAADERR_IRQHandler
|
||||
|
||||
.end
|
|
@ -0,0 +1,207 @@
|
|||
/* Linker script for Toshiba TMPM4G9 */
|
||||
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
#if !defined(MBED_APP_START)
|
||||
#define MBED_APP_START 0x00000000
|
||||
#endif
|
||||
|
||||
#if !defined(MBED_APP_SIZE)
|
||||
#define MBED_APP_SIZE 0x180000
|
||||
#endif
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
|
||||
RAM (rwx) : ORIGIN = 0x20000320, LENGTH = (192K - 0x320)
|
||||
}
|
||||
|
||||
/* Library configurations */
|
||||
GROUP(libgcc.a libc.a libm.a libnosys.a)
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __copy_table_start__
|
||||
* __copy_table_end__
|
||||
* __zero_table_start__
|
||||
* __zero_table_end__
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapBase
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
* __Vectors_End
|
||||
* __Vectors_Size
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.vectors))
|
||||
__Vectors_End = .;
|
||||
__Vectors_Size = __Vectors_End - __Vectors;
|
||||
__end__ = .;
|
||||
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
/* To copy multiple ROM to RAM sections,
|
||||
* uncomment .copy.table section and,
|
||||
* define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
|
||||
/*
|
||||
.copy.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__copy_table_start__ = .;
|
||||
LONG (__etext)
|
||||
LONG (__data_start__)
|
||||
LONG (__data_end__ - __data_start__)
|
||||
LONG (__etext2)
|
||||
LONG (__data2_start__)
|
||||
LONG (__data2_end__ - __data2_start__)
|
||||
__copy_table_end__ = .;
|
||||
} > FLASH
|
||||
*/
|
||||
|
||||
/* To clear multiple BSS sections,
|
||||
* uncomment .zero.table section and,
|
||||
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
|
||||
/*
|
||||
.zero.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__zero_table_start__ = .;
|
||||
LONG (__bss_start__)
|
||||
LONG (__bss_end__ - __bss_start__)
|
||||
LONG (__bss2_start__)
|
||||
LONG (__bss2_end__ - __bss2_start__)
|
||||
__zero_table_end__ = .;
|
||||
} > FLASH
|
||||
*/
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
*(.ram_func*)
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
__HeapBase = .;
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
KEEP(*(.heap*))
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
KEEP(*(.stack*))
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
|
@ -0,0 +1,952 @@
|
|||
;/**
|
||||
; *******************************************************************************
|
||||
; * @file startup_TMPM4G9.s
|
||||
; * @brief CMSIS Cortex-M4 Core Device Startup File for the
|
||||
; * TOSHIBA 'TMPM4G9' Device Series
|
||||
; * @version V1.0.9.0
|
||||
; * $Date:: 2018-04-02 #$
|
||||
; *
|
||||
; * DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LICENSE AGREEMENT.
|
||||
; *
|
||||
; * (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
; *******************************************************************************
|
||||
; */
|
||||
;
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; Cortex-M version
|
||||
;
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
|
||||
DATA
|
||||
__vector_table DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD INT00_IRQHandler ; 0: Interrupt pin 00a/00b
|
||||
DCD INT01_IRQHandler ; 1: Interrupt pin 01a/00b
|
||||
DCD INT02_IRQHandler ; 2: Interrupt pin 02a/00b
|
||||
DCD INT03_IRQHandler ; 3: Interrupt pin 03a/03b
|
||||
DCD INT04_IRQHandler ; 4: Interrupt pin 04a/04b
|
||||
DCD INT05_IRQHandler ; 5: Interrupt pin 05a/05b
|
||||
DCD INT06_IRQHandler ; 6: Interrupt pin 06a/06b
|
||||
DCD INT07_IRQHandler ; 7: Interrupt pin 07a/07b
|
||||
DCD INT08_IRQHandler ; 8: Interrupt pin 08a/08b
|
||||
DCD INT09_IRQHandler ; 9: Interrupt pin 09a/09b
|
||||
DCD INT10_IRQHandler ; 10: Interrupt pin 10a/10b
|
||||
DCD INT11_IRQHandler ; 11: Interrupt pin 11a/11b
|
||||
DCD INT12_IRQHandler ; 12: Interrupt pin 12a/12b
|
||||
DCD INT13_IRQHandler ; 13: Interrupt pin 13a/13b
|
||||
DCD INT14_IRQHandler ; 14: Interrupt pin 14a/14b
|
||||
DCD INT15_IRQHandler ; 15: Interrupt pin 15a/15b
|
||||
DCD INTRTC_IRQHandler ; 16: Real time clock(XHz) interrupt
|
||||
DCD INTCEC0RX_IRQHandler ; 17: CEC reception interrupt (channel 0)
|
||||
DCD INTCEC0TX_IRQHandler ; 18: CEC transmission interrupt (channel 0)
|
||||
DCD INTISDA_IRQHandler ; 19: Interval Sensing Detector Interrupt (Unit A)
|
||||
DCD INTISDB_IRQHandler ; 20: Interval Sensing Detector Interrupt (Unit B)
|
||||
DCD INTISDC_IRQHandler ; 21: Interval Sensing Detector Interrupt (Unit C)
|
||||
DCD INTRMC0_IRQHandler ; 22: Remote control reception interrupt 0
|
||||
DCD INTRMC1_IRQHandler ; 23: Remote control reception interrupt 1
|
||||
DCD INTLTTMR0_IRQHandler ; 24: Long Term Timer Interrupt(channel 0)
|
||||
DCD INTHDMAATC_IRQHandler ; 25: HDMA Complete of transfer(Unit A)
|
||||
DCD INTHDMAAERR_IRQHandler ; 26: HDMA transfer error(Unit A)
|
||||
DCD INTHDMABTC_IRQHandler ; 27: HDMA end of transfer(Unit B)
|
||||
DCD INTHDMABERR_IRQHandler ; 28: HDMA transfer error(Unit B)
|
||||
DCD INTMDMAATC_IRQHandler ; 29: MDMA Complete of transfer(Unit A)
|
||||
DCD INTT32A00_A_CT_IRQHandler ; 30: T32A00 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A00_B_C01_CPC_IRQHandler ; 31: T32A00 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A01_A_CT_IRQHandler ; 32: T32A01 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A01_B_C01_CPC_IRQHandler ; 33: T32A01 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A02_A_CT_IRQHandler ; 34: T32A02 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A02_B_C01_CPC_IRQHandler ; 35: T32A02 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A03_A_CT_IRQHandler ; 36: T32A03 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A03_B_C01_CPC_IRQHandler ; 37: T32A03 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A04_A_CT_IRQHandler ; 38: T32A04 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A04_B_C01_CPC_IRQHandler ; 39: T32A04 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A05_A_CT_IRQHandler ; 40: T32A05 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A05_B_C01_CPC_IRQHandler ; 41: T32A05 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A06_A_CT_IRQHandler ; 42: T32A06 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A06_B_C01_CPC_IRQHandler ; 43: T32A06 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A07_A_CT_IRQHandler ; 44: T32A07 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A07_B_C01_CPC_IRQHandler ; 45: T32A07 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A08_A_CT_IRQHandler ; 46: T32A08 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A08_B_C01_CPC_IRQHandler ; 47: T32A08 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A09_A_CT_IRQHandler ; 48: T32A09 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A09_B_C01_CPC_IRQHandler ; 49: T32A09 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A10_A_CT_IRQHandler ; 50: T32A10 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A10_B_C01_CPC_IRQHandler ; 51: T32A10 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A11_A_CT_IRQHandler ; 52: T32A11 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A11_B_C01_CPC_IRQHandler ; 53: T32A11 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A12_A_CT_IRQHandler ; 54: T32A12 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A12_B_C01_CPC_IRQHandler ; 55: T32A12 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTT32A13_A_CT_IRQHandler ; 56: T32A13 TimerA All Interrupt/Timer Interrupt C
|
||||
DCD INTT32A13_B_C01_CPC_IRQHandler ; 57: T32A13 Timer Interrupt B/Capture C0,C1 Interrupt/ Timer Interrupt C
|
||||
DCD INTEMG0_IRQHandler ; 58: PMD0 EMG interrupt
|
||||
DCD INTOVV0_IRQHandler ; 59: PMD0 OVV interrupt
|
||||
DCD INTPWM0_IRQHandler ; 60: PMD0 interrupt
|
||||
DCD INTT0RX_IRQHandler ; 61: TSPI/SIO reception (channel 0)
|
||||
DCD INTT0TX_IRQHandler ; 62: TSPI/SIO transmit (channel 0)
|
||||
DCD INTT0ERR_IRQHandler ; 63: TSPI/SIO error (channel 0)
|
||||
DCD INTT1RX_IRQHandler ; 64: TSPI/SIO reception (channel 1)
|
||||
DCD INTT1TX_IRQHandler ; 65: TSPI/SIO transmit (channel 1)
|
||||
DCD INTT1ERR_IRQHandler ; 66: TSPI/SIO error (channel 1)
|
||||
DCD INTT2RX_IRQHandler ; 67: TSPI/SIO reception (channel 2)
|
||||
DCD INTT2TX_IRQHandler ; 68: TSPI/SIO transmit (channel 2)
|
||||
DCD INTT2ERR_IRQHandler ; 69: TSPI/SIO error (channel 2)
|
||||
DCD INTT3RX_IRQHandler ; 70: TSPI/SIO reception (channel 3)
|
||||
DCD INTT3TX_IRQHandler ; 71: TSPI/SIO transmit (channel 3)
|
||||
DCD INTT3ERR_IRQHandler ; 72: TSPI/SIO error (channel 3)
|
||||
DCD INTT4RX_IRQHandler ; 73: TSPI/SIO reception (channel 4)
|
||||
DCD INTT4TX_IRQHandler ; 74: TSPI/SIO transmit (channel 4)
|
||||
DCD INTT4ERR_IRQHandler ; 75: TSPI/SIO error (channel 4)
|
||||
DCD INTT5RX_IRQHandler ; 76: TSPI/SIO reception (channel 5)
|
||||
DCD INTT5TX_IRQHandler ; 77: TSPI/SIO transmit (channel 5)
|
||||
DCD INTT5ERR_IRQHandler ; 78: TSPI/SIO error (channel 5)
|
||||
DCD INTT6RX_IRQHandler ; 79: TSPI/SIO reception (channel 6)
|
||||
DCD INTT6TX_IRQHandler ; 80: TSPI/SIO transmit (channel 6)
|
||||
DCD INTT6ERR_IRQHandler ; 81: TSPI/SIO error (channel 6)
|
||||
DCD INTT7RX_IRQHandler ; 82: TSPI/SIO reception (channel 7)
|
||||
DCD INTT7TX_IRQHandler ; 83: TSPI/SIO transmit (channel 7)
|
||||
DCD INTT7ERR_IRQHandler ; 84: TSPI/SIO error (channel 7)
|
||||
DCD INTT8RX_IRQHandler ; 85: TSPI/SIO reception (channel 8)
|
||||
DCD INTT8TX_IRQHandler ; 86: TSPI/SIO transmit (channel 8)
|
||||
DCD INTT8ERR_IRQHandler ; 87: TSPI/SIO error (channel 8)
|
||||
DCD INTSMI0_IRQHandler ; 88: Serial Memory Interface Interrupt
|
||||
DCD INTUART0RX_IRQHandler ; 89: UART reception (channel 0)
|
||||
DCD INTUART0TX_IRQHandler ; 90: UART transmit (channel 0)
|
||||
DCD INTUART0ERR_IRQHandler ; 91: UART error (channel 0)
|
||||
DCD INTUART1RX_IRQHandler ; 92: UART reception (channel 1)
|
||||
DCD INTUART1TX_IRQHandler ; 93: UART transmit (channel 1)
|
||||
DCD INTUART1ERR_IRQHandler ; 94: UART error (channel 1)
|
||||
DCD INTUART2RX_IRQHandler ; 95: UART reception (channel 2)
|
||||
DCD INTUART2TX_IRQHandler ; 96: UART transmit (channel 2)
|
||||
DCD INTUART2ERR_IRQHandler ; 97: UART error (channel 2)
|
||||
DCD INTUART3RX_IRQHandler ; 98: UART reception (channel 3)
|
||||
DCD INTUART3TX_IRQHandler ; 99: UART transmit (channel 3)
|
||||
DCD INTUART3ERR_IRQHandler ; 100: UART error (channel 3)
|
||||
DCD INTUART4RX_IRQHandler ; 101: UART reception (channel 4)
|
||||
DCD INTUART4TX_IRQHandler ; 102: UART transmit (channel 4)
|
||||
DCD INTUART4ERR_IRQHandler ; 103: UART error (channel 4)
|
||||
DCD INTUART5RX_IRQHandler ; 104: UART reception (channel 5)
|
||||
DCD INTUART5TX_IRQHandler ; 105: UART transmit (channel 5)
|
||||
DCD INTUART5ERR_IRQHandler ; 106: UART error (channel 5)
|
||||
DCD INTFUART0_IRQHandler ; 107: FUART Interrupt(channel 0)
|
||||
DCD INTFUART1_IRQHandler ; 108: FUART Interrupt(channel 1)
|
||||
DCD INTI2C0_IRQHandler ; 109: I2C0 transmission and reception interrupt
|
||||
DCD INTI2C0AL_IRQHandler ; 110: I2C0 arbitration lost interrupt
|
||||
DCD INTI2C0BF_IRQHandler ; 111: I2C0 bus free interrupt
|
||||
DCD INTI2C0NACK_IRQHandler ; 112: I2C0 no ack interrupt
|
||||
DCD INTI2C1_IRQHandler ; 113: I2C1 transmission and reception interrupt
|
||||
DCD INTI2C1AL_IRQHandler ; 114: I2C1 arbitration lost interrupt
|
||||
DCD INTI2C1BF_IRQHandler ; 115: I2C1 bus free interrupt
|
||||
DCD INTI2C1NACK_IRQHandler ; 116: I2C1 no ack interrupt
|
||||
DCD INTI2C2_IRQHandler ; 117: I2C2 transmission and reception interrupt
|
||||
DCD INTI2C2AL_IRQHandler ; 118: I2C2 arbitration lost interrupt
|
||||
DCD INTI2C2BF_IRQHandler ; 119: I2C2 bus free interrupt
|
||||
DCD INTI2C2NACK_IRQHandler ; 120: I2C2 no ack interrupt
|
||||
DCD INTI2C3_IRQHandler ; 121: I2C3 transmission and reception interrupt
|
||||
DCD INTI2C3AL_IRQHandler ; 122: I2C3 arbitration lost interrupt
|
||||
DCD INTI2C3BF_IRQHandler ; 123: I2C3 bus free interrupt
|
||||
DCD INTI2C3NACK_IRQHandler ; 124: I2C3 no ack interrupt
|
||||
DCD INTI2C4_IRQHandler ; 125: I2C4 transmission and reception interrupt
|
||||
DCD INTI2C4AL_IRQHandler ; 126: I2C4 arbitration lost interrupt
|
||||
DCD INTI2C4BF_IRQHandler ; 127: I2C4 bus free interrupt
|
||||
DCD INTI2C4NACK_IRQHandler ; 128: I2C4 no ack interrupt
|
||||
DCD INTADACP0_IRQHandler ; 129: ADC conversion monitoring function interrupt 0
|
||||
DCD INTADACP1_IRQHandler ; 130: ADC conversion monitoring function interrupt 1
|
||||
DCD INTADATRG_IRQHandler ; 131: ADC conversion triggered by General purpose is finished
|
||||
DCD INTADASGL_IRQHandler ; 132: ADC conversion triggered by Single program is finished
|
||||
DCD INTADACNT_IRQHandler ; 133: ADC conversion triggered by Continuity program is finished
|
||||
DCD INTADAHP_IRQHandler ; 134: ADC High Priority AD conversion interrupt
|
||||
DCD INTFLDRDY_IRQHandler ; 135: Data FLASH Ready interrupt
|
||||
DCD INTFLCRDY0_IRQHandler ; 136: Code FLASH Area0/1 Ready interrupt
|
||||
DCD INTFLCRDY1_IRQHandler ; 137: Code FLASH Area2 Ready interrupt
|
||||
DCD 0 ; 138: Reserved
|
||||
DCD INTMDMAABERR_IRQHandler ; 139: MDMA bus error(Unit A)
|
||||
DCD INTMDMAADERR_IRQHandler ; 140: MDMA descriptor error(Unit A)
|
||||
THUMB
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reset_Handler
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
NMI_Handler
|
||||
B NMI_Handler
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B HardFault_Handler
|
||||
|
||||
PUBWEAK MemManage_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
MemManage_Handler
|
||||
B MemManage_Handler
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
BusFault_Handler
|
||||
B BusFault_Handler
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
UsageFault_Handler
|
||||
B UsageFault_Handler
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SVC_Handler
|
||||
B SVC_Handler
|
||||
|
||||
PUBWEAK DebugMon_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DebugMon_Handler
|
||||
B DebugMon_Handler
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B PendSV_Handler
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B SysTick_Handler
|
||||
|
||||
PUBWEAK INT00_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT00_IRQHandler
|
||||
B INT00_IRQHandler
|
||||
|
||||
PUBWEAK INT01_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT01_IRQHandler
|
||||
B INT01_IRQHandler
|
||||
|
||||
PUBWEAK INT02_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT02_IRQHandler
|
||||
B INT02_IRQHandler
|
||||
|
||||
PUBWEAK INT03_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT03_IRQHandler
|
||||
B INT03_IRQHandler
|
||||
|
||||
PUBWEAK INT04_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT04_IRQHandler
|
||||
B INT04_IRQHandler
|
||||
|
||||
PUBWEAK INT05_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT05_IRQHandler
|
||||
B INT05_IRQHandler
|
||||
|
||||
PUBWEAK INT06_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT06_IRQHandler
|
||||
B INT06_IRQHandler
|
||||
|
||||
PUBWEAK INT07_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT07_IRQHandler
|
||||
B INT07_IRQHandler
|
||||
|
||||
PUBWEAK INT08_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT08_IRQHandler
|
||||
B INT08_IRQHandler
|
||||
|
||||
PUBWEAK INT09_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT09_IRQHandler
|
||||
B INT09_IRQHandler
|
||||
|
||||
PUBWEAK INT10_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT10_IRQHandler
|
||||
B INT10_IRQHandler
|
||||
|
||||
PUBWEAK INT11_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT11_IRQHandler
|
||||
B INT11_IRQHandler
|
||||
|
||||
PUBWEAK INT12_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT12_IRQHandler
|
||||
B INT12_IRQHandler
|
||||
|
||||
PUBWEAK INT13_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT13_IRQHandler
|
||||
B INT13_IRQHandler
|
||||
|
||||
PUBWEAK INT14_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT14_IRQHandler
|
||||
B INT14_IRQHandler
|
||||
|
||||
PUBWEAK INT15_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INT15_IRQHandler
|
||||
B INT15_IRQHandler
|
||||
|
||||
PUBWEAK INTRTC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTRTC_IRQHandler
|
||||
B INTRTC_IRQHandler
|
||||
|
||||
PUBWEAK INTCEC0RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTCEC0RX_IRQHandler
|
||||
B INTCEC0RX_IRQHandler
|
||||
|
||||
PUBWEAK INTCEC0TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTCEC0TX_IRQHandler
|
||||
B INTCEC0TX_IRQHandler
|
||||
|
||||
PUBWEAK INTISDA_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTISDA_IRQHandler
|
||||
B INTISDA_IRQHandler
|
||||
|
||||
PUBWEAK INTISDB_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTISDB_IRQHandler
|
||||
B INTISDB_IRQHandler
|
||||
|
||||
PUBWEAK INTISDC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTISDC_IRQHandler
|
||||
B INTISDC_IRQHandler
|
||||
|
||||
PUBWEAK INTRMC0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTRMC0_IRQHandler
|
||||
B INTRMC0_IRQHandler
|
||||
|
||||
PUBWEAK INTRMC1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTRMC1_IRQHandler
|
||||
B INTRMC1_IRQHandler
|
||||
|
||||
PUBWEAK INTLTTMR0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTLTTMR0_IRQHandler
|
||||
B INTLTTMR0_IRQHandler
|
||||
|
||||
PUBWEAK INTHDMAATC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTHDMAATC_IRQHandler
|
||||
B INTHDMAATC_IRQHandler
|
||||
|
||||
PUBWEAK INTHDMAAERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTHDMAAERR_IRQHandler
|
||||
B INTHDMAAERR_IRQHandler
|
||||
|
||||
PUBWEAK INTHDMABTC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTHDMABTC_IRQHandler
|
||||
B INTHDMABTC_IRQHandler
|
||||
|
||||
PUBWEAK INTHDMABERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTHDMABERR_IRQHandler
|
||||
B INTHDMABERR_IRQHandler
|
||||
|
||||
PUBWEAK INTMDMAATC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTMDMAATC_IRQHandler
|
||||
B INTMDMAATC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A00_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A00_A_CT_IRQHandler
|
||||
B INTT32A00_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A00_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A00_B_C01_CPC_IRQHandler
|
||||
B INTT32A00_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A01_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A01_A_CT_IRQHandler
|
||||
B INTT32A01_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A01_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A01_B_C01_CPC_IRQHandler
|
||||
B INTT32A01_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A02_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A02_A_CT_IRQHandler
|
||||
B INTT32A02_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A02_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A02_B_C01_CPC_IRQHandler
|
||||
B INTT32A02_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A03_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A03_A_CT_IRQHandler
|
||||
B INTT32A03_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A03_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A03_B_C01_CPC_IRQHandler
|
||||
B INTT32A03_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A04_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A04_A_CT_IRQHandler
|
||||
B INTT32A04_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A04_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A04_B_C01_CPC_IRQHandler
|
||||
B INTT32A04_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A05_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A05_A_CT_IRQHandler
|
||||
B INTT32A05_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A05_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A05_B_C01_CPC_IRQHandler
|
||||
B INTT32A05_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A06_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A06_A_CT_IRQHandler
|
||||
B INTT32A06_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A06_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A06_B_C01_CPC_IRQHandler
|
||||
B INTT32A06_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A07_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A07_A_CT_IRQHandler
|
||||
B INTT32A07_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A07_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A07_B_C01_CPC_IRQHandler
|
||||
B INTT32A07_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A08_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A08_A_CT_IRQHandler
|
||||
B INTT32A08_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A08_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A08_B_C01_CPC_IRQHandler
|
||||
B INTT32A08_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A09_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A09_A_CT_IRQHandler
|
||||
B INTT32A09_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A09_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A09_B_C01_CPC_IRQHandler
|
||||
B INTT32A09_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A10_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A10_A_CT_IRQHandler
|
||||
B INTT32A10_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A10_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A10_B_C01_CPC_IRQHandler
|
||||
B INTT32A10_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A11_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A11_A_CT_IRQHandler
|
||||
B INTT32A11_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A11_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A11_B_C01_CPC_IRQHandler
|
||||
B INTT32A11_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A12_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A12_A_CT_IRQHandler
|
||||
B INTT32A12_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A12_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A12_B_C01_CPC_IRQHandler
|
||||
B INTT32A12_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A13_A_CT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A13_A_CT_IRQHandler
|
||||
B INTT32A13_A_CT_IRQHandler
|
||||
|
||||
PUBWEAK INTT32A13_B_C01_CPC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT32A13_B_C01_CPC_IRQHandler
|
||||
B INTT32A13_B_C01_CPC_IRQHandler
|
||||
|
||||
PUBWEAK INTEMG0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTEMG0_IRQHandler
|
||||
B INTEMG0_IRQHandler
|
||||
|
||||
PUBWEAK INTOVV0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTOVV0_IRQHandler
|
||||
B INTOVV0_IRQHandler
|
||||
|
||||
PUBWEAK INTPWM0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTPWM0_IRQHandler
|
||||
B INTPWM0_IRQHandler
|
||||
|
||||
PUBWEAK INTT0RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT0RX_IRQHandler
|
||||
B INTT0RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT0TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT0TX_IRQHandler
|
||||
B INTT0TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT0ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT0ERR_IRQHandler
|
||||
B INTT0ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT1RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT1RX_IRQHandler
|
||||
B INTT1RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT1TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT1TX_IRQHandler
|
||||
B INTT1TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT1ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT1ERR_IRQHandler
|
||||
B INTT1ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT2RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT2RX_IRQHandler
|
||||
B INTT2RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT2TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT2TX_IRQHandler
|
||||
B INTT2TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT2ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT2ERR_IRQHandler
|
||||
B INTT2ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT3RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT3RX_IRQHandler
|
||||
B INTT3RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT3TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT3TX_IRQHandler
|
||||
B INTT3TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT3ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT3ERR_IRQHandler
|
||||
B INTT3ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT4RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT4RX_IRQHandler
|
||||
B INTT4RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT4TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT4TX_IRQHandler
|
||||
B INTT4TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT4ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT4ERR_IRQHandler
|
||||
B INTT4ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT5RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT5RX_IRQHandler
|
||||
B INTT5RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT5TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT5TX_IRQHandler
|
||||
B INTT5TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT5ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT5ERR_IRQHandler
|
||||
B INTT5ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT6RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT6RX_IRQHandler
|
||||
B INTT6RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT6TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT6TX_IRQHandler
|
||||
B INTT6TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT6ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT6ERR_IRQHandler
|
||||
B INTT6ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT7RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT7RX_IRQHandler
|
||||
B INTT7RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT7TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT7TX_IRQHandler
|
||||
B INTT7TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT7ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT7ERR_IRQHandler
|
||||
B INTT7ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTT8RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT8RX_IRQHandler
|
||||
B INTT8RX_IRQHandler
|
||||
|
||||
PUBWEAK INTT8TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT8TX_IRQHandler
|
||||
B INTT8TX_IRQHandler
|
||||
|
||||
PUBWEAK INTT8ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTT8ERR_IRQHandler
|
||||
B INTT8ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTSMI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTSMI0_IRQHandler
|
||||
B INTSMI0_IRQHandler
|
||||
|
||||
PUBWEAK INTUART0RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART0RX_IRQHandler
|
||||
B INTUART0RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART0TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART0TX_IRQHandler
|
||||
B INTUART0TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART0ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART0ERR_IRQHandler
|
||||
B INTUART0ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTUART1RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART1RX_IRQHandler
|
||||
B INTUART1RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART1TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART1TX_IRQHandler
|
||||
B INTUART1TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART1ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART1ERR_IRQHandler
|
||||
B INTUART1ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTUART2RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART2RX_IRQHandler
|
||||
B INTUART2RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART2TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART2TX_IRQHandler
|
||||
B INTUART2TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART2ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART2ERR_IRQHandler
|
||||
B INTUART2ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTUART3RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART3RX_IRQHandler
|
||||
B INTUART3RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART3TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART3TX_IRQHandler
|
||||
B INTUART3TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART3ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART3ERR_IRQHandler
|
||||
B INTUART3ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTUART4RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART4RX_IRQHandler
|
||||
B INTUART4RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART4TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART4TX_IRQHandler
|
||||
B INTUART4TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART4ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART4ERR_IRQHandler
|
||||
B INTUART4ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTUART5RX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART5RX_IRQHandler
|
||||
B INTUART5RX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART5TX_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART5TX_IRQHandler
|
||||
B INTUART5TX_IRQHandler
|
||||
|
||||
PUBWEAK INTUART5ERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTUART5ERR_IRQHandler
|
||||
B INTUART5ERR_IRQHandler
|
||||
|
||||
PUBWEAK INTFUART0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTFUART0_IRQHandler
|
||||
B INTFUART0_IRQHandler
|
||||
|
||||
PUBWEAK INTFUART1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTFUART1_IRQHandler
|
||||
B INTFUART1_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C0_IRQHandler
|
||||
B INTI2C0_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C0AL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C0AL_IRQHandler
|
||||
B INTI2C0AL_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C0BF_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C0BF_IRQHandler
|
||||
B INTI2C0BF_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C0NACK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C0NACK_IRQHandler
|
||||
B INTI2C0NACK_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C1_IRQHandler
|
||||
B INTI2C1_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C1AL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C1AL_IRQHandler
|
||||
B INTI2C1AL_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C1BF_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C1BF_IRQHandler
|
||||
B INTI2C1BF_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C1NACK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C1NACK_IRQHandler
|
||||
B INTI2C1NACK_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C2_IRQHandler
|
||||
B INTI2C2_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C2AL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C2AL_IRQHandler
|
||||
B INTI2C2AL_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C2BF_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C2BF_IRQHandler
|
||||
B INTI2C2BF_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C2NACK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C2NACK_IRQHandler
|
||||
B INTI2C2NACK_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C3_IRQHandler
|
||||
B INTI2C3_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C3AL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C3AL_IRQHandler
|
||||
B INTI2C3AL_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C3BF_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C3BF_IRQHandler
|
||||
B INTI2C3BF_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C3NACK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C3NACK_IRQHandler
|
||||
B INTI2C3NACK_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C4_IRQHandler
|
||||
B INTI2C4_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C4AL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C4AL_IRQHandler
|
||||
B INTI2C4AL_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C4BF_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C4BF_IRQHandler
|
||||
B INTI2C4BF_IRQHandler
|
||||
|
||||
PUBWEAK INTI2C4NACK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTI2C4NACK_IRQHandler
|
||||
B INTI2C4NACK_IRQHandler
|
||||
|
||||
PUBWEAK INTADACP0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADACP0_IRQHandler
|
||||
B INTADACP0_IRQHandler
|
||||
|
||||
PUBWEAK INTADACP1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADACP1_IRQHandler
|
||||
B INTADACP1_IRQHandler
|
||||
|
||||
PUBWEAK INTADATRG_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADATRG_IRQHandler
|
||||
B INTADATRG_IRQHandler
|
||||
|
||||
PUBWEAK INTADASGL_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADASGL_IRQHandler
|
||||
B INTADASGL_IRQHandler
|
||||
|
||||
PUBWEAK INTADACNT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADACNT_IRQHandler
|
||||
B INTADACNT_IRQHandler
|
||||
|
||||
PUBWEAK INTADAHP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTADAHP_IRQHandler
|
||||
B INTADAHP_IRQHandler
|
||||
|
||||
PUBWEAK INTFLDRDY_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTFLDRDY_IRQHandler
|
||||
B INTFLDRDY_IRQHandler
|
||||
|
||||
PUBWEAK INTFLCRDY0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTFLCRDY0_IRQHandler
|
||||
B INTFLCRDY0_IRQHandler
|
||||
|
||||
PUBWEAK INTFLCRDY1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTFLCRDY1_IRQHandler
|
||||
B INTFLCRDY1_IRQHandler
|
||||
|
||||
PUBWEAK INTMDMAABERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTMDMAABERR_IRQHandler
|
||||
B INTMDMAABERR_IRQHandler
|
||||
|
||||
PUBWEAK INTMDMAADERR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
INTMDMAADERR_IRQHandler
|
||||
B INTMDMAADERR_IRQHandler
|
||||
|
||||
END
|
|
@ -0,0 +1,45 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
if (!isdefinedsymbol(MBED_APP_START)) { define symbol MBED_APP_START = 0x00000000; }
|
||||
if (!isdefinedsymbol(MBED_APP_SIZE)) { define symbol MBED_APP_SIZE = 0x180000; }
|
||||
define symbol __ICFEDIT_intvec_start__ = MBED_APP_START;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000320;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2002FFFF;
|
||||
define symbol __ICFEDIT_region_BRAM_start__ = 0x20030000;
|
||||
define symbol __ICFEDIT_region_BRAM_end__ = 0x200307FF;
|
||||
/*-Sizes-*/
|
||||
/*Heap 1/4 of ram and stack 1/8*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x0400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x6000;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
initialize by copy { section RAMCODE };
|
||||
|
||||
/* Place both in a block */
|
||||
define block RamCode { section RAMCODE };
|
||||
define block RamCodeInit { section RAMCODE_init };
|
||||
|
||||
/* Place them in ROM and RAM */
|
||||
place in ROM_region { block RamCodeInit };
|
||||
place in RAM_region { block RamCode };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
||||
place in ROM_region { readonly };
|
|
@ -0,0 +1,12 @@
|
|||
/* mbed Microcontroller Library - CMSIS for TMPM4G9
|
||||
* Copyright (C) 2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* A generic CMSIS include header, pulling in TMPM4G9 specifics
|
||||
*/
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "TMPM4G9.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,28 @@
|
|||
/* mbed Microcontroller Library - cmsis_nvic for TMPM4G9
|
||||
* Copyright (c) 2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#pragma section=".intvec"
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)__section_begin(".intvec"))
|
||||
#elif defined(__CC_ARM)
|
||||
extern uint32_t Load$$LR$$LR_IROM1$$Base[];
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)Load$$LR$$LR_IROM1$$Base)
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t vectors[];
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS ((uint32_t)vectors)
|
||||
#else
|
||||
#error "Flash vector address not set for this toolchain"
|
||||
#endif
|
||||
|
||||
|
||||
#define NVIC_NUM_VECTORS (157)
|
||||
#define NVIC_RAM_VECTOR_ADDRESS 0x20000000 // Location of vectors in RAM
|
||||
|
||||
#endif
|
|
@ -0,0 +1,336 @@
|
|||
/**
|
||||
*******************************************************************************
|
||||
* @file system_TMPM4G9.c
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer Source File for the
|
||||
* TOSHIBA 'TMPM4Gx' Device Series
|
||||
* @version 1.0.0.0
|
||||
* $Date:: 2018-04-02 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENCE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "TMPM4G9.h"
|
||||
|
||||
/*-------- <<< Start of configuration section >>> ----------------------------*/
|
||||
|
||||
/* Semi-Independent Watchdog Timer (SIWDT) Configuration */
|
||||
#define SIWD_SETUP (1U) /* 1:Disable SIWD, 0:Enable SIWD */
|
||||
#define SIWDEN_Val (0x00000000UL) /* SIWD Disable */
|
||||
#define SIWDCR_Val (0x000000B1UL) /* SIWD Disable code */
|
||||
|
||||
/* Clock Generator (CG) Configuration */
|
||||
#define CLOCK_SETUP (1U) /* 1:External HOSC, 0: Internal HOSC */
|
||||
#define SYSCR_GEAR_Val (0x00000000UL) /* GEAR = fc */
|
||||
#define SYSCR_MCKSEL_Val (0x00000001UL) /* fsysm(phiT0m) = fsysh(phiT0h) / 2 */
|
||||
|
||||
#define STBYCR_Val (0x00000000UL)
|
||||
|
||||
#define CG_8M_MUL_20_FPLL (0x00245028UL<<8U) /* fPLL = 8MHz * 20 */
|
||||
#define CG_10M_MUL_16_FPLL (0x002E5020UL<<8U) /* fPLL = 10MHz * 16 */
|
||||
#define CG_12M_MUL_13_3125_FPLL (0x0036DA1AUL<<8U) /* fPLL = 12MHz * 13.3125 */
|
||||
#define CG_16M_MUL_10_FPLL (0x0048D014UL<<8U) /* fPLL = 16MHz * 10 */
|
||||
#define CG_20M_MUL_8_FPLL (0x005AD010UL<<8U) /* fPLL = 20MHz * 8 */
|
||||
|
||||
#define CG_PLL0SEL_PLL0ON_SET (0x00000001UL)
|
||||
#define CG_PLL0SEL_PLL0ON_CLEAR (0xFFFFFFFEUL)
|
||||
#define CG_PLL0SEL_PLL0SEL_SET (0x00000002UL)
|
||||
#define CG_PLL0SEL_PLL0SEL_CLEAR (0xFFFFFFFDUL)
|
||||
|
||||
#define CG_SYSCR_MCKSEL_SET (SYSCR_MCKSEL_Val << 6U)
|
||||
#define CG_SYSCR_MCKSELGST_Val (SYSCR_MCKSEL_Val << 22U)
|
||||
#define CG_SYSCR_MCKSELPST_Val (SYSCR_MCKSEL_Val << 30U)
|
||||
|
||||
#define CG_OSCCR_IHOSC1EN_CLEAR (0xFFFFFFFEUL)
|
||||
#define CG_OSCCR_EOSCEN_SET (0x00000002UL)
|
||||
#define CG_OSCCR_OSCSEL_SET (0x00000100UL)
|
||||
|
||||
#define CG_WUPHCR_WUON_START_SET (0x00000001UL)
|
||||
|
||||
#define EXT_CG_WUPHCR_WUCLK_SET (0x00000000UL) /* WUCLK for External HOSC select the IHOSC1 */
|
||||
#if (CLOCK_SETUP)
|
||||
#define CG_WUPHCR_WUCLK_SET (0x00000100UL) /* WUCLK for Inital/Lockup time */
|
||||
#define PLL0SEL_Ready CG_10M_MUL_16_FPLL
|
||||
#else
|
||||
#define CG_WUPHCR_WUCLK_SET (0x00000000UL) /* WUCLK for Inital/Lockup time */
|
||||
#define PLL0SEL_Ready CG_10M_MUL_16_FPLL
|
||||
#endif
|
||||
#define PLL0SEL_Val (PLL0SEL_Ready|0x00000003UL)
|
||||
#define PLL0SEL_MASK (0xFFFFFF00UL)
|
||||
|
||||
/*-------- <<< End of configuration section >>> ------------------------------*/
|
||||
|
||||
/*-------- DEFINES -----------------------------------------------------------*/
|
||||
/* Define clocks */
|
||||
#define EOSC_8M (8000000UL)
|
||||
#define EOSC_10M (10000000UL)
|
||||
#define EOSC_12M (12000000UL)
|
||||
#define EOSC_16M (16000000UL)
|
||||
#define EOSC_20M (20000000UL)
|
||||
#define IOSC_10M (10000000UL)
|
||||
#define EXTALH EOSC_10M /* External high-speed oscillator freq */
|
||||
#define IXTALH IOSC_10M /* Internal high-speed oscillator freq */
|
||||
#define EOSC_8M_DIV2_PLLON (160000000UL) /* 8.00MHz * 40.0000 / 2 */
|
||||
#define EOSC_10M_DIV2_PLLON (160000000UL) /* 10.00MHz * 32.0000 / 2 */
|
||||
#define EOSC_12M_DIV2_PLLON (159750000UL) /* 12.00MHz * 26.6250 / 2 */
|
||||
#define EOSC_16M_DIV2_PLLON (160000000UL) /* 16.00MHz * 20.0000 / 2 */
|
||||
#define EOSC_20M_DIV2_PLLON (160000000UL) /* 20.00MHz * 16.0000 / 2 */
|
||||
#define IOSC_10M_DIV2_PLLON (160000000UL) /* 10.00MHz * 32.0000 / 2 */
|
||||
|
||||
/* Configure Warm-up time */
|
||||
#define HZ_1M (1000000UL)
|
||||
#define WU_TIME_EXT (5000UL) /* warm-up time for EXT is 5ms */
|
||||
#define INIT_TIME_PLL (100UL) /* Initial time for PLL is 100us */
|
||||
#define LOCKUP_TIME_PLL (400UL) /* Lockup time for PLL is 400us */
|
||||
#define WUPHCR_WUPT_EXT ((uint32_t)(((((uint64_t)WU_TIME_EXT * IXTALH / HZ_1M) - 16UL) /16UL) << 20U)) /* OSCCR<WUPT11:0> = (warm-up time(us) * IXTALH - 16) / 16 */
|
||||
#if (CLOCK_SETUP)
|
||||
#define WUPHCR_INIT_PLL ((uint32_t)(((((uint64_t)INIT_TIME_PLL * EXTALH / HZ_1M) - 16UL) /16UL) << 20U))
|
||||
#define WUPHCR_LUPT_PLL ((uint32_t)(((((uint64_t)LOCKUP_TIME_PLL * EXTALH / HZ_1M) - 16UL) /16UL) << 20U))
|
||||
#else
|
||||
#define WUPHCR_INIT_PLL ((uint32_t)(((((uint64_t)INIT_TIME_PLL * IXTALH / HZ_1M) - 16UL) /16UL) << 20U))
|
||||
#define WUPHCR_LUPT_PLL ((uint32_t)(((((uint64_t)LOCKUP_TIME_PLL * IXTALH / HZ_1M) - 16UL) /16UL) << 20U))
|
||||
#endif
|
||||
|
||||
/* Determine core clock frequency according to settings */
|
||||
/* System clock is high-speed clock*/
|
||||
#if (CLOCK_SETUP)
|
||||
#define CORE_TALH (EXTALH)
|
||||
#else
|
||||
#define CORE_TALH (IXTALH)
|
||||
#endif
|
||||
|
||||
#if ((PLL0SEL_Val & (1U<<1U)) && (PLL0SEL_Val & (1U<<0U))) /* If PLL selected and enabled */
|
||||
#if (CORE_TALH == EOSC_8M) /* If input is 8MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == (CG_8M_MUL_20_FPLL))
|
||||
#define __CORE_CLK EOSC_8M_DIV2_PLLON /* output clock is 160MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 8MHz */
|
||||
#elif (CORE_TALH == EOSC_10M) /* If input is 10MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == CG_10M_MUL_16_FPLL)
|
||||
#define __CORE_CLK EOSC_10M_DIV2_PLLON /* output clock is 160MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 10MHz */
|
||||
#elif (CORE_TALH == EOSC_12M) /* If input is 12MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == CG_12M_MUL_13_3125_FPLL)
|
||||
#define __CORE_CLK EOSC_12M_DIV2_PLLON /* output clock is 159.75MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 12MHz */
|
||||
#elif (CORE_TALH == EOSC_16M) /* If input is 16MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == CG_16M_MUL_10_FPLL)
|
||||
#define __CORE_CLK EOSC_16M_DIV2_PLLON /* output clock is 160MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 16MHz */
|
||||
#elif (CORE_TALH == EOSC_20M) /* If input is 20MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == CG_20M_MUL_8_FPLL)
|
||||
#define __CORE_CLK EOSC_20M_DIV2_PLLON /* output clock is 160MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 20MHz */
|
||||
#elif (CORE_TALH == IOSC_10M) /* If input is 10MHz */
|
||||
#if ((PLL0SEL_Val & PLL0SEL_MASK) == CG_10M_MUL_16_FPLL)
|
||||
#define __CORE_CLK IOSC_10M_DIV2_PLLON /* output clock is 160MHz */
|
||||
#else /* fc -> reserved */
|
||||
#define __CORE_CLK (0U)
|
||||
#endif /* End input is 10MHz */
|
||||
#else /* input clock not known */
|
||||
#define __CORE_CLK (0U)
|
||||
#error "Core Oscillator Frequency invalid!"
|
||||
#endif /* End switch input clock */
|
||||
#else
|
||||
#define __CORE_CLK (CORE_TALH)
|
||||
#endif
|
||||
|
||||
#if ((SYSCR_GEAR_Val & 7U) == 0U) /* Gear -> fc */
|
||||
#define __CORE_SYS (__CORE_CLK)
|
||||
#elif ((SYSCR_GEAR_Val & 7U) == 1U) /* Gear -> fc/2 */
|
||||
#define __CORE_SYS (__CORE_CLK / 2U)
|
||||
#elif ((SYSCR_GEAR_Val & 7U) == 2U) /* Gear -> fc/4 */
|
||||
#define __CORE_SYS (__CORE_CLK / 4U )
|
||||
#elif ((SYSCR_GEAR_Val & 7U) == 3U) /* Gear -> fc/8 */
|
||||
#define __CORE_SYS (__CORE_CLK / 8U)
|
||||
#elif ((SYSCR_GEAR_Val & 7U) == 4U) /* Gear -> fc/16 */
|
||||
#define __CORE_SYS (__CORE_CLK / 16U)
|
||||
#else /* Gear -> reserved */
|
||||
#define __CORE_SYS (0U)
|
||||
#endif
|
||||
|
||||
|
||||
/* Clock Variable definitions */
|
||||
uint32_t SystemCoreClock = __CORE_SYS; /*!< System Clock Frequency (Core Clock) */
|
||||
uint32_t CoreClockInput = 0U;
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Update SystemCoreClock according register values.
|
||||
*/
|
||||
void SystemCoreClockUpdate(void)
|
||||
{ /* Get Core Clock Frequency */
|
||||
uint32_t CoreClock = 0U;
|
||||
uint32_t regval = 0U;
|
||||
uint32_t oscsel = 0U;
|
||||
uint32_t pll0sel = 0U;
|
||||
uint32_t pll0on = 0U;
|
||||
|
||||
CoreClockInput = 0U;
|
||||
/* Determine clock frequency according to clock register values */
|
||||
/* System clock is high-speed clock */
|
||||
regval = TSB_CG->OSCCR;
|
||||
oscsel = regval & CG_OSCCR_OSCSEL_SET;
|
||||
if (oscsel) { /* If system clock is External high-speed oscillator freq */
|
||||
CoreClock = EXTALH;
|
||||
} else { /* If system clock is Internal high-speed oscillator freq */
|
||||
CoreClock = IXTALH;
|
||||
}
|
||||
regval = TSB_CG->PLL0SEL;
|
||||
pll0sel = regval & CG_PLL0SEL_PLL0SEL_SET;
|
||||
pll0on = regval & CG_PLL0SEL_PLL0ON_SET;
|
||||
if (pll0sel && pll0on) { /* If PLL enabled */
|
||||
if (CoreClock == EOSC_8M) { /* If input is 8MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_8M_MUL_20_FPLL) {
|
||||
CoreClockInput = EOSC_8M_DIV2_PLLON; /* output clock is 160MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else if (CoreClock == EOSC_10M) { /* If input is 10MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_10M_MUL_16_FPLL) {
|
||||
CoreClockInput = EOSC_10M_DIV2_PLLON; /* output clock is 160MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else if (CoreClock == EOSC_12M) { /* If input is 12MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_12M_MUL_13_3125_FPLL) {
|
||||
CoreClockInput = EOSC_12M_DIV2_PLLON; /* output clock is 159.75MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else if (CoreClock == EOSC_16M) { /* If input is 16MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_16M_MUL_10_FPLL) {
|
||||
CoreClockInput = EOSC_16M_DIV2_PLLON; /* output clock is 160MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else if (CoreClock == EOSC_20M) { /* If input is 20MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_20M_MUL_8_FPLL) {
|
||||
CoreClockInput = EOSC_20M_DIV2_PLLON; /* output clock is 160MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else if (CoreClock == IOSC_10M) { /* If input is 10MHz */
|
||||
if ((TSB_CG->PLL0SEL & PLL0SEL_MASK) == CG_10M_MUL_16_FPLL) {
|
||||
CoreClockInput = IOSC_10M_DIV2_PLLON; /* output clock is 160MHz */
|
||||
} else {
|
||||
CoreClockInput = 0U; /* fc -> reserved */
|
||||
}
|
||||
} else {
|
||||
CoreClockInput = 0U;
|
||||
}
|
||||
} else { /* If PLL not used */
|
||||
CoreClockInput = CoreClock;
|
||||
}
|
||||
|
||||
switch (TSB_CG->SYSCR & 7U) {
|
||||
case 0U: /* Gear -> fc */
|
||||
SystemCoreClock = CoreClockInput;
|
||||
break;
|
||||
case 1U: /* Gear -> fc/2 */
|
||||
SystemCoreClock = CoreClockInput / 2U;
|
||||
break;
|
||||
case 2U: /* Gear -> fc/4 */
|
||||
SystemCoreClock = CoreClockInput / 4U;
|
||||
break;
|
||||
case 3U: /* Gear -> fc/8 */
|
||||
SystemCoreClock = CoreClockInput / 8U;
|
||||
break;
|
||||
case 4U: /* Gear -> fc/16 */
|
||||
SystemCoreClock = CoreClockInput / 16U;
|
||||
break;
|
||||
case 5U:
|
||||
case 6U:
|
||||
case 7U:
|
||||
SystemCoreClock = 0U;
|
||||
break;
|
||||
default:
|
||||
SystemCoreClock = 0U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System.
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
#if (SIWD_SETUP) /* Watchdog Setup */
|
||||
/* SIWD Disable */
|
||||
TSB_SIWD0->EN = SIWDEN_Val;
|
||||
TSB_SIWD0->CR = SIWDCR_Val;
|
||||
#else
|
||||
/* SIWD Enable (Setting after a Reset) */
|
||||
#endif
|
||||
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) /* FPU setting */
|
||||
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
|
||||
#endif
|
||||
|
||||
#if (CLOCK_SETUP) /* Clock(external) Setup */
|
||||
TSB_CG->SYSCR = SYSCR_GEAR_Val;
|
||||
|
||||
TSB_CG->WUPHCR = (WUPHCR_WUPT_EXT | EXT_CG_WUPHCR_WUCLK_SET);
|
||||
TSB_CG->OSCCR |= CG_OSCCR_EOSCEN_SET;
|
||||
TSB_CG->WUPHCR = (WUPHCR_WUPT_EXT | EXT_CG_WUPHCR_WUCLK_SET | CG_WUPHCR_WUON_START_SET);
|
||||
while (TSB_CG_WUPHCR_WUEF) {
|
||||
;
|
||||
} /* Warm-up */
|
||||
|
||||
TSB_CG->OSCCR |= CG_OSCCR_OSCSEL_SET;
|
||||
while (!TSB_CG_OSCCR_OSCF) {
|
||||
;
|
||||
} /* Confirm CGOSCCR<OSCF>="1" */
|
||||
TSB_CG->OSCCR &= CG_OSCCR_IHOSC1EN_CLEAR ;
|
||||
#else
|
||||
/* Internal HOSC Enable (Setting after a Reset) */
|
||||
#endif
|
||||
|
||||
TSB_CG->SYSCR = (SYSCR_GEAR_Val | CG_SYSCR_MCKSEL_SET); /* set <MCKSEL> */
|
||||
while((TSB_CG->SYSCR & (CG_SYSCR_MCKSELGST_Val | CG_SYSCR_MCKSELPST_Val))
|
||||
!= ((CG_SYSCR_MCKSELGST_Val | CG_SYSCR_MCKSELPST_Val))){
|
||||
;
|
||||
}
|
||||
|
||||
TSB_CG->WUPHCR = (WUPHCR_INIT_PLL | CG_WUPHCR_WUCLK_SET);
|
||||
TSB_CG->PLL0SEL &= CG_PLL0SEL_PLL0SEL_CLEAR; /* PLL-->fOsc */
|
||||
TSB_CG->PLL0SEL &= CG_PLL0SEL_PLL0ON_CLEAR;
|
||||
TSB_CG->PLL0SEL = PLL0SEL_Ready;
|
||||
TSB_CG->WUPHCR = (WUPHCR_INIT_PLL | CG_WUPHCR_WUCLK_SET | CG_WUPHCR_WUON_START_SET);
|
||||
while (TSB_CG_WUPHCR_WUEF) {
|
||||
;
|
||||
} /* Warm-up */
|
||||
|
||||
TSB_CG->WUPHCR = (WUPHCR_LUPT_PLL | CG_WUPHCR_WUCLK_SET);
|
||||
TSB_CG->PLL0SEL |= CG_PLL0SEL_PLL0ON_SET; /* PLL enabled */
|
||||
TSB_CG->STBYCR = STBYCR_Val;
|
||||
TSB_CG->WUPHCR = (WUPHCR_LUPT_PLL | CG_WUPHCR_WUCLK_SET | CG_WUPHCR_WUON_START_SET);
|
||||
while (TSB_CG_WUPHCR_WUEF) {
|
||||
;
|
||||
} /* Lockup */
|
||||
TSB_CG->PLL0SEL |= CG_PLL0SEL_PLL0SEL_SET;
|
||||
while (!TSB_CG_PLL0SEL_PLL0ST) {
|
||||
;
|
||||
} /*Confirm CGPLL0SEL<PLL0ST> = "1" */
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
*****************************************************************************
|
||||
* @file system_TMPM4G9.h
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer Header File for the
|
||||
* TOSHIBA 'TMPM4G9' Device Series
|
||||
* @version V0.0.0.0
|
||||
* $Date:: 2018-04-02 #$
|
||||
*
|
||||
* DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENCE AGREEMENT.
|
||||
*
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2017 All rights reserved
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __SYSTEM_TMPM4G9_H
|
||||
#define __SYSTEM_TMPM4G9_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
extern uint32_t CoreClockInput; /*!< High speed Clock Frequency */
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,123 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "tmpm4g9_fc.h"
|
||||
|
||||
#define PROGRAM_WIRTE_MAX (16U) // Page program could be written 16 bytes/4 words once
|
||||
#define SECTOR_SIZE (0x8000) // 32KB each sectors or block
|
||||
#define FLASH_CHIP_SIZE (0x00180000) // Flash chip size is 1536KByte
|
||||
#define MASK_CHIP_ID_FROM_ADD (0x00FFFFFFUL)
|
||||
|
||||
#define SUCCESS (0U)
|
||||
#define FAIL (-1)
|
||||
// IHOSC1EN
|
||||
#define CGOSCCR_IHOSC1EN_MASK ((uint32_t)0x00000001) // IHOSC1EN :Mask
|
||||
#define CGOSCCR_IHOSC1EN_RW_DISABLE ((uint32_t)0x00000000) // IHOSC1EN :[R/W] :Disable
|
||||
#define CGOSCCR_IHOSC1EN_RW_ENABLE ((uint32_t)0x00000001) // IHOSC1EN :[R/W] :Enable
|
||||
|
||||
static void internal_hosc_enable(void);
|
||||
|
||||
int32_t flash_init(flash_t *obj)
|
||||
{
|
||||
obj->flash_inited = 0;
|
||||
obj->flash_inited = 1;
|
||||
internal_hosc_enable(); // Internal HOSC enable
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t flash_free(flash_t *obj)
|
||||
{
|
||||
obj->flash_inited = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
||||
{
|
||||
int status = FAIL;
|
||||
|
||||
if (obj->flash_inited == 0) {
|
||||
flash_init(obj);
|
||||
}
|
||||
|
||||
// We need to prevent flash accesses during erase operation
|
||||
core_util_critical_section_enter();
|
||||
|
||||
if (TXZ_SUCCESS == fc_erase_block_code_flash((uint32_t*)FC_CODE_FLASH_ADDRESS_TOP, (uint32_t*)address)) {
|
||||
status = SUCCESS;
|
||||
} else {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
|
||||
{
|
||||
int status = SUCCESS;
|
||||
|
||||
address &= MASK_CHIP_ID_FROM_ADD;
|
||||
|
||||
// We need to prevent flash accesses during program operation
|
||||
core_util_critical_section_enter();
|
||||
|
||||
if (TXZ_SUCCESS == fc_write_code_flash((uint32_t*)data, (uint32_t*)address, size)) {
|
||||
// Do nothing
|
||||
} else {
|
||||
status = FAIL;
|
||||
}
|
||||
|
||||
core_util_critical_section_exit();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
|
||||
{
|
||||
if ((address >= FC_CODE_FLASH_ADDRESS_TOP) && (address < (FC_CODE_FLASH_ADDRESS_TOP + FLASH_CHIP_SIZE))) {
|
||||
return SECTOR_SIZE;
|
||||
} else {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
return MBED_FLASH_INVALID_SIZE;
|
||||
}
|
||||
|
||||
uint32_t flash_get_page_size(const flash_t *obj)
|
||||
{
|
||||
return PROGRAM_WIRTE_MAX;
|
||||
}
|
||||
|
||||
uint32_t flash_get_start_address(const flash_t *obj)
|
||||
{
|
||||
return FC_CODE_FLASH_ADDRESS_TOP;
|
||||
}
|
||||
|
||||
uint32_t flash_get_size(const flash_t *obj)
|
||||
{
|
||||
return FLASH_CHIP_SIZE;
|
||||
}
|
||||
|
||||
static void internal_hosc_enable(void)
|
||||
{
|
||||
uint32_t work;
|
||||
work = (uint32_t)(TSB_CG->OSCCR & ~CGOSCCR_IHOSC1EN_MASK);
|
||||
TSB_CG->OSCCR = (uint32_t)(work | CGOSCCR_IHOSC1EN_RW_ENABLE);
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "gpio_api.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "pinmap.h"
|
||||
#include "mbed_error.h"
|
||||
#include "txz_gpio.h"
|
||||
|
||||
#define GPIO_DATA PIN_DATA(0, 2)
|
||||
#define ALT_FUNC_GPIO 0
|
||||
|
||||
_gpio_t gpio_port_add = {
|
||||
.p_pa_instance = TSB_PA,
|
||||
.p_pb_instance = TSB_PB,
|
||||
.p_pc_instance = TSB_PC,
|
||||
.p_pd_instance = TSB_PD,
|
||||
.p_pe_instance = TSB_PE,
|
||||
.p_pf_instance = TSB_PF,
|
||||
.p_pg_instance = TSB_PG,
|
||||
.p_ph_instance = TSB_PH,
|
||||
.p_pj_instance = TSB_PJ,
|
||||
.p_pk_instance = TSB_PK,
|
||||
.p_pl_instance = TSB_PL,
|
||||
.p_pm_instance = TSB_PM,
|
||||
.p_pn_instance = TSB_PN,
|
||||
.p_pp_instance = TSB_PP,
|
||||
.p_pr_instance = TSB_PR,
|
||||
.p_pt_instance = TSB_PT,
|
||||
.p_pu_instance = TSB_PU,
|
||||
.p_pv_instance = TSB_PV,
|
||||
.p_pw_instance = TSB_PW,
|
||||
.p_py_instance = TSB_PY
|
||||
};
|
||||
|
||||
uint32_t gpio_set(PinName pin)
|
||||
{
|
||||
// Check that pin is valid
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
// Set pin function as GPIO pin
|
||||
pin_function(pin, GPIO_DATA);
|
||||
|
||||
// Return pin mask
|
||||
return (1 << (pin & 0x07));
|
||||
}
|
||||
|
||||
void gpio_init(gpio_t *obj, PinName pin)
|
||||
{
|
||||
// Store above pin mask, pin name into GPIO object
|
||||
obj->pin = pin;
|
||||
obj->pin_num = PIN_POS(pin);
|
||||
obj->mask = gpio_set(pin);
|
||||
obj->port = (PortName) PIN_PORT(pin);
|
||||
// Enable clock for particular port
|
||||
TSB_CG->FSYSMENB |= (1 << ((obj->port) + 2));
|
||||
}
|
||||
|
||||
void gpio_mode(gpio_t *obj, PinMode mode)
|
||||
{
|
||||
// Set pin mode
|
||||
pin_mode(obj->pin, mode);
|
||||
}
|
||||
|
||||
// Set gpio object pin direction
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction)
|
||||
{
|
||||
// Set direction
|
||||
switch (direction) {
|
||||
case PIN_INPUT:
|
||||
// Set pin input
|
||||
gpio_func(&gpio_port_add,
|
||||
(gpio_gr_t)obj->port,
|
||||
(gpio_num_t)obj->pin_num,
|
||||
(uint32_t)ALT_FUNC_GPIO,
|
||||
GPIO_PIN_INPUT);
|
||||
break;
|
||||
case PIN_OUTPUT:
|
||||
// Set pin output
|
||||
gpio_func(&gpio_port_add,
|
||||
(gpio_gr_t)obj->port,
|
||||
(gpio_num_t)obj->pin_num,
|
||||
(uint32_t)ALT_FUNC_GPIO,
|
||||
GPIO_PIN_OUTPUT);
|
||||
break;
|
||||
case PIN_INOUT:
|
||||
// Set pin both input and output
|
||||
gpio_func(&gpio_port_add,
|
||||
(gpio_gr_t)obj->port,
|
||||
(gpio_num_t)obj->pin_num,
|
||||
(uint32_t)ALT_FUNC_GPIO,
|
||||
GPIO_PIN_INOUT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_write(gpio_t *obj, int value)
|
||||
{
|
||||
// Write gpio object pin data
|
||||
gpio_write_bit(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)obj->pin_num, GPIO_Mode_DATA, value);
|
||||
}
|
||||
|
||||
int gpio_read(gpio_t *obj)
|
||||
{
|
||||
// Read gpio object pin data
|
||||
gpio_pinstate_t val = GPIO_PIN_SET; // To initialize local variable
|
||||
gpio_read_bit(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)obj->pin_num, GPIO_Mode_DATA, &val);
|
||||
return val;
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "gpio_irq_api.h"
|
||||
#include "mbed_error.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "pinmap.h"
|
||||
#include "mbed_critical.h"
|
||||
#include "txz_gpio.h"
|
||||
|
||||
#define CHANNEL_NUM (16)
|
||||
#define DISABLE (0)
|
||||
#define ENABLE (1)
|
||||
#define CLR_INT_FLAG (0xC0)
|
||||
|
||||
const PinMap PinMap_GPIO_IRQ[] = {
|
||||
{PK7, GPIO_IRQ_0, PIN_DATA(0, 0)},
|
||||
{PL0, GPIO_IRQ_1, PIN_DATA(0, 0)},
|
||||
{PA0, GPIO_IRQ_2, PIN_DATA(0, 0)},
|
||||
{PA7, GPIO_IRQ_3, PIN_DATA(0, 0)},
|
||||
{PB0, GPIO_IRQ_4, PIN_DATA(0, 0)},
|
||||
{PB1, GPIO_IRQ_5, PIN_DATA(0, 0)},
|
||||
{PB6, GPIO_IRQ_6, PIN_DATA(0, 0)},
|
||||
{PB7, GPIO_IRQ_7, PIN_DATA(0, 0)},
|
||||
{PG0, GPIO_IRQ_8, PIN_DATA(0, 0)},
|
||||
{PG1, GPIO_IRQ_9, PIN_DATA(0, 0)},
|
||||
{PK0, GPIO_IRQ_A, PIN_DATA(0, 0)},
|
||||
{PK1, GPIO_IRQ_B, PIN_DATA(0, 0)},
|
||||
{PC0, GPIO_IRQ_C, PIN_DATA(0, 0)},
|
||||
{PC1, GPIO_IRQ_D, PIN_DATA(0, 0)},
|
||||
{PC6, GPIO_IRQ_E, PIN_DATA(0, 0)},
|
||||
{PC7, GPIO_IRQ_F, PIN_DATA(0, 0)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
extern _gpio_t gpio_port_add;
|
||||
|
||||
static uint32_t channel_ids[CHANNEL_NUM] = {0};
|
||||
static gpio_irq_handler hal_irq_handler[CHANNEL_NUM] = {NULL};
|
||||
static CG_INTActiveState CurrentState;
|
||||
|
||||
static void CG_SetSTBYReleaseINTSrc(CG_INTSrc, CG_INTActiveState, uint8_t);
|
||||
static void INT_IRQHandler(PinName, uint32_t);
|
||||
|
||||
void INT00_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PK7, 0);
|
||||
}
|
||||
|
||||
void INT01_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PL0, 1);
|
||||
}
|
||||
|
||||
void INT02_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PA0, 2);
|
||||
}
|
||||
|
||||
void INT03_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PA7, 3);
|
||||
}
|
||||
|
||||
void INT04_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PB0, 4);
|
||||
}
|
||||
|
||||
void INT05_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PB1, 5);
|
||||
}
|
||||
|
||||
void INT06_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PB6, 6);
|
||||
}
|
||||
|
||||
void INT07_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PB7, 7);
|
||||
}
|
||||
|
||||
void INT08_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PG0, 8);
|
||||
}
|
||||
|
||||
void INT09_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PG1, 9);
|
||||
}
|
||||
|
||||
void INT10_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PK0, 10);
|
||||
}
|
||||
|
||||
void INT11_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PK1, 11);
|
||||
}
|
||||
|
||||
void INT12_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PC0, 12);
|
||||
}
|
||||
void INT13_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PC1, 13);
|
||||
}
|
||||
void INT14_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PC6, 14);
|
||||
}
|
||||
void INT15_IRQHandler(void)
|
||||
{
|
||||
INT_IRQHandler(PC7, 15);
|
||||
}
|
||||
|
||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
|
||||
{
|
||||
// Get gpio interrupt ID
|
||||
obj->irq_id = pinmap_peripheral(pin, PinMap_GPIO_IRQ);
|
||||
core_util_critical_section_enter();
|
||||
// Get GPIO port and pin num
|
||||
obj->port = (PortName)PIN_PORT(pin);
|
||||
obj->pin_num = PIN_POS(pin);
|
||||
// Set pin level as LOW
|
||||
gpio_write_bit(&gpio_port_add, obj->port, obj->pin_num, GPIO_Mode_DATA, 0);
|
||||
// Enable gpio interrupt function
|
||||
pinmap_pinout(pin, PinMap_GPIO_IRQ);
|
||||
// Get GPIO irq source
|
||||
obj->irq_src = (CG_INTSrc)obj->irq_id;
|
||||
// Save irq handler
|
||||
hal_irq_handler[obj->irq_src] = handler;
|
||||
// Save irq id
|
||||
channel_ids[obj->irq_src] = id;
|
||||
// Initialize interrupt event as both edges detection
|
||||
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
|
||||
// Clear gpio pending interrupt
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
|
||||
// Set interrupt event and enable INTx clear
|
||||
CG_SetSTBYReleaseINTSrc(obj->irq_src, (CG_INTActiveState)obj->event, ENABLE);
|
||||
core_util_critical_section_exit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gpio_irq_free(gpio_irq_t *obj)
|
||||
{
|
||||
// Clear gpio_irq
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
|
||||
// Reset interrupt handler
|
||||
hal_irq_handler[obj->irq_src] = NULL;
|
||||
// Reset interrupt id
|
||||
channel_ids[obj->irq_src] = 0;
|
||||
}
|
||||
|
||||
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||
{
|
||||
// Disable GPIO interrupt on obj
|
||||
gpio_irq_disable(obj);
|
||||
|
||||
if (enable) {
|
||||
// Get gpio interrupt event
|
||||
if (event == IRQ_RISE) {
|
||||
if ((obj->event == CG_INT_ACTIVE_STATE_FALLING) ||
|
||||
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
|
||||
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
|
||||
} else {
|
||||
obj->event = CG_INT_ACTIVE_STATE_RISING;
|
||||
}
|
||||
} else if (event == IRQ_FALL) {
|
||||
if ((obj->event == CG_INT_ACTIVE_STATE_RISING) ||
|
||||
(obj->event == CG_INT_ACTIVE_STATE_BOTH_EDGES)) {
|
||||
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
|
||||
} else {
|
||||
obj->event = CG_INT_ACTIVE_STATE_FALLING;
|
||||
}
|
||||
} else {
|
||||
error("Not supported event\n");
|
||||
}
|
||||
} else {
|
||||
// Get gpio interrupt event
|
||||
if (event == IRQ_RISE) {
|
||||
if ((obj->event == CG_INT_ACTIVE_STATE_RISING) ||
|
||||
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
|
||||
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
|
||||
} else {
|
||||
obj->event = CG_INT_ACTIVE_STATE_FALLING;
|
||||
}
|
||||
} else if (event == IRQ_FALL) {
|
||||
if ((obj->event == CG_INT_ACTIVE_STATE_FALLING) ||
|
||||
(obj->event == CG_INT_ACTIVE_STATE_INVALID)) {
|
||||
obj->event = CG_INT_ACTIVE_STATE_BOTH_EDGES;
|
||||
} else {
|
||||
obj->event = CG_INT_ACTIVE_STATE_RISING;
|
||||
}
|
||||
} else {
|
||||
error("Not supported event\n");
|
||||
}
|
||||
}
|
||||
|
||||
CurrentState = obj->event;
|
||||
if (obj->event != CG_INT_ACTIVE_STATE_INVALID ) {
|
||||
// Set interrupt event and enable INTx clear
|
||||
CG_SetSTBYReleaseINTSrc(obj->irq_src, (CG_INTActiveState)obj->event, ENABLE);
|
||||
gpio_write_bit(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)obj->pin_num, GPIO_Mode_DATA, 0);
|
||||
} else {
|
||||
gpio_write_bit(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)obj->pin_num, GPIO_Mode_DATA, 1);
|
||||
}
|
||||
|
||||
// Clear interrupt request
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
|
||||
// Enable GPIO interrupt on obj
|
||||
gpio_irq_enable(obj);
|
||||
}
|
||||
|
||||
void gpio_irq_enable(gpio_irq_t *obj)
|
||||
{
|
||||
// Clear and Enable gpio_irq object
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
|
||||
NVIC_EnableIRQ((IRQn_Type)obj->irq_id);
|
||||
}
|
||||
|
||||
void gpio_irq_disable(gpio_irq_t *obj)
|
||||
{
|
||||
// Disable gpio_irq object
|
||||
NVIC_DisableIRQ((IRQn_Type)obj->irq_id);
|
||||
}
|
||||
|
||||
static void INT_IRQHandler(PinName pin, uint32_t index)
|
||||
{
|
||||
PortName port;
|
||||
uint8_t pin_num;
|
||||
|
||||
gpio_pinstate_t data = GPIO_PIN_RESET;
|
||||
pin_num = PIN_POS(pin);
|
||||
port = (PortName)PIN_PORT(pin);
|
||||
|
||||
// Clear interrupt request
|
||||
CG_SetSTBYReleaseINTSrc((CG_INTSrc)(CG_INT_SRC_0 + index), CurrentState, DISABLE);
|
||||
// Get pin value
|
||||
gpio_read_bit(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)pin_num, GPIO_Mode_DATA, &data);
|
||||
|
||||
switch (data) {
|
||||
// Falling edge detection
|
||||
case 0:
|
||||
hal_irq_handler[index](channel_ids[index], IRQ_FALL);
|
||||
break;
|
||||
// Rising edge detection
|
||||
case 1:
|
||||
hal_irq_handler[index](channel_ids[index], IRQ_RISE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Clear gpio pending interrupt
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)(CG_INT_SRC_0 + index));
|
||||
// Enable interrupt request
|
||||
CG_SetSTBYReleaseINTSrc((CG_INTSrc)(CG_INT_SRC_0 + index), CurrentState, ENABLE);
|
||||
}
|
||||
|
||||
static void CG_SetSTBYReleaseINTSrc(CG_INTSrc INTSource, CG_INTActiveState ActiveState, uint8_t NewState)
|
||||
{
|
||||
uint8_t *ptr = ((uint8_t *)(&(TSB_IA->IMC00)) + (INTSource * 2));
|
||||
// Clear pending falling and rising edge bit
|
||||
*ptr = CLR_INT_FLAG;
|
||||
*ptr = (ActiveState | NewState);
|
||||
{
|
||||
uint8_t regval = *ptr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "txz_gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t pin_num;
|
||||
uint32_t mask;
|
||||
PinName pin;
|
||||
PortName port;
|
||||
} gpio_t;
|
||||
|
||||
typedef enum {
|
||||
CG_INT_SRC_0 = 0U,
|
||||
CG_INT_SRC_1,
|
||||
CG_INT_SRC_2,
|
||||
CG_INT_SRC_3,
|
||||
CG_INT_SRC_4,
|
||||
CG_INT_SRC_5,
|
||||
CG_INT_SRC_6,
|
||||
CG_INT_SRC_7,
|
||||
CG_INT_SRC_8,
|
||||
CG_INT_SRC_9,
|
||||
CG_INT_SRC_A,
|
||||
CG_INT_SRC_B,
|
||||
CG_INT_SRC_C,
|
||||
CG_INT_SRC_D,
|
||||
CG_INT_SRC_E,
|
||||
CG_INT_SRC_F
|
||||
} CG_INTSrc;
|
||||
|
||||
typedef enum {
|
||||
CG_INT_ACTIVE_STATE_L = 0x00U,
|
||||
CG_INT_ACTIVE_STATE_H = 0x02U,
|
||||
CG_INT_ACTIVE_STATE_FALLING = 0x04U,
|
||||
CG_INT_ACTIVE_STATE_RISING = 0x06U,
|
||||
CG_INT_ACTIVE_STATE_BOTH_EDGES = 0x08U,
|
||||
CG_INT_ACTIVE_STATE_INVALID = 0x0AU
|
||||
} CG_INTActiveState;
|
||||
|
||||
static inline int gpio_is_connected(const gpio_t *obj)
|
||||
{
|
||||
return (obj->pin != (PinName)NC);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,203 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "i2c_api.h"
|
||||
#include "mbed_error.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "pinmap.h"
|
||||
#include "txz_i2c_api.h"
|
||||
|
||||
#define MAX_I2C_FREQ 1000000
|
||||
|
||||
static const PinMap PinMap_I2C_SDA[] = {
|
||||
{PG2, I2C_0, PIN_DATA(7, 2)},
|
||||
{PF2, I2C_1, PIN_DATA(7, 2)},
|
||||
{PG4, I2C_2, PIN_DATA(7, 2)},
|
||||
{PJ6, I2C_3, PIN_DATA(7, 2)},
|
||||
{PJ3, I2C_4, PIN_DATA(7, 2)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_I2C_SCL[] = {
|
||||
{PG3, I2C_0, PIN_DATA(7, 2)},
|
||||
{PF3, I2C_1, PIN_DATA(7, 2)},
|
||||
{PG5, I2C_2, PIN_DATA(7, 2)},
|
||||
{PJ7, I2C_3, PIN_DATA(7, 2)},
|
||||
{PJ2, I2C_4, PIN_DATA(7, 2)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
// Initialize the I2C peripheral. It sets the default parameters for I2C
|
||||
void i2c_init(i2c_t *obj, PinName sda, PinName scl)
|
||||
{
|
||||
MBED_ASSERT(obj != NULL);
|
||||
|
||||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
I2CName i2c_name = (I2CName)pinmap_merge(i2c_sda, i2c_scl);
|
||||
|
||||
MBED_ASSERT((int)i2c_name != NC);
|
||||
|
||||
switch (i2c_name) {
|
||||
case I2C_0:
|
||||
TSB_CG_FSYSMENA_IPMENA29 = TXZ_ENABLE; // Enable clock for I2C_0
|
||||
TSB_CG_FSYSMENB_IPMENB08 = TXZ_ENABLE; // Enable clock for GPIO G
|
||||
obj->my_i2c.i2c.p_instance = TSB_I2C0;
|
||||
obj->my_i2c.info.irqn = INTI2C0_IRQn;
|
||||
break;
|
||||
case I2C_1:
|
||||
TSB_CG_FSYSMENA_IPMENA30 = TXZ_ENABLE; // Enable clock for I2C_1
|
||||
TSB_CG_FSYSMENB_IPMENB07 = TXZ_ENABLE; // Enable clock for GPIO F
|
||||
obj->my_i2c.i2c.p_instance = TSB_I2C1;
|
||||
obj->my_i2c.info.irqn = INTI2C1_IRQn;
|
||||
break;
|
||||
case I2C_2:
|
||||
TSB_CG_FSYSMENA_IPMENA31 = TXZ_ENABLE; // Enable clock for I2C_2
|
||||
TSB_CG_FSYSMENB_IPMENB08 = TXZ_ENABLE; // Enable clock for GPIO G
|
||||
obj->my_i2c.i2c.p_instance = TSB_I2C2;
|
||||
obj->my_i2c.info.irqn = INTI2C2_IRQn;
|
||||
break;
|
||||
case I2C_3:
|
||||
TSB_CG_FSYSMENB_IPMENB00 = TXZ_ENABLE; // Enable clock for I2C_3
|
||||
TSB_CG_FSYSMENB_IPMENB10 = TXZ_ENABLE; // Enable clock for GPIO J
|
||||
obj->my_i2c.i2c.p_instance = TSB_I2C3;
|
||||
obj->my_i2c.info.irqn = INTI2C3_IRQn;
|
||||
break;
|
||||
case I2C_4:
|
||||
TSB_CG_FSYSMENB_IPMENB01 = TXZ_ENABLE; // Enable clock for I2C_4
|
||||
TSB_CG_FSYSMENB_IPMENB10 = TXZ_ENABLE; // Enable clock for GPIO J
|
||||
obj->my_i2c.i2c.p_instance = TSB_I2C4;
|
||||
obj->my_i2c.info.irqn = INTI2C4_IRQn;
|
||||
break;
|
||||
default:
|
||||
error("I2C is not available");
|
||||
break;
|
||||
}
|
||||
|
||||
pinmap_pinout(sda, PinMap_I2C_SDA);
|
||||
pin_mode(sda, OpenDrain);
|
||||
pin_mode(sda, PullUp);
|
||||
|
||||
pinmap_pinout(scl, PinMap_I2C_SCL);
|
||||
pin_mode(scl, OpenDrain);
|
||||
pin_mode(scl, PullUp);
|
||||
|
||||
i2c_reset(obj);
|
||||
i2c_frequency(obj, 100000);
|
||||
I2C_init(&obj->my_i2c.i2c);
|
||||
}
|
||||
|
||||
// Configure the I2C frequency
|
||||
void i2c_frequency(i2c_t *obj, int hz)
|
||||
{
|
||||
if (hz <= MAX_I2C_FREQ) {
|
||||
i2c_frequency_t(&obj->my_i2c, hz);
|
||||
} else {
|
||||
error("Failed : Max I2C frequency is 1000000");
|
||||
}
|
||||
}
|
||||
|
||||
int i2c_start(i2c_t *obj)
|
||||
{
|
||||
i2c_start_t(&obj->my_i2c);
|
||||
return TXZ_SUCCESS;
|
||||
}
|
||||
|
||||
int i2c_stop(i2c_t *obj)
|
||||
{
|
||||
i2c_stop_t(&obj->my_i2c);
|
||||
return TXZ_SUCCESS;
|
||||
}
|
||||
|
||||
void i2c_reset(i2c_t *obj)
|
||||
{
|
||||
// Software reset
|
||||
i2c_reset_t(&obj->my_i2c);
|
||||
}
|
||||
|
||||
int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
|
||||
{
|
||||
int32_t count = 0;
|
||||
|
||||
count = i2c_read_t(&obj->my_i2c, address, (uint8_t *)data, length, stop);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
|
||||
{
|
||||
int32_t count = 0;
|
||||
|
||||
count = i2c_write_t(&obj->my_i2c, address, (uint8_t *)data, length, stop);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int i2c_byte_read(i2c_t *obj, int last)
|
||||
{
|
||||
int32_t data = 0;
|
||||
|
||||
data = i2c_byte_read_t(&obj->my_i2c, last);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int i2c_byte_write(i2c_t *obj, int data)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
result = i2c_byte_write_t(&obj->my_i2c, data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void i2c_slave_mode(i2c_t *obj, int enable_slave)
|
||||
{
|
||||
i2c_slave_mode_t(&obj->my_i2c, enable_slave);
|
||||
}
|
||||
|
||||
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask)
|
||||
{
|
||||
i2c_slave_address_t(&obj->my_i2c, address);
|
||||
}
|
||||
|
||||
int i2c_slave_receive(i2c_t *obj)
|
||||
{
|
||||
int32_t result = 0;
|
||||
|
||||
result = i2c_slave_receive_t(&obj->my_i2c);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int i2c_slave_read(i2c_t *obj, char *data, int length)
|
||||
{
|
||||
int32_t count = 0;
|
||||
|
||||
count = i2c_slave_read_t(&obj->my_i2c, (uint8_t *)data, length);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int i2c_slave_write(i2c_t *obj, const char *data, int length)
|
||||
{
|
||||
int32_t count = 0;
|
||||
|
||||
count = i2c_slave_write_t(&obj->my_i2c, (uint8_t *)data, length);
|
||||
|
||||
return count;
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_OBJECTS_H
|
||||
#define MBED_OBJECTS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "PortNames.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "gpio_object.h"
|
||||
#include "txz_gpio.h"
|
||||
#include "txz_uart.h"
|
||||
#include "txz_fuart.h"
|
||||
#include "txz_tspi.h"
|
||||
#include "txz_t32a.h"
|
||||
#include "txz_cg.h"
|
||||
#include "txz_driver_def.h"
|
||||
#include "adc.h"
|
||||
#include "txz_i2c_api.h"
|
||||
#include "txz_i2c.h"
|
||||
#include "txz_fuart_include.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct port_s {
|
||||
uint32_t mask;
|
||||
PortName port;
|
||||
};
|
||||
|
||||
struct dac_s {
|
||||
DACName dac;
|
||||
TSB_DA_TypeDef *DACx;
|
||||
};
|
||||
|
||||
struct serial_s {
|
||||
uint32_t index;
|
||||
uint32_t mode;
|
||||
TSB_UART_TypeDef *UARTx;
|
||||
TSB_FURT_TypeDef *FUARTx;
|
||||
uart_boudrate_t boud_obj;
|
||||
fuart_boudrate_t fboud_obj;
|
||||
};
|
||||
|
||||
struct pwmout_s {
|
||||
uint32_t divisor;
|
||||
uint32_t type;
|
||||
uint32_t trailing_timing;
|
||||
uint32_t leading_timing;
|
||||
float period;
|
||||
t32a_t p_t32a;
|
||||
PinName pin;
|
||||
};
|
||||
|
||||
struct spi_s {
|
||||
uint8_t bits;
|
||||
tspi_t p_obj;
|
||||
SPIName module;
|
||||
};
|
||||
|
||||
struct gpio_irq_s {
|
||||
PortName port;
|
||||
uint8_t pin_num;
|
||||
uint32_t irq_id;
|
||||
CG_INTSrc irq_src;
|
||||
CG_INTActiveState event;
|
||||
};
|
||||
|
||||
struct flash_s {
|
||||
int flash_inited;
|
||||
};
|
||||
|
||||
struct analogin_s {
|
||||
adc_t p_adc;
|
||||
PinName pin;
|
||||
ADCName adc;
|
||||
adc_channel_setting_t param;
|
||||
};
|
||||
|
||||
struct i2c_s {
|
||||
int address;
|
||||
uint32_t index;
|
||||
_i2c_t my_i2c;
|
||||
};
|
||||
|
||||
#include "gpio_object.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,102 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "pinmap.h"
|
||||
#include "txz_gpio.h"
|
||||
|
||||
#define PIN_FUNC_MAX 8
|
||||
|
||||
extern _gpio_t gpio_port_add;
|
||||
|
||||
void pin_function(PinName pin, int function)
|
||||
{
|
||||
uint32_t port = 0;
|
||||
uint8_t bit = 0;
|
||||
uint8_t func = 0;
|
||||
uint8_t dir = 0;
|
||||
|
||||
// Assert that pin is valid
|
||||
MBED_ASSERT(pin != NC);
|
||||
|
||||
// Calculate pin function and pin direction
|
||||
func = PIN_FUNC(function);
|
||||
dir = PIN_DIR(function);
|
||||
// Calculate port and pin position
|
||||
port = PIN_PORT(pin);
|
||||
bit = PIN_POS(pin);
|
||||
|
||||
// Find function is in range or not
|
||||
if (func <= PIN_FUNC_MAX) {
|
||||
// Set pin function and direction if direction is in range
|
||||
switch (dir) {
|
||||
case PIN_INPUT:
|
||||
// Set pin input
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, (uint32_t)func, GPIO_PIN_INPUT);
|
||||
break;
|
||||
case PIN_OUTPUT:
|
||||
// Set pin output
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, (uint32_t)func, GPIO_PIN_OUTPUT);
|
||||
break;
|
||||
case PIN_INOUT:
|
||||
// Set pin both input and output
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, (uint32_t)func, GPIO_PIN_INOUT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode)
|
||||
{
|
||||
uint32_t port = 0;
|
||||
uint8_t bit = 0;
|
||||
|
||||
// Assert that pin is valid
|
||||
MBED_ASSERT(pin != NC);
|
||||
|
||||
// Check if function is in range
|
||||
if (mode > OpenDrain) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate port and pin position
|
||||
port = PIN_PORT(pin);
|
||||
bit = PIN_POS(pin);
|
||||
|
||||
// Set pin mode
|
||||
switch (mode) {
|
||||
case PullNone:
|
||||
gpio_SetPullUp(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_RESET);
|
||||
gpio_SetPullDown(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_RESET);
|
||||
gpio_SetOpenDrain(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_RESET);
|
||||
break;
|
||||
case PullUp:
|
||||
gpio_SetPullUp(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_SET);
|
||||
break;
|
||||
case PullDown:
|
||||
gpio_SetPullDown(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_SET);
|
||||
break;
|
||||
case OpenDrain:
|
||||
gpio_SetOpenDrain(&gpio_port_add, (gpio_gr_t)port, (gpio_num_t)bit, GPIO_PIN_SET);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "port_api.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "txz_gpio.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#define PORT_PIN_NUM (8)
|
||||
#define ALT_FUNC_GPIO (0)
|
||||
|
||||
extern _gpio_t gpio_port_add;
|
||||
static void gpio_pin_dir(port_t *obj, PinDirection dir, uint32_t pin_num);
|
||||
|
||||
PinName port_pin(PortName port, int pin_n)
|
||||
{
|
||||
PinName pin = NC;
|
||||
pin = (PinName)((port << 3) | pin_n);
|
||||
return pin;
|
||||
}
|
||||
|
||||
void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
// Assert that port is valid
|
||||
MBED_ASSERT(port <= PortY);
|
||||
|
||||
// Store port and port mask for future use
|
||||
obj->port = port;
|
||||
obj->mask = mask;
|
||||
|
||||
// Enable the clock for particular port
|
||||
_gpio_init(&gpio_port_add, obj->port);
|
||||
|
||||
// Set port function and port direction
|
||||
for (i = 0; i < PORT_PIN_NUM; i++) {
|
||||
// If the pin is used
|
||||
if (obj->mask & (1 << i)) {
|
||||
pin_function(port_pin(obj->port, i), dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void port_mode(port_t *obj, PinMode mode)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
// Assert that port is valid
|
||||
MBED_ASSERT(obj->port <= PortY);
|
||||
|
||||
// Set mode for masked pins
|
||||
for (i = 0; i < PORT_PIN_NUM; i++) {
|
||||
// If the pin is used
|
||||
if (obj->mask & (1 << i)) {
|
||||
pin_mode(port_pin(obj->port, i), mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void port_dir(port_t *obj, PinDirection dir)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
// Assert that port is valid
|
||||
MBED_ASSERT(obj->port <= PortY);
|
||||
|
||||
for (i = 0; i < PORT_PIN_NUM; i++) {
|
||||
// Set direction for masked pins
|
||||
if (obj->mask & (1 << i)) {
|
||||
gpio_pin_dir(obj, dir, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void port_write(port_t *obj, int value)
|
||||
{
|
||||
uint32_t port_data = 0;
|
||||
uint32_t data = 0;
|
||||
|
||||
// Assert that port is valid
|
||||
MBED_ASSERT(obj->port <= PortY);
|
||||
|
||||
// Get current data of port
|
||||
gpio_read_mode(&gpio_port_add, obj->port, GPIO_Mode_DATA, &port_data);
|
||||
|
||||
// Calculate data to write to masked pins
|
||||
data = (port_data & ~obj->mask) | (value & obj->mask);
|
||||
|
||||
// Write data to masked pins of the port
|
||||
gpio_write_mode(&gpio_port_add, obj->port, GPIO_Mode_DATA, data);
|
||||
}
|
||||
|
||||
int port_read(port_t *obj)
|
||||
{
|
||||
uint32_t port_data = 0;
|
||||
uint32_t data = 0;
|
||||
|
||||
// Assert that port is valid
|
||||
MBED_ASSERT(obj->port <= PortY);
|
||||
|
||||
// Get current data of port
|
||||
gpio_read_mode(&gpio_port_add, obj->port, GPIO_Mode_DATA, &port_data);
|
||||
|
||||
// Calculate data of masked pins
|
||||
data = port_data & obj->mask;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void gpio_pin_dir(port_t *obj, PinDirection dir, uint32_t pin_num)
|
||||
{
|
||||
switch (dir) {
|
||||
case PIN_INPUT:
|
||||
// Set pin input
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)pin_num, (uint32_t)ALT_FUNC_GPIO, GPIO_PIN_INPUT);
|
||||
break;
|
||||
case PIN_OUTPUT:
|
||||
// Set pin output
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)pin_num, (uint32_t)ALT_FUNC_GPIO, GPIO_PIN_OUTPUT);
|
||||
break;
|
||||
case PIN_INOUT:
|
||||
// Set pin both input and output
|
||||
gpio_func(&gpio_port_add, (gpio_gr_t)obj->port, (gpio_num_t)pin_num, (uint32_t)ALT_FUNC_GPIO, GPIO_PIN_INOUT);
|
||||
break;
|
||||
default:
|
||||
// error("Invalid direction\n");
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "pwmout_api.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#define GPIO_CLK_OFFSET 2
|
||||
// Because Timer operating frequency is 2.5 MhZ
|
||||
#define CALCULATE_RGC1_VAL 2.5
|
||||
|
||||
static const PinMap PinMap_PWM[] = {
|
||||
{PA5, PWM_0, PIN_DATA(5, 1)},
|
||||
{PB2, PWM_1, PIN_DATA(5, 1)},
|
||||
{PB4, PWM_2, PIN_DATA(5, 1)},
|
||||
{PD2, PWM_3, PIN_DATA(5, 1)},
|
||||
{PD4, PWM_4, PIN_DATA(5, 1)},
|
||||
{PE1, PWM_5, PIN_DATA(5, 1)},
|
||||
{PE6, PWM_6, PIN_DATA(5, 1)},
|
||||
{PC2, PWM_7, PIN_DATA(5, 1)},
|
||||
{PL6, PWM_8, PIN_DATA(3, 1)},
|
||||
{PC4, PWM_9, PIN_DATA(5, 1)},
|
||||
{PM2, PWM_10, PIN_DATA(3, 1)},
|
||||
{PU0, PWM_11, PIN_DATA(3, 1)},
|
||||
{PU6, PWM_12, PIN_DATA(3, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
void pwmout_init(pwmout_t *obj, PinName pin)
|
||||
{
|
||||
// Determine the pwm channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
|
||||
// Assert input is valid
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
switch (pwm) {
|
||||
case PWM_0:
|
||||
obj->p_t32a.p_instance = TSB_T32A1;
|
||||
// Clock enable of T32A ch01
|
||||
TSB_CG_FSYSMENA_IPMENA07 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_1:
|
||||
obj->p_t32a.p_instance = TSB_T32A2;
|
||||
// Clock enable of T32A ch02
|
||||
TSB_CG_FSYSMENA_IPMENA08 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_2:
|
||||
obj->p_t32a.p_instance = TSB_T32A3;
|
||||
// Clock enable of T32A ch03
|
||||
TSB_CG_FSYSMENA_IPMENA09 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_3:
|
||||
obj->p_t32a.p_instance = TSB_T32A4;
|
||||
// Clock enable of T32A ch04
|
||||
TSB_CG_FSYSMENA_IPMENA10 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_4:
|
||||
obj->p_t32a.p_instance = TSB_T32A5;
|
||||
// Clock enable of T32A ch05
|
||||
TSB_CG_FSYSMENA_IPMENA11 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_5:
|
||||
obj->p_t32a.p_instance = TSB_T32A6;
|
||||
// Clock enable of T32A ch06
|
||||
TSB_CG_FSYSMENA_IPMENA12 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_6:
|
||||
obj->p_t32a.p_instance = TSB_T32A7;
|
||||
// Clock enable of T32A ch07
|
||||
TSB_CG_FSYSMENA_IPMENA13 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_7:
|
||||
obj->p_t32a.p_instance = TSB_T32A8;
|
||||
// Clock enable of T32A ch08
|
||||
TSB_CG_FSYSMENA_IPMENA14 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_8:
|
||||
obj->p_t32a.p_instance = TSB_T32A9;
|
||||
// Clock enable of T32A ch09
|
||||
TSB_CG_FSYSMENA_IPMENA15 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_9:
|
||||
obj->p_t32a.p_instance = TSB_T32A10;
|
||||
// Clock enable of T32A ch10
|
||||
TSB_CG_FSYSMENA_IPMENA16 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_10:
|
||||
obj->p_t32a.p_instance = TSB_T32A11;
|
||||
// Clock enable of T32A ch11
|
||||
TSB_CG_FSYSMENA_IPMENA17 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_11:
|
||||
obj->p_t32a.p_instance = TSB_T32A12;
|
||||
// Clock enable of T32A ch12
|
||||
TSB_CG_FSYSMENA_IPMENA18 = TXZ_ENABLE;
|
||||
break;
|
||||
case PWM_12:
|
||||
obj->p_t32a.p_instance = TSB_T32A13;
|
||||
// Clock enable of T32A ch13
|
||||
TSB_CG_FSYSMENA_IPMENA19 = TXZ_ENABLE;
|
||||
break;
|
||||
default:
|
||||
obj->p_t32a.p_instance = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (obj->p_t32a.p_instance == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable clock for GPIO port.
|
||||
TSB_CG->FSYSMENB |= (TXZ_ENABLE << ((PIN_PORT(pin)) + GPIO_CLK_OFFSET));
|
||||
|
||||
// Set pin function as PWM
|
||||
pinmap_pinout(pin, PinMap_PWM);
|
||||
|
||||
// Default to 20ms, 0% duty cycle
|
||||
pwmout_period_ms(obj, 20);
|
||||
}
|
||||
|
||||
void pwmout_free(pwmout_t *obj)
|
||||
{
|
||||
// Stop PWM
|
||||
obj->p_t32a.p_instance->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_STOP);
|
||||
obj->trailing_timing = TXZ_DISABLE;
|
||||
obj->leading_timing = TXZ_DISABLE;
|
||||
obj->p_t32a.p_instance = NULL;
|
||||
}
|
||||
|
||||
void pwmout_write(pwmout_t *obj, float value)
|
||||
{
|
||||
// Stop PWM
|
||||
obj->p_t32a.p_instance->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_STOP);
|
||||
|
||||
if (value <= 0.0f) {
|
||||
value = TXZ_DISABLE;
|
||||
} else if (value >= 1.0f) {
|
||||
value = TXZ_ENABLE;
|
||||
}
|
||||
|
||||
// Store the new leading_timing value
|
||||
obj->leading_timing = obj->trailing_timing - (obj->trailing_timing * value);
|
||||
|
||||
// Setting T32A_RGA0 register
|
||||
obj->p_t32a.p_instance->RGC0 = obj->leading_timing;
|
||||
|
||||
// Start PWM
|
||||
obj->p_t32a.p_instance->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_START);
|
||||
}
|
||||
|
||||
float pwmout_read(pwmout_t *obj)
|
||||
{
|
||||
float duty_cycle = (float)(obj->trailing_timing - obj->leading_timing) / obj->trailing_timing;
|
||||
return duty_cycle;
|
||||
}
|
||||
|
||||
void pwmout_period(pwmout_t *obj, float seconds)
|
||||
{
|
||||
pwmout_period_us(obj, (int)(seconds * 1000000.0f));
|
||||
}
|
||||
|
||||
void pwmout_period_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
pwmout_period_us(obj, (ms * 1000));
|
||||
}
|
||||
|
||||
// Set the PWM period, keeping the duty cycle the same.
|
||||
void pwmout_period_us(pwmout_t *obj, int us)
|
||||
{
|
||||
uint32_t prscl = 0;
|
||||
float duty_cycle = 0;
|
||||
float seconds = (float)((us) / 1000000.0f);
|
||||
|
||||
obj->period = seconds;
|
||||
// Restore the duty-cycle
|
||||
duty_cycle = ((float)(obj->trailing_timing - obj->leading_timing) / obj->trailing_timing);
|
||||
prscl = T32A_PRSCLx_32;
|
||||
|
||||
obj->trailing_timing = (us * CALCULATE_RGC1_VAL);
|
||||
obj->leading_timing = ((obj->trailing_timing)- (obj->trailing_timing * duty_cycle));
|
||||
|
||||
obj->p_t32a.p_instance->MOD = T32A_MODE_32;
|
||||
obj->p_t32a.p_instance->RUNC = (T32A_RUN_DISABLE | T32A_COUNT_STOP);
|
||||
obj->p_t32a.p_instance->CRC = (prscl | T32A_RELOAD_TREGx);
|
||||
obj->p_t32a.p_instance->IMC = (T32A_IMUFx_MASK_REQ | T32A_IMOFx_MASK_REQ |
|
||||
T32A_IMx1_MASK_REQ | T32A_IMx0_MASK_REQ);
|
||||
obj->p_t32a.p_instance->RGC0 = obj->leading_timing;
|
||||
obj->p_t32a.p_instance->RGC1 = obj->trailing_timing;
|
||||
obj->p_t32a.p_instance->OUTCRC0 = T32A_OCR_DISABLE;
|
||||
obj->p_t32a.p_instance->OUTCRC1 = (T32A_OCRCMPx1_CLR | T32A_OCRCMPx0_SET);
|
||||
obj->p_t32a.p_instance->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_START);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
|
||||
{
|
||||
pwmout_pulsewidth_us(obj, (seconds * 1000000.0f));
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
pwmout_pulsewidth_us(obj, (ms * 1000));
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
|
||||
{
|
||||
float seconds = 0;
|
||||
float value = 0;
|
||||
|
||||
seconds = (float)(us / 1000000.0f);
|
||||
value = (((seconds / obj->period) * 100.0f) / 100.0f);
|
||||
pwmout_write(obj, value);
|
||||
}
|
|
@ -0,0 +1,399 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "mbed_error.h"
|
||||
#include "serial_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#define UART_NUM 8
|
||||
#define UART_ENABLE_RX ((uint32_t)0x00000001)
|
||||
#define UART_ENABLE_TX ((uint32_t)0x00000002)
|
||||
#define UARTxFIFOCLR_TFCLR_CLEAR ((uint32_t)0x00000002)
|
||||
#define UARTxFIFOCLR_RFCLR_CLEAR ((uint32_t)0x00000001)
|
||||
#define UARTxSWRST_SWRSTF_MASK ((uint32_t)0x00000080)
|
||||
#define UARTxSWRST_SWRSTF_RUN ((uint32_t)0x00000080)
|
||||
#define UARTxSWRST_SWRST_10 ((uint32_t)0x00000002)
|
||||
#define UARTxSWRST_SWRST_01 ((uint32_t)0x00000001)
|
||||
#define UART_RX_FIFO_FILL_LEVEL ((uint32_t)0x00000100)
|
||||
#define FUART_ENABLE_RX ((uint32_t)0x00000200)
|
||||
#define FUART_ENABLE_TX ((uint32_t)0x00000100)
|
||||
#define BAUDRATE_DEFAULT (9600)
|
||||
#define CLR_REGISTER (0x00)
|
||||
|
||||
static const PinMap PinMap_UART_TX[] = {
|
||||
{PE3, SERIAL_0, PIN_DATA(7, 1)},
|
||||
{PH1, SERIAL_1, PIN_DATA(3, 1)},
|
||||
{PG1, SERIAL_2, PIN_DATA(3, 1)},
|
||||
{PU7, SERIAL_3, PIN_DATA(7, 1)},
|
||||
{PU0, SERIAL_4, PIN_DATA(7, 1)},
|
||||
{PJ1, SERIAL_5, PIN_DATA(3, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_UART_RX[] = {
|
||||
{PE2, SERIAL_0, PIN_DATA(7, 0)},
|
||||
{PH0, SERIAL_1, PIN_DATA(3, 0)},
|
||||
{PG0, SERIAL_2, PIN_DATA(3, 0)},
|
||||
{PU6, SERIAL_3, PIN_DATA(7, 0)},
|
||||
{PU1, SERIAL_4, PIN_DATA(7, 0)},
|
||||
{PJ0, SERIAL_5, PIN_DATA(3, 0)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static int serial_irq_ids[UART_NUM] = {0};
|
||||
static uart_irq_handler irq_handler;
|
||||
|
||||
int stdio_uart_inited = 0;
|
||||
serial_t stdio_uart;
|
||||
|
||||
static void uart_swreset(TSB_UART_TypeDef *UARTx);
|
||||
void serial_init(serial_t *obj, PinName tx, PinName rx)
|
||||
{
|
||||
int is_stdio_uart = 0;
|
||||
obj->mode = 0;
|
||||
cg_t paramCG;
|
||||
paramCG.p_instance = TSB_CG;
|
||||
uart_clock_t prescal = {0};
|
||||
|
||||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart_name = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
|
||||
MBED_ASSERT((int)uart_name != NC);
|
||||
|
||||
obj->index = uart_name;
|
||||
// Initialize UART instance
|
||||
switch (uart_name) {
|
||||
case SERIAL_0:
|
||||
obj->UARTx = TSB_UART0;
|
||||
// Enable clock for UART0 and Port E
|
||||
TSB_CG_FSYSMENA_IPMENA23 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB06 = TXZ_ENABLE;
|
||||
break;
|
||||
case SERIAL_1:
|
||||
obj->UARTx = TSB_UART1;
|
||||
// Enable clock for UART1 and Port H
|
||||
TSB_CG_FSYSMENA_IPMENA24 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB09 = TXZ_ENABLE;
|
||||
break;
|
||||
case SERIAL_2:
|
||||
obj->UARTx = TSB_UART2;
|
||||
// Enable clock for UART2 and Port G
|
||||
TSB_CG_FSYSMENA_IPMENA25 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB08 = TXZ_ENABLE;
|
||||
break;
|
||||
case SERIAL_3:
|
||||
obj->UARTx = TSB_UART3;
|
||||
// Enable clock for UART3 and Port U
|
||||
TSB_CG_FSYSMENA_IPMENA26 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB18 = TXZ_ENABLE;
|
||||
break;
|
||||
case SERIAL_4:
|
||||
obj->UARTx = TSB_UART4;
|
||||
// Enable clock for UART4 and Port U
|
||||
TSB_CG_FSYSMENA_IPMENA27 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB18 = TXZ_ENABLE;
|
||||
break;
|
||||
case SERIAL_5:
|
||||
obj->UARTx = TSB_UART5;
|
||||
// Enable clock for UART5 and Port J
|
||||
TSB_CG_FSYSMENA_IPMENA28 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB10 = TXZ_ENABLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Set alternate function
|
||||
pinmap_pinout(tx, PinMap_UART_TX);
|
||||
pinmap_pinout(rx, PinMap_UART_RX);
|
||||
|
||||
if (tx != NC && rx != NC) {
|
||||
obj->mode = UART_ENABLE_RX | UART_ENABLE_TX;
|
||||
} else {
|
||||
if (tx != NC) {
|
||||
obj->mode = UART_ENABLE_TX;
|
||||
} else {
|
||||
if (rx != NC) {
|
||||
obj->mode = UART_ENABLE_RX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Software reset
|
||||
uart_swreset(obj->UARTx);
|
||||
|
||||
// Mbed default configurations
|
||||
obj->UARTx->CR0 |= (1U); // Data lengh 8 bit No parity one stop bit
|
||||
prescal.prsel = UART_PLESCALER_1;
|
||||
uart_get_boudrate_setting(cg_get_mphyt0(¶mCG), &prescal, BAUDRATE_DEFAULT, &obj->boud_obj);
|
||||
|
||||
obj->UARTx->BRD |= ((obj->boud_obj.ken) | (obj->boud_obj.brk << 16) | (obj->boud_obj.brn));
|
||||
obj->UARTx->FIFOCLR = (UARTxFIFOCLR_TFCLR_CLEAR | UARTxFIFOCLR_RFCLR_CLEAR); // Clear FIFO
|
||||
obj->UARTx->TRANS |= obj->mode; // Enable TX RX block.
|
||||
obj->UARTx->CR1 = (UART_RX_FIFO_FILL_LEVEL | UART_TX_INT_ENABLE | UART_RX_INT_ENABLE);
|
||||
|
||||
is_stdio_uart = (uart_name == STDIO_UART) ? (1) : (0);
|
||||
if (is_stdio_uart) {
|
||||
stdio_uart_inited = 1;
|
||||
memcpy(&stdio_uart, obj, sizeof(serial_t));
|
||||
}
|
||||
}
|
||||
|
||||
void serial_free(serial_t *obj)
|
||||
{
|
||||
obj->UARTx->TRANS = CLR_REGISTER;
|
||||
obj->UARTx->CR0 = CLR_REGISTER;
|
||||
obj->UARTx->CR1 = CLR_REGISTER;
|
||||
obj->UARTx = CLR_REGISTER;
|
||||
uart_swreset(obj->UARTx);
|
||||
obj->index = (uint32_t)NC;
|
||||
}
|
||||
|
||||
void serial_baud(serial_t *obj, int baudrate)
|
||||
{
|
||||
cg_t paramCG;
|
||||
paramCG.p_instance = TSB_CG;
|
||||
uart_clock_t prescal;
|
||||
prescal.prsel = UART_PLESCALER_1;
|
||||
uart_get_boudrate_setting(cg_get_mphyt0(¶mCG), &prescal, baudrate, &obj->boud_obj);
|
||||
obj->UARTx->BRD = CLR_REGISTER; // Clear BRD register
|
||||
obj->UARTx->BRD |= ((obj->boud_obj.ken) | (obj->boud_obj.brk << 16) | (obj->boud_obj.brn));
|
||||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
|
||||
{
|
||||
uint32_t parity_check = 0;
|
||||
uint32_t data_length = 0;
|
||||
uint32_t tmp = 0;
|
||||
uint32_t sblen = 0;
|
||||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2));
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven));
|
||||
MBED_ASSERT((data_bits > 6) && (data_bits < 10)); // 0: 7 data bits ... 2: 9 data bits
|
||||
|
||||
parity_check = ((parity == ParityOdd) ? 1 :((parity == ParityEven) ? 3 : 0));
|
||||
data_length = (data_bits == 8 ? 1 :((data_bits == 7) ? 0 : 2));
|
||||
sblen = (stop_bits == 1) ? 0 : 1; // 0: 1 stop bits, 1: 2 stop bits
|
||||
tmp = ((sblen << 4) |(parity_check << 2) | data_length);
|
||||
obj->UARTx->CR0 = tmp;
|
||||
}
|
||||
|
||||
// INTERRUPT HANDLING
|
||||
void INTUART0RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_0], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART0TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_0], TxIrq);
|
||||
}
|
||||
|
||||
void INTUART1RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_1], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART1TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_1], TxIrq);
|
||||
}
|
||||
|
||||
void INTUART2RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_2], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART2TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_2], TxIrq);
|
||||
}
|
||||
|
||||
void INTUART3RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_3], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART3TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_3], TxIrq);
|
||||
}
|
||||
|
||||
void INTUART4RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_4], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART4TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_4], TxIrq);
|
||||
}
|
||||
|
||||
void INTUART5RX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_5], RxIrq);
|
||||
}
|
||||
|
||||
void INTUART5TX_IRQHandler(void)
|
||||
{
|
||||
irq_handler(serial_irq_ids[SERIAL_5], TxIrq);
|
||||
}
|
||||
|
||||
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
|
||||
{
|
||||
irq_handler = handler;
|
||||
serial_irq_ids[obj->index] = id;
|
||||
}
|
||||
|
||||
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
|
||||
{
|
||||
IRQn_Type irq_n = (IRQn_Type)0;
|
||||
|
||||
switch (obj->index) {
|
||||
case SERIAL_0:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART0RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART0TX_IRQn;
|
||||
}
|
||||
break;
|
||||
case SERIAL_1:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART1RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART1TX_IRQn;
|
||||
}
|
||||
break;
|
||||
case SERIAL_2:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART2RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART2TX_IRQn;
|
||||
}
|
||||
break;
|
||||
case SERIAL_3:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART3RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART3TX_IRQn;
|
||||
}
|
||||
break;
|
||||
case SERIAL_4:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART4RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART4TX_IRQn;
|
||||
}
|
||||
break;
|
||||
case SERIAL_5:
|
||||
if (irq == RxIrq) {
|
||||
irq_n = INTUART5RX_IRQn;
|
||||
} else {
|
||||
irq_n = INTUART5TX_IRQn;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ(irq_n);
|
||||
|
||||
if (enable) {
|
||||
NVIC_EnableIRQ(irq_n);
|
||||
} else {
|
||||
NVIC_DisableIRQ(irq_n);
|
||||
}
|
||||
}
|
||||
|
||||
int serial_getc(serial_t *obj)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
while (!serial_readable(obj)) { // Wait until Rx buffer is full
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Read Data Register
|
||||
data = (obj->UARTx->DR & 0xFFU);
|
||||
obj->UARTx->SR |= (1U << 6); // Clear RXEND flag
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void serial_putc(serial_t *obj, int c)
|
||||
{
|
||||
while (!serial_writable(obj)) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Write Data Register
|
||||
obj->UARTx->DR = (c & 0xFF);
|
||||
|
||||
while ((obj->UARTx->SR & (1U << 14)) == 0) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
obj->UARTx->SR |= (1U << 14); // Clear TXEND flag
|
||||
}
|
||||
|
||||
int serial_readable(serial_t *obj)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((obj->UARTx->SR & 0x000F) != 0) {
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int serial_writable(serial_t *obj)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((obj->UARTx->SR & 0x8000) == 0) {
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Pause transmission
|
||||
void serial_break_set(serial_t *obj)
|
||||
{
|
||||
obj->UARTx->TRANS |= 0x08;
|
||||
}
|
||||
|
||||
// Switch to normal transmission
|
||||
void serial_break_clear(serial_t *obj)
|
||||
{
|
||||
obj->UARTx->TRANS &= ~(0x08);
|
||||
}
|
||||
|
||||
static void uart_swreset(TSB_UART_TypeDef *UARTx)
|
||||
{
|
||||
while (((UARTx->SWRST) & UARTxSWRST_SWRSTF_MASK) == UARTxSWRST_SWRSTF_RUN) {
|
||||
// No process
|
||||
}
|
||||
|
||||
UARTx->SWRST = UARTxSWRST_SWRST_10;
|
||||
UARTx->SWRST = UARTxSWRST_SWRST_01;
|
||||
|
||||
while (((UARTx->SWRST) & UARTxSWRST_SWRSTF_MASK) == UARTxSWRST_SWRSTF_RUN) {
|
||||
// No process
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "sleep_api.h"
|
||||
|
||||
// Number of warm-up cycle = (warming up time (s) / clock period (s)) - 16
|
||||
#define CG_WUODR_INT_5MS ((uint16_t)0x0C34)
|
||||
#define CG_STBY_MODE_IDLE 0x0
|
||||
#define CG_STBY_MODE_STOP1 0x1
|
||||
#define EXTERNEL_OSC_MASK 0xFFFFFFF1
|
||||
#define SIWDT_DISABLE 0xB1
|
||||
#define WUPT_LOWER_MASK 0x000F
|
||||
#define WUPT_UPPER_MASK 0xFFF0
|
||||
|
||||
static void external_losc_enable(void);
|
||||
|
||||
void hal_sleep(void)
|
||||
{
|
||||
// Set low power consumption mode IDLE
|
||||
TSB_CG->STBYCR = CG_STBY_MODE_IDLE;
|
||||
|
||||
// Enter idle mode
|
||||
__DSB();
|
||||
__WFI();
|
||||
}
|
||||
|
||||
void hal_deepsleep(void)
|
||||
{
|
||||
uint32_t wupt_lower = 0;
|
||||
uint32_t wupt_upper = 0;
|
||||
uint32_t tmp = 0;
|
||||
|
||||
TSB_CG_FSYSMENB_IPMENB31 = TXZ_ENABLE;
|
||||
|
||||
TSB_SIWD0->EN = TXZ_DISABLE;
|
||||
TSB_SIWD0->CR = SIWDT_DISABLE;
|
||||
|
||||
|
||||
while ((TSB_FC->SR0 & TXZ_DONE) != TXZ_DONE) {
|
||||
// Flash wait
|
||||
}
|
||||
|
||||
while (TSB_CG_WUPHCR_WUEF) {
|
||||
// Wait for end of Warming-up for IHOSC1
|
||||
}
|
||||
|
||||
TSB_CG_WUPHCR_WUCLK = TXZ_DISABLE;
|
||||
wupt_lower = ((CG_WUODR_INT_5MS & WUPT_LOWER_MASK) << 16U);
|
||||
wupt_upper = ((CG_WUODR_INT_5MS & WUPT_UPPER_MASK) << 16U);
|
||||
TSB_CG->WUPHCR |= (wupt_lower | wupt_upper);
|
||||
TSB_CG->STBYCR = CG_STBY_MODE_STOP1;
|
||||
TSB_CG_PLL0SEL_PLL0SEL = TXZ_DISABLE;
|
||||
|
||||
|
||||
while (TSB_CG_PLL0SEL_PLL0ST) {
|
||||
// Wait for PLL status of fsys until off state(fosc=0)
|
||||
}
|
||||
|
||||
// Stop PLL of fsys
|
||||
TSB_CG_PLL0SEL_PLL0ON = TXZ_DISABLE;
|
||||
TSB_CG_OSCCR_IHOSC1EN = TXZ_ENABLE;
|
||||
TSB_CG_OSCCR_OSCSEL = TXZ_DISABLE;
|
||||
|
||||
while (TSB_CG_OSCCR_OSCF) {
|
||||
// Wait for fosc status until IHOSC1 = 0
|
||||
}
|
||||
|
||||
tmp = TSB_CG->OSCCR;
|
||||
tmp &= EXTERNEL_OSC_MASK;
|
||||
TSB_CG->OSCCR = tmp;
|
||||
|
||||
|
||||
// Enter stop1 mode
|
||||
__DSB();
|
||||
__WFI();
|
||||
|
||||
// Switch over from IHOSC to EHOSC
|
||||
// After coming out off sleep mode, Restore the clock setting to EHOSC.
|
||||
external_losc_enable();
|
||||
}
|
||||
|
||||
static void external_losc_enable(void)
|
||||
{
|
||||
uint32_t wupt_lower = 0;
|
||||
uint32_t wupt_upper = 0;
|
||||
|
||||
// Enable high-speed oscillator
|
||||
TSB_CG->OSCCR |= (TXZ_ENABLE << 1);
|
||||
|
||||
// Select internal(fIHOSC) as warm-up clock
|
||||
wupt_lower = ((CG_WUODR_INT_5MS & WUPT_LOWER_MASK) << 16U);
|
||||
wupt_upper = ((CG_WUODR_INT_5MS & WUPT_UPPER_MASK) << 16U);
|
||||
TSB_CG->WUPHCR |= (wupt_lower | wupt_upper);
|
||||
|
||||
// Start warm-up
|
||||
TSB_CG->WUPHCR |= TXZ_ENABLE;
|
||||
|
||||
// Wait until EHOSC become stable
|
||||
while ((TSB_CG->WUPHCR & 0x0002)) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Set fosc source
|
||||
TSB_CG->OSCCR |= (1 << 8);
|
||||
|
||||
// Wait for <OSCSEL> to become "1"
|
||||
while (!((TSB_CG->OSCCR & 0x200)>> 9)) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Stop IHOSC
|
||||
TSB_CG->OSCCR &= ~TXZ_ENABLE;
|
||||
}
|
|
@ -0,0 +1,335 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "spi_api.h"
|
||||
#include "mbed_error.h"
|
||||
#include "txz_tspi.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#define TIMEOUT (5000)
|
||||
#define BAUDRATE_1MHZ_BRS (0x0A)
|
||||
#define BAUDRATE_1MHZ_BRCK (0x30)
|
||||
|
||||
static const PinMap PinMap_SPI_SCLK[] = {
|
||||
{PA1, SPI_0, PIN_DATA(7, 1)},
|
||||
{PL1, SPI_1, PIN_DATA(7, 1)},
|
||||
{PA6, SPI_2, PIN_DATA(7, 1)},
|
||||
{PK6, SPI_3, PIN_DATA(4, 1)},
|
||||
{PD1, SPI_4, PIN_DATA(4, 1)},
|
||||
{PV6, SPI_5, PIN_DATA(4, 1)},
|
||||
{PM2, SPI_6, PIN_DATA(6, 1)},
|
||||
{PM5, SPI_7, PIN_DATA(6, 1)},
|
||||
{PW1, SPI_8, PIN_DATA(4, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_SPI_MOSI[] = {
|
||||
{PA3, SPI_0, PIN_DATA(7, 1)},
|
||||
{PL3, SPI_1, PIN_DATA(7, 1)},
|
||||
{PA4, SPI_2, PIN_DATA(7, 1)},
|
||||
{PK4, SPI_3, PIN_DATA(4, 1)},
|
||||
{PD3, SPI_4, PIN_DATA(4, 1)},
|
||||
{PV5, SPI_5, PIN_DATA(4, 1)},
|
||||
{PM0, SPI_6, PIN_DATA(6, 1)},
|
||||
{PM7, SPI_7, PIN_DATA(6, 1)},
|
||||
{PW3, SPI_8, PIN_DATA(4, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_SPI_MISO[] = {
|
||||
{PA2, SPI_0, PIN_DATA(7, 0)},
|
||||
{PL2, SPI_1, PIN_DATA(7, 0)},
|
||||
{PA5, SPI_2, PIN_DATA(7, 0)},
|
||||
{PK5, SPI_3, PIN_DATA(4, 0)},
|
||||
{PD2, SPI_4, PIN_DATA(4, 0)},
|
||||
{PV4, SPI_5, PIN_DATA(4, 0)},
|
||||
{PM1, SPI_6, PIN_DATA(6, 0)},
|
||||
{PM6, SPI_7, PIN_DATA(6, 0)},
|
||||
{PW2, SPI_8, PIN_DATA(4, 0)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_SPI_SSEL[] = {
|
||||
{PA0, SPI_0, PIN_DATA(7, 1)},
|
||||
{PL0, SPI_1, PIN_DATA(7, 1)},
|
||||
{PA7, SPI_2, PIN_DATA(7, 1)},
|
||||
{PK7, SPI_3, PIN_DATA(4, 1)},
|
||||
{PD0, SPI_4, PIN_DATA(4, 1)},
|
||||
{PV7, SPI_5, PIN_DATA(4, 1)},
|
||||
{PM3, SPI_6, PIN_DATA(6, 1)},
|
||||
{PM4, SPI_7, PIN_DATA(6, 1)},
|
||||
{PW0, SPI_8, PIN_DATA(4, 1)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
|
||||
{
|
||||
// Check pin parameters
|
||||
SPIName spi_mosi = (SPIName)pinmap_peripheral(mosi, PinMap_SPI_MOSI);
|
||||
SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO);
|
||||
SPIName spi_sclk = (SPIName)pinmap_peripheral(sclk, PinMap_SPI_SCLK);
|
||||
SPIName spi_ssel = (SPIName)pinmap_peripheral(ssel, PinMap_SPI_SSEL);
|
||||
SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso);
|
||||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->module = (SPIName)pinmap_merge(spi_data, spi_sclk);
|
||||
obj->module = (SPIName)pinmap_merge(spi_data, spi_cntl);
|
||||
MBED_ASSERT((int)obj->module!= NC);
|
||||
|
||||
// Identify SPI module to use
|
||||
switch ((int)obj->module) {
|
||||
case SPI_0:
|
||||
obj->p_obj.p_instance = TSB_TSPI0;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA04 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB02 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_1:
|
||||
obj->p_obj.p_instance = TSB_TSPI1;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA05 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB12 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_2:
|
||||
obj->p_obj.p_instance = TSB_TSPI2;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA06 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB02 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_3:
|
||||
obj->p_obj.p_instance = TSB_TSPI3;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA07 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB11 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_4:
|
||||
obj->p_obj.p_instance = TSB_TSPI4;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA08 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB05 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_5:
|
||||
obj->p_obj.p_instance = TSB_TSPI5;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSENA_IPENA09 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB19 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_6:
|
||||
obj->p_obj.p_instance = TSB_TSPI6;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSMENA_IPMENA20 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB13 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_7:
|
||||
obj->p_obj.p_instance = TSB_TSPI7;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSMENA_IPMENA21 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB13 = TXZ_ENABLE;
|
||||
break;
|
||||
case SPI_8:
|
||||
obj->p_obj.p_instance = TSB_TSPI8;
|
||||
// Enable clock for particular Port and SPI
|
||||
TSB_CG_FSYSMENA_IPMENA22 = TXZ_ENABLE;
|
||||
TSB_CG_FSYSMENB_IPMENB20 = TXZ_ENABLE;
|
||||
break;
|
||||
default:
|
||||
obj->p_obj.p_instance = NULL;
|
||||
obj->module = (SPIName)NC;
|
||||
error("Cannot found SPI module corresponding with input pins.");
|
||||
break;
|
||||
}
|
||||
|
||||
// Pin out the spi pins
|
||||
pinmap_pinout(mosi, PinMap_SPI_MOSI);
|
||||
pinmap_pinout(miso, PinMap_SPI_MISO);
|
||||
pinmap_pinout(sclk, PinMap_SPI_SCLK);
|
||||
|
||||
if (ssel != NC) {
|
||||
pinmap_pinout(ssel, PinMap_SPI_SSEL);
|
||||
}
|
||||
|
||||
// Default configurations 8 bit, 1Mhz frequency
|
||||
// Control 1 configurations
|
||||
obj->p_obj.init.id = (uint32_t)obj->module;
|
||||
obj->p_obj.init.cnt1.trgen = TSPI_TRGEN_DISABLE; // Trigger disabled
|
||||
obj->p_obj.init.cnt1.trxe = TSPI_DISABLE; // Enable Communication
|
||||
obj->p_obj.init.cnt1.tspims = TSPI_SPI_MODE; // SPI mode
|
||||
obj->p_obj.init.cnt1.mstr = TSPI_MASTER_OPEARTION; // Master mode operation
|
||||
obj->p_obj.init.cnt1.tmmd = TSPI_TWO_WAY; // Full-duplex mode (Transmit/receive)
|
||||
obj->p_obj.init.cnt1.cssel = TSPI_TSPIxCS0_ENABLE; // Chip select of pin CS0 is valid
|
||||
obj->p_obj.init.cnt1.fc = TSPI_TRANS_RANGE_SINGLE; // Transfer single frame at a time contineously
|
||||
|
||||
// Control 2 configurations
|
||||
obj->p_obj.init.cnt2.tidle = TSPI_TIDLE_HI;
|
||||
obj->p_obj.init.cnt2.txdemp = TSPI_TXDEMP_HI; // When slave underruns TxD fixed to low
|
||||
obj->p_obj.init.cnt2.rxdly = TSPI_RXDLY_SET;
|
||||
obj->p_obj.init.cnt2.til = TSPI_TX_FILL_LEVEL_0; // Transmit FIFO Level
|
||||
obj->p_obj.init.cnt2.ril = TSPI_RX_FILL_LEVEL_1; // Receive FIFO Level
|
||||
obj->p_obj.init.cnt2.inttxwe = TSPI_TX_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.intrxwe = TSPI_RX_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.inttxfe = TSPI_TX_FIFO_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.intrxfe = TSPI_RX_FIFO_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.interr = TSPI_ERR_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.dmate = TSPI_TX_DMA_INT_DISABLE;
|
||||
obj->p_obj.init.cnt2.dmare = TSPI_RX_DMA_INT_DISABLE;
|
||||
|
||||
// Control 3 configurations
|
||||
obj->p_obj.init.cnt3.tfempclr = TSPI_TX_BUFF_CLR_DONE; // Transmit buffer clear
|
||||
obj->p_obj.init.cnt3.rffllclr = TSPI_RX_BUFF_CLR_DONE; // Receive buffer clear
|
||||
|
||||
// Baudrate settings - 1 Mhz default
|
||||
obj->p_obj.init.brd.brck = BAUDRATE_1MHZ_BRCK;
|
||||
obj->p_obj.init.brd.brs = BAUDRATE_1MHZ_BRS;
|
||||
|
||||
// Format Control 0 settings
|
||||
obj->p_obj.init.fmr0.dir = TSPI_DATA_DIRECTION_MSB; // MSB bit first
|
||||
obj->p_obj.init.fmr0.fl = TSPI_DATA_LENGTH_8;
|
||||
obj->p_obj.init.fmr0.fint = TSPI_INTERVAL_TIME_0;
|
||||
|
||||
// Special control on polarity of signal and generation timing
|
||||
obj->p_obj.init.fmr0.cs3pol = TSPI_TSPIxCS3_NEGATIVE;
|
||||
obj->p_obj.init.fmr0.cs2pol = TSPI_TSPIxCS2_NEGATIVE;
|
||||
obj->p_obj.init.fmr0.cs1pol = TSPI_TSPIxCS1_NEGATIVE;
|
||||
obj->p_obj.init.fmr0.cs0pol = TSPI_TSPIxCS0_NEGATIVE;
|
||||
obj->p_obj.init.fmr0.ckpha = TSPI_SERIAL_CK_1ST_EDGE;
|
||||
obj->p_obj.init.fmr0.ckpol = TSPI_SERIAL_CK_IDLE_LOW;
|
||||
obj->p_obj.init.fmr0.csint = TSPI_MIN_IDLE_TIME_1;
|
||||
|
||||
obj->p_obj.init.fmr0.cssckdl = TSPI_SERIAL_CK_DELAY_1;
|
||||
obj->p_obj.init.fmr0.sckcsdl = TSPI_NEGATE_1;
|
||||
|
||||
// Format Control 1 settings tspi_fmtr1_t
|
||||
obj->p_obj.init.fmr1.vpe = TSPI_PARITY_DISABLE;
|
||||
obj->p_obj.init.fmr1.vpm = TSPI_PARITY_BIT_ODD;
|
||||
|
||||
obj->bits = (uint8_t)TSPI_DATA_LENGTH_8;
|
||||
|
||||
// Initialize SPI
|
||||
tspi_init(&obj->p_obj);
|
||||
}
|
||||
|
||||
void spi_free(spi_t *obj)
|
||||
{
|
||||
tspi_deinit(&obj->p_obj);
|
||||
obj->module = (SPIName)NC;
|
||||
}
|
||||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave)
|
||||
{
|
||||
MBED_ASSERT((slave == 0U)); // 0: master mode, 1: slave mode
|
||||
MBED_ASSERT((bits >= 8) && (bits <= 32));
|
||||
|
||||
obj->bits = bits;
|
||||
obj->p_obj.init.fmr0.fl = (bits << 24);
|
||||
|
||||
if ((mode >> 1) & 0x1) {
|
||||
obj->p_obj.init.fmr0.ckpol = TSPI_SERIAL_CK_IDLE_HI;
|
||||
} else {
|
||||
obj->p_obj.init.fmr0.ckpol = TSPI_SERIAL_CK_IDLE_LOW;
|
||||
}
|
||||
|
||||
if (mode & 0x1) {
|
||||
obj->p_obj.init.fmr0.ckpha = TSPI_SERIAL_CK_2ND_EDGE;
|
||||
} else {
|
||||
obj->p_obj.init.fmr0.ckpha = TSPI_SERIAL_CK_1ST_EDGE;
|
||||
}
|
||||
|
||||
tspi_init(&obj->p_obj);
|
||||
}
|
||||
|
||||
void spi_frequency(spi_t *obj, int hz)
|
||||
{
|
||||
SystemCoreClockUpdate();
|
||||
uint8_t brs = 0;
|
||||
uint8_t brck = 0;
|
||||
uint16_t prsck = 1;
|
||||
uint64_t fscl = 0;
|
||||
uint64_t tmp_fscl = 0;
|
||||
uint64_t fx = 0;
|
||||
uint64_t tmpvar = SystemCoreClock / 2;
|
||||
|
||||
for (prsck = 1; prsck <= 512; prsck *= 2) {
|
||||
fx = ((uint64_t)tmpvar / prsck);
|
||||
for (brs = 1; brs <= 16; brs++) {
|
||||
fscl = fx /brs;
|
||||
if ((fscl <= (uint64_t)hz) && (fscl > tmp_fscl)) {
|
||||
tmp_fscl = fscl;
|
||||
obj->p_obj.init.brd.brck = (brck << 4);
|
||||
if (brs == 16) {
|
||||
obj->p_obj.init.brd.brs = 0;
|
||||
} else {
|
||||
obj->p_obj.init.brd.brs = brs;
|
||||
}
|
||||
}
|
||||
}
|
||||
brck ++;
|
||||
}
|
||||
|
||||
tspi_init(&obj->p_obj);
|
||||
}
|
||||
|
||||
int spi_master_write(spi_t *obj, int value)
|
||||
{
|
||||
uint8_t ret_value = 0;
|
||||
|
||||
tspi_transmit_t send_obj;
|
||||
tspi_receive_t rec_obj;
|
||||
|
||||
// Transmit data
|
||||
send_obj.tx8.p_data = (uint8_t *)&value;
|
||||
send_obj.tx8.num = 1;
|
||||
tspi_master_write(&obj->p_obj, &send_obj, TIMEOUT);
|
||||
|
||||
// Read received data
|
||||
rec_obj.rx8.p_data = &ret_value;
|
||||
rec_obj.rx8.num = 1;
|
||||
tspi_master_read(&obj->p_obj, &rec_obj, TIMEOUT);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
|
||||
char *rx_buffer, int rx_length, char write_fill)
|
||||
{
|
||||
int total = (tx_length > rx_length) ? tx_length : rx_length;
|
||||
|
||||
for (int i = 0; i < total; i++) {
|
||||
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
|
||||
char in = spi_master_write(obj, out);
|
||||
if (i < rx_length) {
|
||||
rx_buffer[i] = in;
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
int spi_busy(spi_t *obj)
|
||||
{
|
||||
int ret = 1;
|
||||
uint32_t status = 0;
|
||||
|
||||
tspi_get_status(&obj->p_obj, &status);
|
||||
|
||||
if ((status & (TSPI_TX_FLAG_ACTIVE | TSPI_RX_FLAG_ACTIVE)) == 0) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t spi_get_module(spi_t *obj)
|
||||
{
|
||||
return (uint8_t)(obj->module);
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/* mbed Microcontroller Library
|
||||
* (C)Copyright TOSHIBA ELECTRONIC DEVICES & STORAGE CORPORATION 2018 All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "us_ticker_api.h"
|
||||
#include "TMPM4G9.h"
|
||||
#include "txz_t32a.h"
|
||||
|
||||
#define CLR_TIMER_INT_FLAG (uint8_t)0x41
|
||||
|
||||
static uint8_t us_ticker_inited = 0; // Is ticker initialized yet?
|
||||
|
||||
const ticker_info_t* us_ticker_get_info()
|
||||
{
|
||||
static const ticker_info_t info = {
|
||||
2500000,
|
||||
32
|
||||
};
|
||||
return &info;
|
||||
}
|
||||
|
||||
// Initialize us_ticker
|
||||
void us_ticker_init(void)
|
||||
{
|
||||
if (us_ticker_inited) {
|
||||
us_ticker_disable_interrupt();
|
||||
return;
|
||||
}
|
||||
us_ticker_inited = 1;
|
||||
|
||||
// Enable clock for T32A0
|
||||
TSB_CG_FSYSMENA_IPMENA06 = TXZ_ENABLE;
|
||||
|
||||
// T32A ch0 TimerC Reg Match/Over Flow/Under Flow
|
||||
TSB_IB->IMC006 = TXZ_ENABLE;
|
||||
|
||||
// Configure Timer T32A0
|
||||
TSB_T32A0->MOD = T32A_MODE_32;
|
||||
TSB_T32A0->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_STOP);
|
||||
TSB_T32A0->CRC = T32A_PRSCLx_32;
|
||||
TSB_T32A0->IMC = (T32A_IMUFx_MASK_REQ | T32A_IMOFx_MASK_REQ);
|
||||
TSB_T32A0->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_START);
|
||||
|
||||
NVIC_SetVector(INTT32A00_A_CT_IRQn, (uint32_t)us_ticker_irq_handler);
|
||||
NVIC_EnableIRQ(INTT32A00_A_CT_IRQn);
|
||||
}
|
||||
|
||||
uint32_t us_ticker_read(void)
|
||||
{
|
||||
uint32_t ret_val = 0;
|
||||
|
||||
if (!us_ticker_inited) {
|
||||
us_ticker_init();
|
||||
}
|
||||
|
||||
ret_val = (TSB_T32A0->TMRC);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||
{
|
||||
NVIC_DisableIRQ(INTT32A00_A_CT_IRQn);
|
||||
TSB_T32A0->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_STOP);
|
||||
TSB_T32A0->RGC1 = timestamp ;
|
||||
NVIC_EnableIRQ(INTT32A00_A_CT_IRQn);
|
||||
TSB_T32A0->RUNC = (T32A_RUN_ENABLE | T32A_COUNT_START);
|
||||
}
|
||||
|
||||
void us_ticker_fire_interrupt(void)
|
||||
{
|
||||
NVIC_SetPendingIRQ(INTT32A00_A_CT_IRQn);
|
||||
NVIC_EnableIRQ(INTT32A00_A_CT_IRQn);
|
||||
}
|
||||
|
||||
void us_ticker_disable_interrupt(void)
|
||||
{
|
||||
// Disable interrupts in NVIC
|
||||
TSB_IB->IMC006 = CLR_TIMER_INT_FLAG;
|
||||
NVIC_ClearPendingIRQ(INTT32A00_A_CT_IRQn);
|
||||
NVIC_DisableIRQ(INTT32A00_A_CT_IRQn);
|
||||
}
|
||||
|
||||
void us_ticker_clear_interrupt(void)
|
||||
{
|
||||
TSB_IB->IMC006 = CLR_TIMER_INT_FLAG;
|
||||
NVIC_ClearPendingIRQ(INTT32A00_A_CT_IRQn);
|
||||
}
|
||||
|
||||
void us_ticker_free(void)
|
||||
{
|
||||
TSB_T32A0->RUNC = T32A_RUN_DISABLE;
|
||||
TSB_IB->IMC006 = CLR_TIMER_INT_FLAG;
|
||||
NVIC_ClearPendingIRQ(INTT32A00_A_CT_IRQn);
|
||||
NVIC_DisableIRQ(INTT32A00_A_CT_IRQn);
|
||||
TSB_CG_FSYSMENA_IPMENA06 = TXZ_DISABLE;
|
||||
}
|
|
@ -49,4 +49,12 @@
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_TMPM4G9)
|
||||
|
||||
#ifndef INITIAL_SP
|
||||
#define INITIAL_SP (0x20030000UL)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // MBED_MBED_RTX_H
|
||||
|
|
|
@ -4459,5 +4459,18 @@
|
|||
"device_name": "TMPM3H6FWFG",
|
||||
"detect_code": ["7012"],
|
||||
"release_versions": ["5"]
|
||||
},
|
||||
"TMPM4G9": {
|
||||
"inherits": ["Target"],
|
||||
"core": "Cortex-M4",
|
||||
"is_disk_virtual": true,
|
||||
"extra_labels": ["TOSHIBA"],
|
||||
"macros": ["__TMPM4G9__"],
|
||||
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
|
||||
"device_has": ["ANALOGIN", "ANALOGOUT", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "SERIAL", "SPI", "I2C", "I2CSLAVE", "STDIO_MESSAGES", "FLASH", "SLEEP", "USTICKER"],
|
||||
"device_name": "TMPM4G9F15FG",
|
||||
"detect_code": ["7016"],
|
||||
"release_versions": ["5"],
|
||||
"bootloader_supported": true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue