本文整理汇总了C++中SetWord16函数的典型用法代码示例。如果您正苦于以下问题:C++ SetWord16函数的具体用法?C++ SetWord16怎么用?C++ SetWord16使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetWord16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_sys_startup_period
/**
****************************************************************************************
* @brief Checks if system is in startup phase.
* @return uint8 1 if system is in startup phase, otherwise 0.
****************************************************************************************
*/
uint8_t check_sys_startup_period(void)
{
uint8_t ret_value = 0;
if (sys_startup_flag)
{
uint32_t current_time;
current_time = lld_evt_time_get();
if (current_time < startup_sleep_delay) // startup_sleep_delay after system startup to allow system to sleep
ret_value = 1;
else // After 2 seconds system can sleep
{
sys_startup_flag = false;
if ( (app_get_sleep_mode() == 2) || (app_get_sleep_mode() == 1) )
{
SetWord16(SET_FREEZE_REG, FRZ_WDOG); // Stop WDOG until debugger is removed
while ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP) {};
SetBits16(SYS_CTRL_REG, DEBUGGER_ENABLE, 0); // close debugger
}
#if (USE_WDOG)
SetWord16(RESET_FREEZE_REG, FRZ_WDOG); // Start WDOG
#endif
ret_value = 0;
}
}
return ret_value;
}
示例2: read_from_3wire_SPI_register
/**
****************************************************************************************
* @brief Read from 3-wire SPI
* @param[in] registerIndex: Target address (A6..A0)
*
* @return byte read
****************************************************************************************
*/
uint8_t read_from_3wire_SPI_register(uint8_t registerIndex, uint8_t is_last_transaction)
{
static uint8_t i, dataRead;
GPIO_SetInactive(cs.port, cs.pin); // pull CS low
GPIO_SetPinFunction( sdio.port, sdio.pin, OUTPUT, PID_SPI_DO); // configure SDIO as output
SetWord16(SPI_RX_TX_REG0, (uint16_t)(registerIndex) ); // MSB set to HIGH - A6..A0 Address of register to write to
do {
} while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0); // polling to wait for spi transmission
SetWord16(SPI_CLEAR_INT_REG, 0); //Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt
GPIO_SetPinFunction( sdio.port, sdio.pin, INPUT, PID_SPI_DI); // configure SDIO as input
for (i=0; i<TsradCounter; i++); // {DEV.NOTE#: For Mouse sensor Delay > Tsrad = 4us <-- suitable counter is 6}
SetWord16(SPI_RX_TX_REG0, (uint16_t)0x00 ); // dummy write data - read data
do {
} while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0); // polling to wait for spi transmission
SetWord16(SPI_CLEAR_INT_REG, 0); //Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt
dataRead = GetWord16(SPI_RX_TX_REG0); // read received byte
SetWord16(SPI_CLEAR_INT_REG, 0x01); // clear pending flag
if(is_last_transaction)
GPIO_SetActive(cs.port, cs.pin); // set CS high
return dataRead;
}
示例3: getByte_SPI
/**
****************************************************************************************
* @brief Read a single item from serial flash via SPI
* @param[in] x: buffer to read the data
****************************************************************************************
*/
inline void getByte_SPI(uint8* x )
{
SetWord16(SPI_RX_TX_REG0, (uint16) DUMMY);
while (GetBits16(SPI_CTRL_REG, SPI_INT_BIT==0));
SetWord16(SPI_CLEAR_INT_REG, 0x01);
*(uint8*)x=(uint8)GetWord16(SPI_RX_TX_REG0);
}
示例4: SpiFlashRead
/**
****************************************************************************************
* @brief Read a block of data from spu flash
* @param[in] destination_buffer: buffer to put the data
* @param[in] source_addr: starting position to read the data from spi
* @param[in] len: size of data to read
****************************************************************************************
*/
void SpiFlashRead(unsigned long destination_buffer,unsigned long source_addr,unsigned long len)
{
unsigned long i;
spi_mem_cs_low();
putByte_SPI(0x03);
putByte_SPI((source_addr&0xffffff)>>16);
putByte_SPI((source_addr&0xffff)>>8);
putByte_SPI(source_addr&0xff);
SetWord16(SPI_RX_TX_REG0, (uint16) 0);
__ASM volatile ("nop");
__ASM volatile ("nop");
for (i=0;i<len;i++)
{
SetWord16(SPI_RX_TX_REG0, (uint16) 0);
__ASM volatile ("nop");
__ASM volatile ("nop");
__ASM volatile ("nop");
__ASM volatile ("nop");
__ASM volatile ("nop");
__ASM volatile ("nop");
*(uint8*)(uint32)(destination_buffer+i)=(uint8)GetWord16(SPI_RX_TX_REG0);
}
spi_mem_cs_high();
}
示例5: adc_init
void adc_init(void){
SetWord16(GP_ADC_CTRL_REG, GP_ADC_LDO_EN | GP_ADC_SE);
SetWord16(GP_ADC_CTRL_REG, GP_ADC_LDO_EN | GP_ADC_SE | GP_ADC_EN);
SetWord16(GP_ADC_CTRL2_REG, 0x000E); // Enable 3x attenuation
// SetWord16(GP_ADC_OFFP_REG, 0x297);
}
示例6: trng_get_raw_data
/**
****************************************************************************************
* @brief Acquires the raw RFADC IQ samples
****************************************************************************************
*/
void trng_get_raw_data(uint32 address, uint32 length)
{
SetWord16(RFPT_ADDR_REG, address);
SetWord16(RFPT_LEN_REG, length);
SetWord16(RFPT_CTRL_REG, 0x1);
while ((GetWord16(RFPT_STAT_REG) & RFPT_ACTIVE)== RFPT_ACTIVE);
}
示例7: quad_decoder_init
void quad_decoder_init(QUAD_DEC_INIT_PARAMS_t *quad_dec_init_params)
{
// Enable the Quadrature clock
SetBits16(CLK_PER_REG, QUAD_ENABLE , true);
// Setup Quadrature Decoder pin assignment
SetWord16(QDEC_CTRL2_REG, quad_dec_init_params->chx_port_sel | quad_dec_init_params->chy_port_sel | quad_dec_init_params->chz_port_sel);
SetWord16(QDEC_CLOCKDIV_REG, quad_dec_init_params->qdec_clockdiv);
}
示例8: putByte_SPI
/**
****************************************************************************************
* @brief Write a single item to serial flash via SPI
* @param[in] x: data to send
****************************************************************************************
*/
void putByte_SPI(uint32 x)
{
uint16 tmp;
SetWord16(SPI_RX_TX_REG0, (uint16_t)x); // write (low part of) dataToSend
do
{
} while (GetBits16(SPI_CTRL_REG, SPI_INT_BIT) == 0); // polling to wait for spi transmission
SetWord16(SPI_CLEAR_INT_REG, 0x01); // clear pending flag
tmp = GetWord16(SPI_RX_TX_REG0);
}
示例9: burst_write_to_3wire_SPI_register
void burst_write_to_3wire_SPI_register(uint8_t registerIndex)
{
GPIO_SetPinFunction( sdio.port, sdio.pin, OUTPUT, PID_SPI_DO); // configure SDIO as output
SetWord16(SPI_RX_TX_REG0, (uint16_t)(registerIndex) ); // MSB set to HIGH - A6..A0 Address of register to write to
do {
} while (GetBits16(SPI_CTRL_REG,SPI_INT_BIT)==0); // polling to wait for spi transmission
SetWord16(SPI_CLEAR_INT_REG, 0); // Clear SPI_CTRL_REG[SPI_INT_BIT] interrupt
GPIO_SetPinFunction( sdio.port, sdio.pin, INPUT, PID_SPI_DI); // configure SDIO as input
}
示例10: uart_initialization
void uart_initialization(void)
{
SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock for UART 1
SetWord16(UART_LCR_REG, 0x80); // set bit to access DLH and DLL register
SetWord16(UART_IER_DLH_REG,(UART_BAUDRATE_115K2&0xFF>>8));//set high byte
SetWord16(UART_RBR_THR_DLL_REG,UART_BAUDRATE_115K2&0xFF);//set low byte
SetWord16(UART_LCR_REG,UART_DATALENGTH|UART_PARITY|UART_STOPBITS);
SetBits16(UART_MCR_REG, UART_SIRE, 0); // mode 0 for normal , 1 for IRDA
SetWord16(UART_IIR_FCR_REG,1); // enable fifo
SetBits16(UART_IER_DLH_REG,ERBFI_dlh0,0); // IER access, disable interrupt for available data
}
示例11: set_pxact_gpio
void set_pxact_gpio(void)
{
#if DEVELOPMENT_DEBUG
uint32_t i;
SetWord16(P13_MODE_REG, PID_GPIO|OUTPUT);
SetWord16(P1_SET_DATA_REG, 0x8);
for ( i=0;i<150;i++); //20 is almost 7.6usec of time.
SetWord16(P1_RESET_DATA_REG, 0x8);
#endif
return;
}
示例12: i2c_eeprom_init
/**
****************************************************************************************
* @brief Initialize I2C controller as a master for EEPROM handling.
****************************************************************************************
*/
void i2c_eeprom_init(uint16_t dev_address, uint8_t speed, uint8_t address_mode, uint8_t address_size)
{
mem_address_size = address_size;
SetBits16(CLK_PER_REG, I2C_ENABLE, 1); // enable clock for I2C
SetWord16(I2C_ENABLE_REG, 0x0); // Disable the I2C controller
SetWord16(I2C_CON_REG, I2C_MASTER_MODE | I2C_SLAVE_DISABLE | I2C_RESTART_EN); // Slave is disabled
SetBits16(I2C_CON_REG, I2C_SPEED, speed); // Set speed
SetBits16(I2C_CON_REG, I2C_10BITADDR_MASTER, address_mode); // Set addressing mode
SetWord16(I2C_TAR_REG, dev_address & 0x3FF); // Set Slave device address
SetWord16(I2C_ENABLE_REG, 0x1); // Enable the I2C controller
while( (GetWord16(I2C_STATUS_REG) & 0x20) != 0 ); // Wait for I2C master FSM to be IDLE
i2c_dev_address = dev_address;
}
示例13: NMI_HandlerC
void NMI_HandlerC(unsigned long *hardfault_args)
{
// Reached this point due to a WDOG timeout
SetBits16(PMU_CTRL_REG, RADIO_SLEEP, 1); // turn off radio PD
SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 1); // turn off peripheral power domain
SetBits16(CLK_RADIO_REG, BLE_LP_RESET, 1); // reset the BLE LP timer
NVIC_ClearPendingIRQ(BLE_WAKEUP_LP_IRQn); // clear any pending LP IRQs
#if (DEVELOPMENT_DEBUG)
SetWord16(SET_FREEZE_REG, FRZ_WDOG); // Stop WDOG
SetBits16(SYS_CTRL_REG, DEBUGGER_ENABLE, 1); // enable debugger to be able to re-attach
*(volatile unsigned long *)(STATUS_BASE ) = hardfault_args[0]; // R0
*(volatile unsigned long *)(STATUS_BASE + 0x04) = hardfault_args[1]; // R1
*(volatile unsigned long *)(STATUS_BASE + 0x08) = hardfault_args[2]; // R2
*(volatile unsigned long *)(STATUS_BASE + 0x0C) = hardfault_args[3]; // R3
*(volatile unsigned long *)(STATUS_BASE + 0x10) = hardfault_args[4]; // R12
*(volatile unsigned long *)(STATUS_BASE + 0x14) = hardfault_args[5]; // LR
*(volatile unsigned long *)(STATUS_BASE + 0x18) = hardfault_args[6]; // PC
*(volatile unsigned long *)(STATUS_BASE + 0x1C) = hardfault_args[7]; // PSR
*(volatile unsigned long *)(STATUS_BASE + 0x20) = (*((volatile unsigned long *)(0xE000ED28))); // CFSR
*(volatile unsigned long *)(STATUS_BASE + 0x24) = (*((volatile unsigned long *)(0xE000ED2C))); // HFSR
*(volatile unsigned long *)(STATUS_BASE + 0x28) = (*((volatile unsigned long *)(0xE000ED30))); // DFSR
*(volatile unsigned long *)(STATUS_BASE + 0x2C) = (*((volatile unsigned long *)(0xE000ED3C))); // AFSR
*(volatile unsigned long *)(STATUS_BASE + 0x30) = (*((volatile unsigned long *)(0xE000ED34))); // MMAR
*(volatile unsigned long *)(STATUS_BASE + 0x34) = (*((volatile unsigned long *)(0xE000ED38))); // BFAR
if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
// __asm("BKPT #0\n");
BKPT();
else
{
while(1);
}
#else // DEVELOPMENT_DEBUG
# ifdef PRODUCTION_DEBUG_OUTPUT
// Power up peripherals' power domain
SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0);
while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP));
dbg_prod_output(0, hardfault_args);
# endif
// Remap addres 0x00 to ROM and force execution
SetWord16(SYS_CTRL_REG, (GetWord16(SYS_CTRL_REG) & ~REMAP_ADR0) | SW_RESET );
#endif // DEVELOPMENT_DEBUG
}
示例14: Uart_init
void Uart_init(void)
{
SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock for UART 1
SetWord16(UART_LCR_REG, 0x80); // set bit to access DLH and DLL register
SetWord16(UART_IER_DLH_REG,(UART_BAUDRATE_115K2&0xFF>>8));//set high byte
SetWord16(UART_RBR_THR_DLL_REG,UART_BAUDRATE_115K2&0xFF);//set low byte
SetWord16(UART_LCR_REG,UART_DATALENGTH_8|UART_PARITY_NONE|UART_STOPBITS_1);
SetBits16(UART_MCR_REG, UART_SIRE, 0); // mode 0 for normal , 1 for IRDA
SetWord16(UART_IIR_FCR_REG,1); // enable fifo
SetBits16(UART_IER_DLH_REG,ERBFI_dlh0,1); // IER access, disable interrupt for available data
NVIC_SetPriority(UART_IRQn,1);
NVIC_EnableIRQ(UART_IRQn);
}
示例15: spi_439_getblock
void spi_439_getblock(int i)
{
uint16_t firstword = spi_439_bufstart0;
if (!(i & 0x01))
firstword = spi_439_bufstart1;
spi_439_block_idx = 20; // 1 Control + 20*2 samples,
SetWord16(SPI_RX_TX_REG1, (uint16_t)firstword);
SetWord16(SPI_RX_TX_REG0, 40); /* Tell 439 it needs to send 40 samples */
#ifdef TESTING_SPI
startpkt=1;
#endif
}