📄 uwire.h
字号:
//NAME : UWIRE_ReadRxRegister -
//DESCRIPTION : Read RX register -
//PARAMETERS : None -
//RETURN VALUE: None -
//-----------------------------------------------------------------------
UWORD16 UWIRE_ReadRxRegister (void);
//----------------------------------------------------
// UWIRE_Error_t : ERROR raised on Reset Error
//----------------------------------------------------
typedef enum {
UWIRE_CSR_RESET_ERROR = 3,
UWIRE_SR1_RESET_ERROR = 4,
UWIRE_SR2_RESET_ERROR = 5,
UWIRE_SR3_RESET_ERROR = 6,
UWIRE_CSR_WRITE_ERROR = 7,
UWIRE_SR1_WRITE_ERROR = 8,
UWIRE_SR2_WRITE_ERROR = 9,
UWIRE_SR3_WRITE_ERROR = 10
} UWIRE_Error_t;
//--------------------------------------------------------------------------------
// NAME : UWIRE_TestRegisters
// DESCRIPTION : Test
// 1) the default register values on reset
// 2) the access of the register to the UWIRE module.
// RETURN VALUE : Return the result of the test OK or BAD
// PARAMETERS : res : pointer to the result area
// LIMITATIONS : Update results
//---------------------------------------------------------------------------------
UWORD8 UWIRE_TestRegisters(void);
//--------------------------------------------------------------------------------
// NAME : UWIRE_SetSr1Reg
// UWIRE_SetSr2Reg
// UWIRE_SetCsrReg
// DESCRIPTION : Initialize the register
// PARAMETERS : Value => 16 bits data to write into register
// RETURN VALUE : none
// LIMITATIONS : Update results
//---------------------------------------------------------------------------------
void UWIRE_SetSr1Reg(UWORD16 value);
void UWIRE_SetSr2Reg(UWORD16 value);
void UWIRE_SetCsrReg(UWORD16 value);
//--------------------------------------------------------------------------------------
//NAME : UWIRE_SetupSr1OrSr2 -
//DESCRIPTION : Setup the Microwire I/F -
//PARAMETERS : -
// index: Index of the external device [0..3] -
// can drive 4 serial external components as bellow -
// CS0, CS1 => Setup Register 1 Update -
// CS2, CS3 => Setup Register 2 Update -
// readEdge: Define active edge of the serial clock used to read data -
// 0 => Falling, 1 => Rising -
// writeEdge: Define active edge of the serial clock used to write data -
// 0 => Falling, 1 => Rising -
// CSlevel: Define the active level of the chip select -
// frequency: frequency of the serial clock (divider of the internal clock frequency) -
// 0=>div2, 1=>div4, 2=>div8, 3=>Undefined -
// check: check or not if the external device is busy -
// 0 => No check, the write process is immediatly executed -
// 1 => Check enable: -
// -if Data Input signal is low, the external device is considered busy -
// -if DI signal is High, the device is ready and the interface starts -
// the Write Process -
//RETURN VALUE: None -
//--------------------------------------------------------------------------------------
typedef enum
{
UWIRE_CS0_INDEX = 0x00, //Chip Select CS0 is selected
UWIRE_CS1_INDEX = 0x01, //Chip Select CS1 is selected
UWIRE_CS2_INDEX = 0x02, //Chip Select CS2 is selected
UWIRE_CS3_INDEX = 0x03 //Chip Select CS3 is selected
} UWIRE_CsIndex_t;
typedef enum
{
UWIRE_FALLING_EDGE_READ = 0,
UWIRE_RISING_EDGE_READ = 1
} UWIRE_EdgeRd_t;
typedef enum
{
UWIRE_FALLING_EDGE_WRITE = 0,
UWIRE_RISING_EDGE_WRITE = 1
} UWIRE_EdgeWr_t;
typedef enum
{
UWIRE_CS_ACTIVE_LEVEL_0 = 0, //Chip Select active level is zero
UWIRE_CS_ACTIVE_LEVEL_1 = 1 //Chip Select active level is one
} UWIRE_CsLvl_t;
typedef enum
{
UWIRE_CS_CLOCK_FREQ_DIV_2 = 0x00, // internal clock divided by 2
UWIRE_CS_CLOCK_FREQ_DIV_4 = 0x01, // internal clock divided by 4
UWIRE_CS_CLOCK_FREQ_DIV_8 = 0x02, // internal clock divided by 8
UWIRE_CS_CLOCK_FREQ_UNDEF = 0x03 // undefined frequency
} UWIRE_CsFrq_t;
typedef enum
{
UWIRE_CS_NO_CHECK_DEVICE_READY_ON_WRITE = 0,
UWIRE_CS_CHECK_DEVICE_READY_ON_WRITE = 1
} UWIRE_CsChk_t;
void UWIRE_SetupSr1OrSr2(UWIRE_CsIndex_t index,
UWIRE_EdgeRd_t readEdge,
UWIRE_EdgeWr_t writeEdge,
UWIRE_CsLvl_t CSlevel,
UWIRE_CsFrq_t frequency,
UWIRE_CsChk_t check);
//-----------------------------------------------------------
//NAME : UWIRE_Setup3 -
//DESCRIPTION : Setup the Microwire I/F setup register 3 -
//PARAMETERS : -
// clk_en: 0 => Disable the clock -
// 1 => Enable the clock -
// clk_freq: Frequency of the internal clock when enable -
// 0 => divide2 -
// 1 => divide4 -
// 2 => divide7 -
// 3 => divide10 -
//RETURN VALUE: None -
//-----------------------------------------------------------
typedef enum
{
UWIRE_CLOCK_DISABLE = 0x00,
UWIRE_CLOCK_ENABLE = 0x01
} UWIRE_ClkEn_t;
typedef enum
{
UWIRE_CK_FREQ_DIV_2 = 0x00, // input clock divided by 2
UWIRE_CK_FREQ_DIV_4 = 0x01, // input clock divided by 4
UWIRE_CK_FREQ_DIV_7 = 0x02, // input clock divided by 7
UWIRE_CK_FREQ_DIV_10 = 0x03 // input clock divided by 10
} UWIRE_ClkFreq_t;
void UWIRE_Setup3(UWIRE_ClkEn_t clk_en, UWIRE_ClkFreq_t clk_freq);
//-------------------------------------------------------------------
//NAME : UWIRE_Select -
//DESCRIPTION : Select an external device -
//PARAMETERS:
// cs_index: Index of the external device [0..3] -
// can drive 4 serial external components as bellow -
// 0 => CS0 , 1 => CS1, 2 => CS2, 3 => CS3 -
//RETURN VALUE: None -
//-------------------------------------------------------------------
typedef enum
{
UWIRE_INDEX_CS0 = 0, //Index of external device is Chip Select 0
UWIRE_INDEX_CS1 = 1, //Index of external device is Chip Select 1
UWIRE_INDEX_CS2 = 2, //Index of external device is Chip Select 2
UWIRE_INDEX_CS3 = 3 //Index of external device is Chip Select 3
} UWIRE_Index_t;
void UWIRE_Select(UWIRE_Index_t cs_index);
//-------------------------------------------------------------------
//NAME : UWIRE_ActivatePeriph -
//DESCRIPTION : activate the chip select of the selected peripheral -
//PARAMETERS: None -
//RETURN VALUE: None -
//-------------------------------------------------------------------
void UWIRE_ActivatePeriph(void);
//--------------------------------------------------------------------
//NAME : UWIRE_ActivatePeriph -
//DESCRIPTION : deactivate the chip select of the selected peripheral-
//PARAMETERS: None -
//RETURN VALUE: None -
//--------------------------------------------------------------------
void UWIRE_DeactivatePeriph(void);
//-------------------------------------------------------------------
//NAME : UWIRE_TestResetValue
//DESCRIPTION : Check all reset values
//RETURN VALUE: None
//-------------------------------------------------------------------
void UWIRE_TestResetValue(void);
//-------------------------------------------------------------------
//NAME : UWIRE_TestRegistersAccess
//DESCRIPTION : Check it is possible to modify all registers
//RETURN VALUE: None
//-------------------------------------------------------------------
void UWIRE_TestRegistersAccess(void);
//-------------------------------------------------------------------
//NAME : UWIRE_Release -
//DESCRIPTION : Wait for termination Read/Write of ongoing transfer -
// to Free up the microwire I/F -
//RETURN VALUE: None -
//-------------------------------------------------------------------
void UWIRE_Release(void);
//-----------------------------------------------------------------------
//NAME : UWIRE_Write -
//DESCRIPTION : write into an external device, using the microwire I/F -
//PARAMETERS :
// data = Data to transmit
// write_len = Number of bits to transmit [0..31]
// read_len = Number of bits to receive [0..31]
//RETURN VALUE: None -
//-----------------------------------------------------------------------
void UWIRE_Write(UWORD16 data, UWORD8 write_len, UWORD8 read_len);
//-----------------------------------------------------------------------
//NAME : UWIRE_Read -
//DESCRIPTION : Read from an external device, using the microwire I/F -
//RETURN VALUE: Received data -
//-----------------------------------------------------------------------
UWORD16 UWIRE_Read(void);
/*----------- EEPROM ---------------*/
//-------------------------------------------
//NAME : UWIRE_M46EepromWriteEnable -
//DESCRIPTION : M93LC46 EEPROM Write enable -
//RETURN VALUE: None -
//-------------------------------------------
void UWIRE_M46EepromWriteEnable (void);
//---------------------------------------------
//NAME : UWIRE_Xl66EepromWriteEnable -
//DESCRIPTION : XL93LC66 EEPROM Write enable -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_Xl66EepromWriteEnable (void);
void UWIRE_Xl66EepromEraseAll (void);
void UWIRE_M46EepromEraseAll (void);
void UWIRE_Xl66EepromSetup (void);
void UWIRE_M46EepromSetup (void);
void UWIRE_Xl66EepromWrite (UWORD16 address, UWORD16 data);
void UWIRE_M46EepromWrite (UWORD16 address, UWORD16 data);
UWORD16 UWIRE_Xl66EepromRead (UWORD16 address);
UWORD16 UWIRE_M46EepromRead (UWORD16 address);
//---------------------------------------------
//NAME : UWIRE_DmaTxMode -
//DESCRIPTION : Set the SR5 to uwire in -
// DMA_TX mode -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_DmaTxMode(int value);
//---------------------------------------------
//NAME : UWIRE_ItMode -
//DESCRIPTION : Set the SR5 to uwire in -
// IT mode -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_ItMode(int value);
//---------------------------------------------
//NAME : UWIRE_AutoTxMode -
//DESCRIPTION : Set the SR5 to uwire in -
// AUTO_TX mode -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_AutoTxMode(int value);
//---------------------------------------------
//NAME : UWIRE_CsToggleMode -
//DESCRIPTION : Set the SR5 to uwire in -
// CS toggle mode -
// ( only if AUTOTX selected -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_CsToggleMode(int value);
//---------------------------------------------
//NAME : UWIRE_WriteAutoTx -
//DESCRIPTION : allow a write process whithout-
// selecting the chip select -
// -
// data : data to transmit -
// write_len : bit number to transmit-
// read_len : bit number to write -
// -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_WriteAutoTx(UWORD16 data, UWORD8 write_len, UWORD8 read_len);
//---------------------------------------------
//NAME : UWIRE_WaitTransmitionEnd -
//DESCRIPTION : wait the reset of the CSRB bit-
// does polling -
//RETURN VALUE: None -
//---------------------------------------------
void UWIRE_WaitTransmitionEnd(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -