docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* Clears the SPIx CRC Error (CRCERR) interrupt pending bit. */
void SPI_I2S_ClearITPendingBit(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
/* Clears the SPIx CRC Error (CRCERR) interrupt pending bit. */ void SPI_I2S_ClearITPendingBit(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
{ uint16_t itpos = 0; assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx)); assert_param(IS_SPI_I2S_CLEAR_IT(SPI_I2S_IT)); itpos = 0x01 << (SPI_I2S_IT & 0x0F); SPIx->SR = (uint16_t)~itpos; }
MaJerle/stm32f429
C++
null
2,036
/* Fills each SDIO_DataInitStruct member with its default value. */
void SDIO_DataStructInit(SDIO_DataInitTypeDef *SDIO_DataInitStruct)
/* Fills each SDIO_DataInitStruct member with its default value. */ void SDIO_DataStructInit(SDIO_DataInitTypeDef *SDIO_DataInitStruct)
{ SDIO_DataInitStruct->SDIO_DataTimeOut = 0xFFFFFFFF; SDIO_DataInitStruct->SDIO_DataLength = 0x00; SDIO_DataInitStruct->SDIO_DataBlockSize = SDIO_DataBlockSize_1b; SDIO_DataInitStruct->SDIO_TransferDir = SDIO_TransferDir_ToCard; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is the entrypoint of ECM Driver. It installs Driver Binding Protocols together with Component Name Protocols. */
EFI_STATUS EFIAPI UsbEcmEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This function is the entrypoint of ECM Driver. It installs Driver Binding Protocols together with Component Name Protocols. */ EFI_STATUS EFIAPI UsbEcmEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ gUsbEcmDriverBinding.DriverBindingHandle = ImageHandle; gUsbEcmDriverBinding.ImageHandle = ImageHandle; return gBS->InstallMultipleProtocolInterfaces ( &gUsbEcmDriverBinding.DriverBindingHandle, &gEfiDriverBindingProtocolGuid, &gUsbEcmDriverBinding, ...
tianocore/edk2
C++
Other
4,240
/* Report a full set of quiescent states to the specified rcu_state data structure. This involves cleaning up after the prior grace period and letting rcu_start_gp() start up the next grace period if one is needed. Note that the caller must hold rnp->lock, as required by rcu_start_gp(), which will release it. */
static void rcu_report_qs_rsp(struct rcu_state *rsp, unsigned long flags) __releases(rcu_get_root(rsp) -> lock)
/* Report a full set of quiescent states to the specified rcu_state data structure. This involves cleaning up after the prior grace period and letting rcu_start_gp() start up the next grace period if one is needed. Note that the caller must hold rnp->lock, as required by rcu_start_gp(), which will release it. */ stati...
{ WARN_ON_ONCE(!rcu_gp_in_progress(rsp)); rsp->completed = rsp->gpnum; rsp->signaled = RCU_GP_IDLE; rcu_start_gp(rsp, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This API configure the ODR of the auxiliary sensor. */
static int8_t config_aux_odr(const struct bmi160_dev *dev)
/* This API configure the ODR of the auxiliary sensor. */ static int8_t config_aux_odr(const struct bmi160_dev *dev)
{ int8_t rslt; uint8_t aux_odr; rslt = bmi160_get_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev); if (rslt == BMI160_OK) { aux_odr = (uint8_t)(dev->aux_cfg.aux_odr); rslt = bmi160_set_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev); dev->delay_ms(BMI160_AUX_COM_DELAY); } ret...
eclipse-threadx/getting-started
C++
Other
310
/* STUSB1602 checks the VPU Over Voltage Protection Fault Transition (bit5 0x12 */
VPU_OVP_Fault_Trans_TypeDef STUSB1602_VPU_OVP_Fault_Trans_Get(uint8_t Addr)
/* STUSB1602 checks the VPU Over Voltage Protection Fault Transition (bit5 0x12 */ VPU_OVP_Fault_Trans_TypeDef STUSB1602_VPU_OVP_Fault_Trans_Get(uint8_t Addr)
{ STUSB1602_HW_FAULT_STATUS_TRANS_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_HW_FAULT_STATUS_TRANS_REG, 1); return (VPU_OVP_Fault_Trans_TypeDef)(reg.b.VPU_OVP_FAULT_TRANS); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Set the clock rate of the specified I2C port. The */
void xI2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
/* Set the clock rate of the specified I2C port. The */ void xI2CMasterInit(unsigned long ulBase, unsigned long ulI2CClk)
{ unsigned long ulHclk; unsigned long ulDiv; xASSERT((ulBase == I2C0_BASE)); xSysCtlPeripheralReset(xSYSCTL_PERIPH_I2C0); ulHclk = xSysCtlClockGet(); ulDiv = (unsigned long) (((ulHclk * 10)/(ulI2CClk * 4) + 5) / 10 - 1); xHWREG(ulBase + I2C_CLKDIV) = ulDiv; xHWREG(ulBase + I2C_CON) = 0; ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the baud rate speed in the termios structure. */
static void native_tty_baud_speed_set(struct termios *ter, int baudrate)
/* Set the baud rate speed in the termios structure. */ static void native_tty_baud_speed_set(struct termios *ter, int baudrate)
{ for (int i = 0; i < ARRAY_SIZE(baudrate_lut); i++) { if (baudrate_lut[i].baudrate == baudrate) { cfsetospeed(ter, baudrate_lut[i].termios_baudrate); cfsetispeed(ter, baudrate_lut[i].termios_baudrate); return; } } ERROR("Could not set baudrate, as %d is not supported.\n", baudrate); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Sets the value of the RTC match 0 register. */
void HibernateRTCMatch0Set(unsigned long ulMatch)
/* Sets the value of the RTC match 0 register. */ void HibernateRTCMatch0Set(unsigned long ulMatch)
{ HWREG(HIB_RTCM0) = ulMatch; HibernateWriteComplete(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI PciSegmentWrite16(IN UINT64 Address, IN UINT16 Value)
{ ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1); return (UINT16)DxePciSegmentLibPciRootBridgeIoWriteWorker (Address, EfiPciWidthUint16, Value); }
tianocore/edk2
C++
Other
4,240
/* Setup interrupt frequency during suppression (timeout if the frame count isn't filled). */
static void setup_queue_timers(struct velocity_info *vptr)
/* Setup interrupt frequency during suppression (timeout if the frame count isn't filled). */ static void setup_queue_timers(struct velocity_info *vptr)
{ if (vptr->rev_id >= REV_ID_VT3216_A0) { u8 txqueue_timer = 0; u8 rxqueue_timer = 0; if (vptr->mii_status & (VELOCITY_SPEED_1000 | VELOCITY_SPEED_100)) { txqueue_timer = vptr->options.txqueue_timer; rxqueue_timer = vptr->options.rxqueue_timer; } writeb(txqueue_timer, &vptr->mac_regs->TQETMR); wr...
robutest/uclinux
C++
GPL-2.0
60
/* Fills each TIM_OCInitStruct member with its default value. */
void TIM_OCStructInit(TIM_OCInitTypeDef *TIM_OCInitStruct)
/* Fills each TIM_OCInitStruct member with its default value. */ void TIM_OCStructInit(TIM_OCInitTypeDef *TIM_OCInitStruct)
{ TIM_OCInitStruct->TIM_OCMode = TIM_OCMode_Timing; TIM_OCInitStruct->TIM_OutputState = TIM_OutputState_Disable; TIM_OCInitStruct->TIM_OutputNState = TIM_OutputNState_Disable; TIM_OCInitStruct->TIM_Pulse = 0x0000000; TIM_OCInitStruct->TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStruct->TIM_O...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The only special thing we need to do here is to make sure that all jbd2_journal_stop calls result in the superblock being marked dirty, so that sync() will call the filesystem's write_super callback if appropriate. */
int __ext4_journal_stop(const char *where, handle_t *handle)
/* The only special thing we need to do here is to make sure that all jbd2_journal_stop calls result in the superblock being marked dirty, so that sync() will call the filesystem's write_super callback if appropriate. */ int __ext4_journal_stop(const char *where, handle_t *handle)
{ struct super_block *sb; int err; int rc; if (!ext4_handle_valid(handle)) { ext4_put_nojournal(handle); return 0; } sb = handle->h_transaction->t_journal->j_private; err = handle->h_err; rc = jbd2_journal_stop(handle); if (!err) err = rc; if (err) __ext4_std_error(sb, where, err); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Turn off the SSP port, optionally powering it down. */
void ssp_disable(void)
/* Turn off the SSP port, optionally powering it down. */ void ssp_disable(void)
{ Ser4SSCR0 &= ~SSCR0_SSE; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* for IVOP addbits == 0 for PVOP addbits == fcode - 1 for BVOP addbits == max(fcode,bcode) - 1 returns true or false */
int check_resync_marker(Bitstream *bs, int addbits)
/* for IVOP addbits == 0 for PVOP addbits == fcode - 1 for BVOP addbits == max(fcode,bcode) - 1 returns true or false */ int check_resync_marker(Bitstream *bs, int addbits)
{ uint32_t nbits; uint32_t code; uint32_t nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + addbits; nbits = BitstreamNumBitsToByteAlign(bs); code = BitstreamShowBits(bs, nbits); if (code == (((uint32_t)1 << (nbits - 1)) - 1)) { return BitstreamShowBitsFromByteAlign(bs, nbitsresyncmarker) == RESYNC_MARKER; } re...
DC-SWAT/DreamShell
C++
null
404
/* Checks a character for being a separators in the command line input. */
int32_t Cli_IsSeparator(uint8_t c)
/* Checks a character for being a separators in the command line input. */ int32_t Cli_IsSeparator(uint8_t c)
{ return ((c == SPC_) || (c == TAB_) || (c == ',')) ? UART_TRUE : UART_FALSE; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry of the doubly linked list. */
VOID EFIAPI NetListInsertBefore(IN OUT LIST_ENTRY *PostEntry, IN OUT LIST_ENTRY *NewEntry)
/* Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry of the doubly linked list. */ VOID EFIAPI NetListInsertBefore(IN OUT LIST_ENTRY *PostEntry, IN OUT LIST_ENTRY *NewEntry)
{ ASSERT (PostEntry != NULL && NewEntry != NULL); NewEntry->ForwardLink = PostEntry; NewEntry->BackLink = PostEntry->BackLink; PostEntry->BackLink->ForwardLink = NewEntry; PostEntry->BackLink = NewEntry; }
tianocore/edk2
C++
Other
4,240
/* Check whether the pointed buffer are all 0xff (blank). */
static int blank_check(u8 *buf, int len)
/* Check whether the pointed buffer are all 0xff (blank). */ static int blank_check(u8 *buf, int len)
{ int i; for (i = 0; i < len; i++) if (buf[i] != 0xFF) return 0; return 1; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Pass control to next thread that is in state READY. */
static osStatus_t svcRtxThreadYield(void)
/* Pass control to next thread that is in state READY. */ static osStatus_t svcRtxThreadYield(void)
{ thread_running = osRtxThreadGetRunning(); thread_ready = osRtxInfo.thread.ready.thread_list; if ((thread_ready != NULL) && (thread_ready->priority == thread_running->priority)) { osRtxThreadListRemove(thread_ready); osRtxThreadReadyPut(thread_running); EvrRtxThreadPreempted(thr...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Return a buffer to the list of free buffers, it was in use, but is not now. */
void MAC_release_buffer(unsigned char *pcBufferToRelease)
/* Return a buffer to the list of free buffers, it was in use, but is not now. */ void MAC_release_buffer(unsigned char *pcBufferToRelease)
{ long lIndex; for( lIndex = 0; lIndex < macNUM_BUFFERS; lIndex++ ) { if( pucBufferToRelease == &( xMACBuffers.ucBuffer[ lIndex ][ 0 ] ) ) { ucMACBufferInUse[ lIndex ] = pdFALSE; break; } } configASSERT( lIndex < macNUM_BUFFERS ); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* If HmacSha384Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI HmacSha384SetKey(OUT VOID *HmacSha384Context, IN CONST UINT8 *Key, IN UINTN KeySize)
/* If HmacSha384Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI HmacSha384SetKey(OUT VOID *HmacSha384Context, IN CONST UINT8 *Key, IN UINTN KeySize)
{ return HmacMdSetKey (MBEDTLS_MD_SHA384, HmacSha384Context, Key, KeySize); }
tianocore/edk2
C++
Other
4,240
/* Initiates temperature measurement on the barometric pressure sensor and reads pressure from it. */
uint32_t BMP_getTemperature(float *temperature)
/* Initiates temperature measurement on the barometric pressure sensor and reads pressure from it. */ uint32_t BMP_getTemperature(float *temperature)
{ int8_t result; int32_t uncompTemp; int32_t uncompPressure; int32_t compTemp; if( bmp280PowerMode == BMP280_NORMAL_MODE ) { result = bmp280_read_uncomp_temperature( &uncompTemp ); } else { result = bmp280_get_forced_uncomp_pressure_temperature( &uncompPressure, &uncompTemp ); } i...
remotemcu/remcu-chip-sdks
C++
null
436
/* USBH_GetFreeChannel Get a free channel number for allocation to a device endpoint. */
static uint16_t USBH_GetFreeChannel(USB_OTG_CORE_HANDLE *pdev)
/* USBH_GetFreeChannel Get a free channel number for allocation to a device endpoint. */ static uint16_t USBH_GetFreeChannel(USB_OTG_CORE_HANDLE *pdev)
{ uint8_t idx = 0; for (idx = 0 ; idx < HC_MAX ; idx++) { if ((pdev->host.channel[idx] & HC_USED) == 0) { return idx; } } return HC_ERROR; }
MaJerle/stm32f429
C++
null
2,036
/* Checks whether the specified CAN interrupt has occurred or not. */
ITStatus CAN_GetITStatus(CAN_TypeDef *can, u32 it)
/* Checks whether the specified CAN interrupt has occurred or not. */ ITStatus CAN_GetITStatus(CAN_TypeDef *can, u32 it)
{ return (ITStatus)((can->IR & it) != it) ? RESET : SET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable or disable PWM output of the specified TMR2 channel. */
void TMR2_PWM_OutputCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, en_functional_state_t enNewState)
/* Enable or disable PWM output of the specified TMR2 channel. */ void TMR2_PWM_OutputCmd(CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch, en_functional_state_t enNewState)
{ uint32_t u32PCONRAddr; uint8_t au8EnPos[] = {TMR2_PCONR_OUTENA_POS, TMR2_PCONR_OUTENB_POS}; DDL_ASSERT(IS_TMR2_UNIT(TMR2x)); DDL_ASSERT(IS_TMR2_CH(u32Ch)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); u32PCONRAddr = (uint32_t)&TMR2x->PCONR; WRITE_REG32(PERIPH_BIT_BAND(u32PCONRAddr, au8EnPo...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Written by Sven Verdoolaege, K.U.Leuven, Departement Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */
int main(int argc, char **argv)
/* Written by Sven Verdoolaege, K.U.Leuven, Departement Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */ int main(int argc, char **argv)
{ struct isl_ctx *ctx = isl_ctx_alloc(); struct isl_basic_set *bset; struct isl_vec *sample; isl_printer *p; bset = isl_basic_set_read_from_file(ctx, stdin); sample = isl_basic_set_sample_vec(isl_basic_set_copy(bset)); p = isl_printer_to_file(ctx, stdout); p = isl_printer_print_vec(p, sample); p = isl_printer_...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */
int main(int argc, char **argv)
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */ int main(int argc, char **argv)
{ int total, i; if (SDL_Init(SDL_INIT_VIDEO) < 0) { SDL_Log("SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError()); return 1; } total = SDL_GetNumVideoDisplays(); for (i = 0; i < total; i++) { SDL_Rect bounds = { -1,-1,-1,-1 }, usable = { -1,-1,-1,-1 }; SDL_GetDisplay...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Initiate a nice (hopefully) shutdown of Linux. We simply are going to try and send the init process a SIGINT signal. If this fails (why?), we'll simply force it off in a not-so-nice manner. */
static int shutdown(void)
/* Initiate a nice (hopefully) shutdown of Linux. We simply are going to try and send the init process a SIGINT signal. If this fails (why?), we'll simply force it off in a not-so-nice manner. */ static int shutdown(void)
{ int rc = kill_cad_pid(SIGINT, 1); if (rc) { printk(KERN_ALERT "mf.c: SIGINT to init failed (%d), " "hard shutdown commencing\n", rc); mf_power_off(); } else printk(KERN_INFO "mf.c: init has been successfully notified " "to proceed with shutdown\n"); return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for checking if a user flag has been acquired. */
static bool user_flag_is_acquired(ble_conn_state_user_flag_id_t flag_id)
/* Function for checking if a user flag has been acquired. */ static bool user_flag_is_acquired(ble_conn_state_user_flag_id_t flag_id)
{ return ((m_bcs.acquired_flags & (1 << flag_id)) != 0); }
labapart/polymcu
C++
null
201
/* Config the ADC peripheral according to the specified parameters in the adcConfig. */
void ADC_Config(ADC_T *adc, ADC_Config_T *adcConfig)
/* Config the ADC peripheral according to the specified parameters in the adcConfig. */ void ADC_Config(ADC_T *adc, ADC_Config_T *adcConfig)
{ uint32_t reg; reg = adc->CTRL1; reg &= 0xFFF0FEFF; reg |= (uint32_t)((adcConfig->mode) | ((uint32_t)adcConfig->scanConvMode << 8)); adc->CTRL1 = reg; reg = adc->CTRL2; reg &= 0xFFF1F7FD; reg |= (uint32_t)adcConfig->dataAlign | \ (uint32_t)adcConfig->externalTrigConv | \ ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Helper function stating whether the gyro is on or off. */
int inv_get_gyro_on()
/* Helper function stating whether the gyro is on or off. */ int inv_get_gyro_on()
{ return (sensors.gyro.status & INV_SENSOR_ON) == INV_SENSOR_ON; }
Luos-io/luos_engine
C++
MIT License
496
/* fc_timeout_error() - Handler for fcp_pkt timeouts @fsp: The FCP packt that has timed out */
static void fc_timeout_error(struct fc_fcp_pkt *)
/* fc_timeout_error() - Handler for fcp_pkt timeouts @fsp: The FCP packt that has timed out */ static void fc_timeout_error(struct fc_fcp_pkt *)
{ fsp->status_code = FC_CMD_TIME_OUT; fsp->cdb_status = 0; fsp->io_status = 0; fc_fcp_send_abort(fsp); }
robutest/uclinux
C++
GPL-2.0
60
/* The hardware priority mechanism only looks at the upper N bits of the priority level (where N is 3 for the Tiva C and E Series family), so any prioritization must be performed in those bits. The remaining bits can be used to sub-prioritize the interrupt sources, and may be used by the hardware priority mechanism on ...
void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority)
/* The hardware priority mechanism only looks at the upper N bits of the priority level (where N is 3 for the Tiva C and E Series family), so any prioritization must be performed in those bits. The remaining bits can be used to sub-prioritize the interrupt sources, and may be used by the hardware priority mechanism on ...
{ uint32_t ui32Temp; ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS)); ui32Temp = HWREG(g_pui32Regs[ui32Interrupt >> 2]); ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3))); ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3)); HWREG(g_pui32Regs[ui32Interrupt >> 2]) = ui32Temp; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Free a buffer of the DMA program buffer. */
static void XDmaPs_BufPool_Free(XDmaPs_ProgBuf *Pool, void *Buf)
/* Free a buffer of the DMA program buffer. */ static void XDmaPs_BufPool_Free(XDmaPs_ProgBuf *Pool, void *Buf)
{ int Index; Xil_AssertVoid(Pool != NULL); for (Index = 0; Index < XDMAPS_MAX_CHAN_BUFS; Index++) { if (Pool[Index].Buf == Buf) { if (Pool[Index].Allocated) { Pool[Index].Allocated = 0; } } } }
ua1arn/hftrx
C++
null
69
/* Copies data into an arbitrary memory location from an array of pages The copy is assumed to be non-overlapping. */
static void _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len)
/* Copies data into an arbitrary memory location from an array of pages The copy is assumed to be non-overlapping. */ static void _copy_from_pages(char *p, struct page **pages, size_t pgbase, size_t len)
{ struct page **pgfrom; char *vfrom; size_t copy; pgfrom = pages + (pgbase >> PAGE_CACHE_SHIFT); pgbase &= ~PAGE_CACHE_MASK; do { copy = PAGE_CACHE_SIZE - pgbase; if (copy > len) copy = len; vfrom = kmap_atomic(*pgfrom, KM_USER0); memcpy(p, vfrom + pgbase, copy); kunmap_atomic(vfrom, KM_USER0); pgb...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Copies data currently in flash to the block->data and sets the base address. */
static blt_bool FlashInitBlock(tFlashBlockInfo *block, blt_addr address)
/* Copies data currently in flash to the block->data and sets the base address. */ static blt_bool FlashInitBlock(tFlashBlockInfo *block, blt_addr address)
{ blt_int8u oldPage; if ((address % FLASH_WRITE_BLOCK_SIZE) != 0) { return BLT_FALSE; } if (block->base_addr == address) { return BLT_TRUE; } block->base_addr = address; oldPage = FLASH_PPAGE_REG; FLASH_PPAGE_REG = FlashGetPhysPage(address); CpuMemCopy((blt_addr)block->data, (blt_addr)Flas...
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function gets the options for the QSPI device. The options control how the device behaves relative to the QSPI bus. */
u32 XQspiPs_GetOptions(XQspiPs *InstancePtr)
/* This function gets the options for the QSPI device. The options control how the device behaves relative to the QSPI bus. */ u32 XQspiPs_GetOptions(XQspiPs *InstancePtr)
{ u32 OptionsFlag = 0; u32 ConfigReg; unsigned int Index; Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); ConfigReg = XQspiPs_ReadReg(InstancePtr->Config.BaseAddress, XQSPIPS_CR_OFFSET); for (Index = 0; Index < XQSPIPS_NUM_OPTIONS; Index++) { ...
ua1arn/hftrx
C++
null
69
/* Read the photo data from the PTC08 memory. */
xtBoolean PTC08PhotoDataGet(unsigned char *pucBuffer, unsigned long ulAddr, unsigned long ulLen)
/* Read the photo data from the PTC08 memory. */ xtBoolean PTC08PhotoDataGet(unsigned char *pucBuffer, unsigned long ulAddr, unsigned long ulLen)
{ unsigned long i; ucGetPhotoCmd[8] = ulAddr/256; ucGetPhotoCmd[9] = ulAddr%256; ucGetPhotoCmd[12] =ulLen/256; ucGetPhotoCmd[13] =ulLen%256; UARTBufferPut(PTC08_UART, (unsigned char *)&ucGetPhotoCmd[0], 16); if (!UARTBufferGet(PTC08_UART, pucBuffer, 10+ulLen)) { return xfalse; ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Disable Titan-e multicast addresses. Returns: VXGE_HW_OK - success. VXGE_HW_ERR_INVALID_HANDLE - Invalid handle */
enum vxge_hw_status vxge_hw_vpath_mcast_disable(struct __vxge_hw_vpath_handle *vp)
/* Disable Titan-e multicast addresses. Returns: VXGE_HW_OK - success. VXGE_HW_ERR_INVALID_HANDLE - Invalid handle */ enum vxge_hw_status vxge_hw_vpath_mcast_disable(struct __vxge_hw_vpath_handle *vp)
{ u64 val64; struct __vxge_hw_virtualpath *vpath; enum vxge_hw_status status = VXGE_HW_OK; if ((vp == NULL) || (vp->vpath->ringh == NULL)) { status = VXGE_HW_ERR_INVALID_HANDLE; goto exit; } vpath = vp->vpath; val64 = readq(&vpath->vp_reg->rxmac_vcfg0); if (val64 & VXGE_HW_RXMAC_VCFG0_MCAST_ALL_ADDR_EN) { ...
robutest/uclinux
C++
GPL-2.0
60
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
{ if(huart->Instance==USART1) { __HAL_RCC_USART1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7); } else if(huart->Instance==USART2) { __HAL_RCC_USART2_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables reception of all the frames to application. GMAC passes all the frames received to application irrespective of whether they pass SA/DA address filtering or not. */
void synopGMAC_frame_filter_enable(synopGMACdevice *gmacdev)
/* Enables reception of all the frames to application. GMAC passes all the frames received to application irrespective of whether they pass SA/DA address filtering or not. */ void synopGMAC_frame_filter_enable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase, GmacFrameFilter, GmacFilter); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* self_check_seen - check whether all PEB have been seen by fastmap. @ubi: UBI device description object @seen: integer array of @ubi->peb_count size */
static int self_check_seen(struct ubi_device *ubi, int *seen)
/* self_check_seen - check whether all PEB have been seen by fastmap. @ubi: UBI device description object @seen: integer array of @ubi->peb_count size */ static int self_check_seen(struct ubi_device *ubi, int *seen)
{ int pnum, ret = 0; if (!ubi_dbg_chk_fastmap(ubi) || !seen) return 0; for (pnum = 0; pnum < ubi->peb_count; pnum++) { if (!seen[pnum] && ubi->lookuptbl[pnum]) { ubi_err(ubi, "self-check failed for PEB %d, fastmap didn't see it", pnum); ret = -EINVAL; } } return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This routine prepares the mailbox command for unregistering a remote N_Port/F_Port (DID) login. */
void lpfc_unreg_did(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, LPFC_MBOXQ_t *pmb)
/* This routine prepares the mailbox command for unregistering a remote N_Port/F_Port (DID) login. */ void lpfc_unreg_did(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, LPFC_MBOXQ_t *pmb)
{ MAILBOX_t *mb; mb = &pmb->u.mb; memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); mb->un.varUnregDID.did = did; if (vpi != 0xffff) vpi += phba->vpi_base; mb->un.varUnregDID.vpi = vpi; mb->mbxCommand = MBX_UNREG_D_ID; mb->mbxOwner = OWN_HOST; return; }
robutest/uclinux
C++
GPL-2.0
60
/* Writes the current value of MM5. This function is only available on IA32 and X64. */
VOID EFIAPI AsmWriteMm5(IN UINT64 Value)
/* Writes the current value of MM5. This function is only available on IA32 and X64. */ VOID EFIAPI AsmWriteMm5(IN UINT64 Value)
{ __asm__ __volatile__ ( "movd %0, %%mm5" : : "m" (Value) ); }
tianocore/edk2
C++
Other
4,240
/* spider_net_probe initializes pdev and registers a net_device structure for it. After that, the device can be ifconfig'ed up */
static int __devinit spider_net_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* spider_net_probe initializes pdev and registers a net_device structure for it. After that, the device can be ifconfig'ed up */ static int __devinit spider_net_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ int err = -EIO; struct spider_net_card *card; card = spider_net_setup_pci_dev(pdev); if (!card) goto out; spider_net_workaround_rxramfull(card); spider_net_init_card(card); err = spider_net_setup_phy(card); if (err) goto out_undo_pci; err = spider_net_setup_netdev(card); if (err) goto out_undo_pci; r...
robutest/uclinux
C++
GPL-2.0
60
/* Message: DisplayTextMessage Opcode: 0x0099 Type: CallControl Direction: pbx2dev VarLength: no */
static void handle_DisplayTextMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: DisplayTextMessage Opcode: 0x0099 Type: CallControl Direction: pbx2dev VarLength: no */ static void handle_DisplayTextMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_text, 32, ENC_ASCII|ENC_NA); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* checks whether source address filter failed in the rx frame. */
bool synopGMAC_is_sa_filter_failed(DmaDesc *desc)
/* checks whether source address filter failed in the rx frame. */ bool synopGMAC_is_sa_filter_failed(DmaDesc *desc)
{ return ((desc->status & DescSAFilterFail) == DescSAFilterFail); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Open SIR (IrDA) mode on the specified UART. */
void UARTIrDAConfig(unsigned long ulBase, unsigned long ulConfig)
/* Open SIR (IrDA) mode on the specified UART. */ void UARTIrDAConfig(unsigned long ulBase, unsigned long ulConfig)
{ xASSERT(UARTBaseValid(ulBase)); UARTModeSet(ulBase, USART_FUN_SEL_IRDA_EN); xHWREG(ulBase + USART_IRCR) &= 0xFFFF00C0; xHWREG(ulBase + USART_IRCR) |= ulConfig; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This API reads the FIFO data of Accel and/or Mag sensor. */
uint16_t bma4_read_fifo_data(struct bma4_dev *dev)
/* This API reads the FIFO data of Accel and/or Mag sensor. */ uint16_t bma4_read_fifo_data(struct bma4_dev *dev)
{ uint16_t rslt = 0; uint8_t data = 0; uint8_t addr = BMA4_FIFO_DATA_ADDR; if (dev == NULL || dev->fifo == NULL || dev->fifo->data == NULL) { rslt |= BMA4_E_NULL_PTR; } else { reset_fifo_data_structure(dev); if (dev->interface == BMA4_SPI_INTERFACE) addr = addr | ...
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Resets the RCC clock configuration to the default reset state. */
void RCC_DeInit(void)
/* Resets the RCC clock configuration to the default reset state. */ void RCC_DeInit(void)
{ RCC->CTRLSTS |= (uint32_t)0x00000004; RCC->CFG &= (uint32_t)0xF8FFC000; RCC->CTRL &= (uint32_t)0xFEF6FFFE; RCC->CTRL &= (uint32_t)0xFFFBFFFF; RCC->CFG &= (uint32_t)0xF700FFFF; RCC->CFG2 = 0x00007000; RCC->CFG3 = 0x00003800; RCC->RDCTRL = 0x00000000; RCC->PLLHSIPRE = 0x00000000; ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @hsotg: The HCD state structure @qh: QH to remove from schedule */
void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
/* @hsotg: The HCD state structure @qh: QH to remove from schedule */ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
{ u32 intr_mask; dev_vdbg(hsotg->dev, "%s()\n", __func__); if (list_empty(&qh->qh_list_entry)) return; if (dwc2_qh_is_non_per(qh)) { if (hsotg->non_periodic_qh_ptr == &qh->qh_list_entry) hsotg->non_periodic_qh_ptr = hsotg->non_periodic_qh_ptr->next; list_del_init(&qh->qh_list_entry); return; } dwc...
EmcraftSystems/linux-emcraft
C++
Other
266
/* We spread the allocation around to reduce the possibility of two consecutive opened @neh's getting the same context ID assigned (to avoid surprises with late events that timed out long time ago). So first we search from where @rc->ctx_roll is, if not found, we search from zero. */
static int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh)
/* We spread the allocation around to reduce the possibility of two consecutive opened @neh's getting the same context ID assigned (to avoid surprises with late events that timed out long time ago). So first we search from where @rc->ctx_roll is, if not found, we search from zero. */ static int __uwb_rc_ctx_get(struct...
{ int result; result = find_next_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX, rc->ctx_roll++); if (result < UWB_RC_CTX_MAX) goto found; result = find_first_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX); if (result < UWB_RC_CTX_MAX) goto found; return -ENFILE; found: set_bit(result, rc->ctx_bm); neh->context = result...
robutest/uclinux
C++
GPL-2.0
60
/* the init funtion of timer the internal called function of rt_timer_init */
static void _rt_timer_init(rt_timer_t timer, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
/* the init funtion of timer the internal called function of rt_timer_init */ static void _rt_timer_init(rt_timer_t timer, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
{ int i; timer->parent.flag = flag; timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; timer->timeout_func = timeout; timer->parameter = parameter; timer->timeout_tick = 0; timer->init_tick = time; for (i = 0; i < RT_TIMER_SKIP_LIST_LEVEL; i++) { rt_list_init(&(timer->row...
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns the most recent received data by the SPIx peripheral. */
uint32_t SPI_ReceiveData(SPI_TypeDef *SPIx)
/* Returns the most recent received data by the SPIx peripheral. */ uint32_t SPI_ReceiveData(SPI_TypeDef *SPIx)
{ uint32_t temp = 0; assert_param(IS_SPI_ALL_PERIPH(SPIx)); temp = temp; temp |= (uint32_t)SPIx->RXREG; if(SPIx->EXTCTL > 8 || SPIx->EXTCTL == 0) temp |= (uint32_t) (SPIx->RXREG) << 8; if(SPIx->EXTCTL > 16 || SPIx->EXTCTL == 0) temp |= (uint32_t)( SPIx->RXREG) << 16; if(SPIx->EXTCTL > 2...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unregister an IB device. All clients will receive a remove callback. */
void ib_unregister_device(struct ib_device *device)
/* Unregister an IB device. All clients will receive a remove callback. */ void ib_unregister_device(struct ib_device *device)
{ struct ib_client *client; struct ib_client_data *context, *tmp; unsigned long flags; mutex_lock(&device_mutex); list_for_each_entry_reverse(client, &client_list, list) if (client->remove) client->remove(device); list_del(&device->core_list); kfree(device->gid_tbl_len); kfree(device->pkey_tbl_len); mutex...
robutest/uclinux
C++
GPL-2.0
60
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration of the USB device after enumeration - the device endpoints are configured. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ bool ConfigSuccess = true; ConfigSuccess &= Endpoint_ConfigureEndpoint(VENDOR_IN_EPADDR, EP_TYPE_BULK, VENDOR_IO_EPSIZE, 1); ConfigSuccess &= Endpoint_ConfigureEndpoint(VENDOR_OUT_EPADDR, EP_TYPE_BULK, VENDOR_IO_EPSIZE, 1); LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
/* This function is called when an UDP datagrm has been received on the port UDP_PORT. */ void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{ udp_connect(upcb, addr, UDP_CLIENT_PORT); udp_send(upcb, p); udp_disconnect(upcb); pbuf_free(p); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Enables DMA request sources in the DES module. */
void DESDMAEnable(uint32_t ui32Base, uint32_t ui32Flags)
/* Enables DMA request sources in the DES module. */ void DESDMAEnable(uint32_t ui32Base, uint32_t ui32Flags)
{ ASSERT(ui32Base == DES_BASE); ASSERT((ui32Flags & DES_DMA_CONTEXT_IN) || (ui32Flags & DES_DMA_DATA_OUT) || (ui32Flags & DES_DMA_DATA_IN)); HWREG(ui32Base + DES_O_SYSCONFIG) |= ui32Flags; }
micropython/micropython
C++
Other
18,334
/* Attach to the i2c FCU after detecting U3-1 bus */
static int attach_fcu(void)
/* Attach to the i2c FCU after detecting U3-1 bus */ static int attach_fcu(void)
{ fcu = attach_i2c_chip(FAN_CTRLER_ID, "fcu"); if (fcu == NULL) return -ENODEV; DBG("FCU attached\n"); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns success (0) or appropriate error code (none as of now) */
static void emac_set_type2addr(struct emac_priv *priv, u32 ch, char *mac_addr, int index, int match)
/* Returns success (0) or appropriate error code (none as of now) */ static void emac_set_type2addr(struct emac_priv *priv, u32 ch, char *mac_addr, int index, int match)
{ u32 val; emac_write(EMAC_MACINDEX, index); val = ((mac_addr[3] << 24) | (mac_addr[2] << 16) | \ (mac_addr[1] << 8) | (mac_addr[0])); emac_write(EMAC_MACADDRHI, val); val = ((mac_addr[5] << 8) | mac_addr[4] | ((ch & 0x7) << 16) | \ (match << 19) | BIT(20)); emac_write(EMAC_MACADDRLO, val); emac_...
robutest/uclinux
C++
GPL-2.0
60
/* Get the internal database type of the given column. */
static char* getcolumntype(PGconn *conn, PGresult *result, int i, char *buff)
/* Get the internal database type of the given column. */ static char* getcolumntype(PGconn *conn, PGresult *result, int i, char *buff)
{ if (PQntuples(res) > 0) { char *name = PQgetvalue(res, 0, 0); if (strcmp (name, "bpchar")==0 || strcmp (name, "varchar")==0) { int modifier = PQfmod (result, i) - 4; sprintf (buff, "%.20s (%d)", name, modifier); } else strncpy (buff, name, 20); } } PQclear(res); return buff; }
DC-SWAT/DreamShell
C++
null
404
/* brief DMA instance 0, channel 1 IRQ handler. */
void EDMA_0_CH1_DriverIRQHandler(void)
/* brief DMA instance 0, channel 1 IRQ handler. */ void EDMA_0_CH1_DriverIRQHandler(void)
{ EDMA_DriverIRQHandler(0U, 1U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check if the CRC field in the Partition table header is valid for Partition entry array. */
BOOLEAN PartitionCheckGptEntryArrayCRC(IN EFI_PARTITION_TABLE_HEADER *PartHeader, IN EFI_PARTITION_ENTRY *PartEntry)
/* Check if the CRC field in the Partition table header is valid for Partition entry array. */ BOOLEAN PartitionCheckGptEntryArrayCRC(IN EFI_PARTITION_TABLE_HEADER *PartHeader, IN EFI_PARTITION_ENTRY *PartEntry)
{ UINT32 Crc; UINTN Size; Size = (UINTN)MultU64x32 (PartHeader->NumberOfPartitionEntries, PartHeader->SizeOfPartitionEntry); Crc = CalculateCrc32 (PartEntry, Size); return (BOOLEAN)(PartHeader->PartitionEntryArrayCRC32 == Crc); }
tianocore/edk2
C++
Other
4,240
/* Return value: ptr to chip information on success / NULL on failure */
static const struct ipr_chip_t* __devinit ipr_get_chip_info(const struct pci_device_id *dev_id)
/* Return value: ptr to chip information on success / NULL on failure */ static const struct ipr_chip_t* __devinit ipr_get_chip_info(const struct pci_device_id *dev_id)
{ int i; for (i = 0; i < ARRAY_SIZE(ipr_chip); i++) if (ipr_chip[i].vendor == dev_id->vendor && ipr_chip[i].device == dev_id->device) return &ipr_chip[i]; return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the I2C 10-bit header only mode with read direction. */
void I2C_10BitAddressHeaderCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the I2C 10-bit header only mode with read direction. */ void I2C_10BitAddressHeaderCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR2 |= I2C_CR2_HEAD10R; } else { I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_HEAD10R); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The fops implementation of the character device driver */
static ssize_t do_write(struct urdev *urd, const char __user *udata, size_t count, size_t reclen, loff_t *ppos)
/* The fops implementation of the character device driver */ static ssize_t do_write(struct urdev *urd, const char __user *udata, size_t count, size_t reclen, loff_t *ppos)
{ struct ccw1 *cpa; int rc; cpa = alloc_chan_prog(udata, count / reclen, reclen); if (IS_ERR(cpa)) return PTR_ERR(cpa); rc = do_ur_io(urd, cpa); if (rc) goto fail_kfree_cpa; if (urd->io_request_rc) { rc = urd->io_request_rc; goto fail_kfree_cpa; } *ppos += count; rc = count; fail_kfree_cpa: free_chan...
robutest/uclinux
C++
GPL-2.0
60
/* This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values. */
uint8_t DComp_NextMouseInterface(void *CurrentDescriptor)
/* This comparator searches for the next Interface descriptor of the correct Mouse HID Class and Protocol values. */ uint8_t DComp_NextMouseInterface(void *CurrentDescriptor)
{ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); if (Header->Type == DTYPE_Interface) { USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); if ((Interface->Class == HID_CSCP_HIDClass) && (Interface->Pro...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Read Status Register. The RDSR instruction is for reading Status Register Bits. */
enum status_code mx25l_read_status(uint8_t *value)
/* Read Status Register. The RDSR instruction is for reading Status Register Bits. */ enum status_code mx25l_read_status(uint8_t *value)
{ enum status_code status; uint8_t tx_buf[1] = {MX25L_CMD_RDSR}; _mx25l_chip_select(); status = spi_write_buffer_wait(&_mx25l_spi, tx_buf, 1); if (status != STATUS_OK) { return STATUS_ERR_IO; } status = spi_read_buffer_wait(&_mx25l_spi, value, 1, 0); if (status != STATUS_OK) { return STATUS_ERR_IO; } _mx2...
memfault/zero-to-main
C++
null
200
/* Write a sequence of count value/register pairs. Returns -1 after the first failed write, or 0 for no errors. */
int sn9c102_write_regs(struct sn9c102_device *cam, const u8 valreg[][2], int count)
/* Write a sequence of count value/register pairs. Returns -1 after the first failed write, or 0 for no errors. */ int sn9c102_write_regs(struct sn9c102_device *cam, const u8 valreg[][2], int count)
{ struct usb_device* udev = cam->usbdev; u8* buff = cam->control_buffer; int i, res; for (i = 0; i < count; i++) { u8 index = valreg[i][1]; *buff = valreg[i][0]; res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41, index, 0, buff, 1, SN9C102_CTRL_TIMEOUT); if (res < 0) { ...
robutest/uclinux
C++
GPL-2.0
60
/* Clears (resets) the initialization flag. Requires unlocking backup domain write protection (PWR_CR_DBP) */
void rtc_clear_init_flag(void)
/* Clears (resets) the initialization flag. Requires unlocking backup domain write protection (PWR_CR_DBP) */ void rtc_clear_init_flag(void)
{ RTC_ISR &= ~RTC_ISR_INIT; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Fills each AES_IVInitStruct member with its default value. */
void AES_IVStructInit(AES_IVInitTypeDef *AES_IVInitStruct)
/* Fills each AES_IVInitStruct member with its default value. */ void AES_IVStructInit(AES_IVInitTypeDef *AES_IVInitStruct)
{ AES_IVInitStruct->AES_IV0 = 0x00000000; AES_IVInitStruct->AES_IV1 = 0x00000000; AES_IVInitStruct->AES_IV2 = 0x00000000; AES_IVInitStruct->AES_IV3 = 0x00000000; }
avem-labs/Avem
C++
MIT License
1,752
/* Scan for the next right leaf starting at node p->child Since we have back pointer, no recursion necessary. */
static struct leaf* leaf_walk_rcu(struct tnode *p, struct node *c)
/* Scan for the next right leaf starting at node p->child Since we have back pointer, no recursion necessary. */ static struct leaf* leaf_walk_rcu(struct tnode *p, struct node *c)
{ do { t_key idx; if (c) idx = tkey_extract_bits(c->key, p->pos, p->bits) + 1; else idx = 0; while (idx < 1u << p->bits) { c = tnode_get_child_rcu(p, idx++); if (!c) continue; if (IS_LEAF(c)) { prefetch(p->child[idx]); return (struct leaf *) c; } p = (struct tnode *) c; idx ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Change Logs: Date Author Notes Dystopia the first version This function will initial board. */
void rt_hw_board_init(void)
/* Change Logs: Date Author Notes Dystopia the first version This function will initial board. */ void rt_hw_board_init(void)
{ keystone_cpu_init(); rt_hw_interrupt_init(); rt_hw_system_timer_init(); rt_kprintf("heap: 0x%08x - 0x%08x\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END); rt_hw_system_timer_start(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */
struct device_node* of_find_compatible_node(struct device_node *from, const char *type, const char *compatible)
/* Returns a node pointer with refcount incremented, use of_node_put() on it when done. */ struct device_node* of_find_compatible_node(struct device_node *from, const char *type, const char *compatible)
{ struct device_node *np; read_lock(&devtree_lock); np = from ? from->allnext : allnodes; for (; np; np = np->allnext) { if (type && !(np->type && (of_node_cmp(np->type, type) == 0))) continue; if (of_device_is_compatible(np, compatible) && of_node_get(np)) break; } of_node_put(from); read_unlock...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Draws a polygon filled with the given texture. This standard version is calling multithreaded versions with NULL cache parameters. */
int texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy)
/* Draws a polygon filled with the given texture. This standard version is calling multithreaded versions with NULL cache parameters. */ int texturedPolygon(SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy)
{ return (texturedPolygonMT(dst, vx, vy, n, texture, texture_dx, texture_dy, NULL, NULL)); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function returns a reference to the window that should be used as a parent for child widgets and windows. This corresponds to the internal area inside borders and title bar. */
struct win_window* wtk_frame_as_parent(struct wtk_frame *frame)
/* This function returns a reference to the window that should be used as a parent for child widgets and windows. This corresponds to the internal area inside borders and title bar. */ struct win_window* wtk_frame_as_parent(struct wtk_frame *frame)
{ Assert(frame); return frame->contents; }
memfault/zero-to-main
C++
null
200
/* note This is an internal used function, upper layer should not use. */
void FLEXIO_MCULCD_ClearSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base)
/* note This is an internal used function, upper layer should not use. */ void FLEXIO_MCULCD_ClearSingleBeatWriteConfig(FLEXIO_MCULCD_Type *base)
{ uint32_t tempValue = base->flexioBase->TIMCTL[base->timerIndex]; tempValue &= ~(FLEXIO_TIMCTL_PINCFG_MASK); tempValue |= FLEXIO_TIMCTL_PINCFG(kFLEXIO_PinConfigBidirectionOutputData); base->flexioBase->TIMCTL[base->timerIndex] = tempValue; base->flexioBase->TIMCTL[base->timerIndex] = 0U; base->...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Notify the system that the SMM variable write driver is ready. */
VOID VariableNotifySmmWriteReady(VOID)
/* Notify the system that the SMM variable write driver is ready. */ VOID VariableNotifySmmWriteReady(VOID)
{ EFI_STATUS Status; EFI_HANDLE Handle; Handle = NULL; Status = gBS->InstallProtocolInterface ( &Handle, &gSmmVariableWriteGuid, EFI_NATIVE_INTERFACE, NULL ); ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* Enables or disables the temperature sensor and Vrefint channel. */
void ADC_TempSensorVrefintCmd(FunctionalState NewState)
/* Enables or disables the temperature sensor and Vrefint channel. */ void ADC_TempSensorVrefintCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADC->CCR |= (uint32_t)ADC_CCR_TSVREFE; } else { ADC->CCR &= (uint32_t)(~ADC_CCR_TSVREFE); } }
avem-labs/Avem
C++
MIT License
1,752
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */
int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
/* Returns the number of bytes received on success, or else the status code returned by the underlying usb_control_msg() call. */ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size)
{ int i; int result; memset(buf, 0, size); for (i = 0; i < 3; ++i) { result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CTRL_GET_TIMEOUT); if (result <= 0 && result != -ETIMEDOUT) continue; if (result > 1 && ((u8 *)b...
robutest/uclinux
C++
GPL-2.0
60
/* Retrieve ordinal number of the given adc hardware instance. */
static uint8_t _adc_get_hardware_index(const void *const hw)
/* Retrieve ordinal number of the given adc hardware instance. */ static uint8_t _adc_get_hardware_index(const void *const hw)
{ return ((uint32_t)hw - (uint32_t)ADC0) >> 10; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Selects the clock source to output on MCO pin. */
void RCC_MCOConfig(uint8_t RCC_MCO)
/* Selects the clock source to output on MCO pin. */ void RCC_MCOConfig(uint8_t RCC_MCO)
{ assert_param(IS_RCC_MCO(RCC_MCO)); if(RCC_MCO <= RCC_MCO_PLLCLK_Div2) { *(__IO uint8_t *) CFGR_BYTE4_ADDRESS = RCC_MCO; } else { *(__IO uint8_t *) CFGR_BYTE4_ADDRESS = RCC_MCO_PLLCLK_Div2; } RCC->RCC_MCO_VAL = RCC_MCO - 6; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate how many bytes are needed to represent a given number in EBML. */
static int ebml_num_size(uint64_t num)
/* Calculate how many bytes are needed to represent a given number in EBML. */ static int ebml_num_size(uint64_t num)
{ int bytes = 1; while ((num+1) >> bytes*7) bytes++; return bytes; }
DC-SWAT/DreamShell
C++
null
404
/* Set or clear the mask for an individual endpoint's interrupt request. */
static void s3c_hsotg_ctrl_epint(struct s3c_hsotg *hsotg, unsigned int ep, unsigned int dir_in, unsigned int en)
/* Set or clear the mask for an individual endpoint's interrupt request. */ static void s3c_hsotg_ctrl_epint(struct s3c_hsotg *hsotg, unsigned int ep, unsigned int dir_in, unsigned int en)
{ unsigned long flags; u32 bit = 1 << ep; u32 daint; if (!dir_in) bit <<= 16; local_irq_save(flags); daint = readl(hsotg->regs + S3C_DAINTMSK); if (en) daint |= bit; else daint &= ~bit; writel(daint, hsotg->regs + S3C_DAINTMSK); local_irq_restore(flags); }
robutest/uclinux
C++
GPL-2.0
60
/* this function write one digit to the SLCD DATA register */
void slcd_seg_digit_display(uint8_t ch, uint8_t position)
/* this function write one digit to the SLCD DATA register */ void slcd_seg_digit_display(uint8_t ch, uint8_t position)
{ while(slcd_flag_get(SLCD_FLAG_UPRF)); slcd_seg_digit_write(ch, position , INTEGER); slcd_data_update_request(); }
liuxuming/trochili
C++
Apache License 2.0
132
/* Enables or disables the double buffer mode for the selected DMA stream. */
void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef *DMAy_Streamx, FunctionalState NewState)
/* Enables or disables the double buffer mode for the selected DMA stream. */ void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef *DMAy_Streamx, FunctionalState NewState)
{ assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { DMAy_Streamx->CR |= (uint32_t)DMA_SxCR_DBM; } else { DMAy_Streamx->CR &= ~(uint32_t)DMA_SxCR_DBM; } }
MaJerle/stm32f429
C++
null
2,036
/* Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF). */
BOOLEAN EFIAPI HkdfSha384ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
/* Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF). */ BOOLEAN EFIAPI HkdfSha384ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
{ return HkdfMdExtractAndExpand (EVP_sha384 (), Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize); }
tianocore/edk2
C++
Other
4,240
/* Fixes: , AV: fixed OOM handling in fifo_open(), moved initialization there, switched to external allocation of pipe_inode_info. */
static void wait_for_partner(struct inode *inode, unsigned int *cnt)
/* Fixes: , AV: fixed OOM handling in fifo_open(), moved initialization there, switched to external allocation of pipe_inode_info. */ static void wait_for_partner(struct inode *inode, unsigned int *cnt)
{ int cur = *cnt; while (cur == *cnt) { pipe_wait(inode->i_pipe); if (signal_pending(current)) break; } }
robutest/uclinux
C++
GPL-2.0
60
/* Locks the Data memory and FLASH_PECR register access. */
void DATA_EEPROM_Lock(void)
/* Locks the Data memory and FLASH_PECR register access. */ void DATA_EEPROM_Lock(void)
{ FLASH->PECR |= FLASH_PECR_PELOCK; }
avem-labs/Avem
C++
MIT License
1,752
/* This function is a helper function for the wtk_frame_handler() function. It is called when a pointer MOVE event is sent to the container window. This function either starts or continues a drag operation, depending on current state. */
static void wtk_handle_frame_move(struct wtk_frame *frame, struct win_pointer_event const *event)
/* This function is a helper function for the wtk_frame_handler() function. It is called when a pointer MOVE event is sent to the container window. This function either starts or continues a drag operation, depending on current state. */ static void wtk_handle_frame_move(struct wtk_frame *frame, struct win_pointer_even...
{ switch (frame->state) { case WTK_FRAME_AWAITING_MOVE: if (wtk_is_drag_threshold_exceeded(&(event->pos))) { wtk_start_drag(&(event->pos)); frame->state = WTK_FRAME_MOVING; } break; case WTK_FRAME_MOVING: wtk_continue_drag(&(event->last_pos), &(event->pos)); break; default: break; } }
memfault/zero-to-main
C++
null
200
/* This function handles External line 1 interrupt request. */
void EXTI1_IRQHandler(void)
/* This function handles External line 1 interrupt request. */ void EXTI1_IRQHandler(void)
{ if(EXTI_GetITStatus(EXTI_Line1) != RESET) { if( Count==1) { PauseResumeStatus = 1; Count = 0; } else { PauseResumeStatus = 0; Count = 1; } EXTI_ClearITPendingBit(EXTI_Line1); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Note: these must be called with data->lock locked! */
static enum dma_emul_channel_state dma_emul_get_channel_state(const struct device *dev, uint32_t channel)
/* Note: these must be called with data->lock locked! */ static enum dma_emul_channel_state dma_emul_get_channel_state(const struct device *dev, uint32_t channel)
{ const struct dma_emul_config *config = dev->config; __ASSERT_NO_MSG(channel < config->num_channels); return (enum dma_emul_channel_state)config->xfer[channel].config._reserved; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* RETURNS: Number of executed taskfiles on success, 0 if _GTF doesn't exist. -errno on other errors. */
static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed)
/* RETURNS: Number of executed taskfiles on success, 0 if _GTF doesn't exist. -errno on other errors. */ static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed)
{ struct ata_acpi_gtf *gtf = NULL, *pgtf = NULL; int gtf_count, i, rc; rc = ata_dev_get_GTF(dev, &gtf); if (rc < 0) return rc; gtf_count = rc; for (i = 0; i < gtf_count; i++, gtf++) { rc = ata_acpi_run_tf(dev, gtf, pgtf); if (rc < 0) break; if (rc) { (*nr_executed)++; pgtf = gtf; } } ata_acpi...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Similar to pci_intx(pdev, 1), except that we make sure msi is off... */
static void ipath_enable_intx(struct pci_dev *pdev)
/* Similar to pci_intx(pdev, 1), except that we make sure msi is off... */ static void ipath_enable_intx(struct pci_dev *pdev)
{ u16 cw, new; int pos; pci_read_config_word(pdev, PCI_COMMAND, &cw); new = cw & ~PCI_COMMAND_INTX_DISABLE; if (new != cw) pci_write_config_word(pdev, PCI_COMMAND, new); pos = pci_find_capability(pdev, PCI_CAP_ID_MSI); if (pos) { pci_read_config_word(pdev, pos + PCI_MSI_FLAGS, &cw); new = cw & ~PCI_MSI_FLA...
robutest/uclinux
C++
GPL-2.0
60
/* Attribute read call back for the Long descriptor V2D3 attribute. */
static ssize_t read_long_des_v2d3(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
/* Attribute read call back for the Long descriptor V2D3 attribute. */ static ssize_t read_long_des_v2d3(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{ const uint8_t *value = attr->user_data; return bt_gatt_attr_read(conn, attr, buf, len, offset, value, sizeof(long_des_v2d3_value)); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* brief Return Frequency of SystickClock return Frequency of Systick Clock */
uint32_t CLOCK_GetSystickClkFreq(uint32_t id)
/* brief Return Frequency of SystickClock return Frequency of Systick Clock */ uint32_t CLOCK_GetSystickClkFreq(uint32_t id)
{ volatile uint32_t *pSystickClkDiv; pSystickClkDiv = &(SYSCON->SYSTICKCLKDIV0); uint32_t freq = 0U; switch (SYSCON->SYSTICKCLKSELX[id]) { case 0U: freq = CLOCK_GetCoreSysClkFreq() / ((((volatile uint32_t *)pSystickClkDiv)[(uint32_t)id] & 0xffU) + 1U); break; ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
/* If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI Sha1HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
{ SHA_CTX Context; if (HashValue == NULL) { return FALSE; } if ((Data == NULL) && (DataSize != 0)) { return FALSE; } if (!SHA1_Init (&Context)) { return FALSE; } if (!SHA1_Update (&Context, Data, DataSize)) { return FALSE; } if (!SHA1_Final (HashValue, &Context)) { return FALSE;...
tianocore/edk2
C++
Other
4,240
/* Set type attribute for mutex. See IEEE 1003.1 */
int pthread_mutexattr_settype(pthread_mutexattr_t *_attr, int type)
/* Set type attribute for mutex. See IEEE 1003.1 */ int pthread_mutexattr_settype(pthread_mutexattr_t *_attr, int type)
{ struct pthread_mutexattr *attr = (struct pthread_mutexattr *)_attr; int retc = EINVAL; if ((type == PTHREAD_MUTEX_NORMAL) || (type == PTHREAD_MUTEX_RECURSIVE) || (type == PTHREAD_MUTEX_ERRORCHECK)) { attr->type = type; retc = 0; } return retc; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* param base PDM base pointer. param handle PDM handle pointer. param channel PDM channel. param config channel config. param format data format. */
status_t PDM_TransferSetChannelConfig(PDM_Type *base, pdm_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config, uint32_t format)
/* param base PDM base pointer. param handle PDM handle pointer. param channel PDM channel. param config channel config. param format data format. */ status_t PDM_TransferSetChannelConfig(PDM_Type *base, pdm_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config, uint32_t format)
{ assert(handle != NULL); PDM_SetChannelConfig(base, channel, config); handle->format = format; if (handle->channelNums == 0U) { handle->startChannel = (uint8_t)channel; } handle->channelNums++; if (handle->channelNums > (uint8_t)FSL_FEATURE_PDM_CHANNEL_NUM) { return ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Note that anything more complicated than checking if no bits are toggling (including checking DQ5 for an error status) is tricky to get working correctly and is therefore not done (particulary with interleaved chips as each chip must be checked independantly of the others). */
static int __xipram chip_ready(struct map_info *map, unsigned long addr)
/* Note that anything more complicated than checking if no bits are toggling (including checking DQ5 for an error status) is tricky to get working correctly and is therefore not done (particulary with interleaved chips as each chip must be checked independantly of the others). */ static int __xipram chip_ready(struct ...
{ map_word d, t; d = map_read(map, addr); t = map_read(map, addr); return map_word_equal(map, d, t); }
robutest/uclinux
C++
GPL-2.0
60