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
/* Returns the bank number and pin offset within the bank. */
static void zynq_gpio_get_bank_pin(unsigned int pin_num, unsigned int *bank_num, unsigned int *bank_pin_num, struct udevice *dev)
/* Returns the bank number and pin offset within the bank. */ static void zynq_gpio_get_bank_pin(unsigned int pin_num, unsigned int *bank_num, unsigned int *bank_pin_num, struct udevice *dev)
{ struct zynq_gpio_platdata *platdata = dev_get_platdata(dev); u32 bank; for (bank = 0; bank < platdata->p_data->max_bank; bank++) { if (pin_num >= platdata->p_data->bank_min[bank] && pin_num <= platdata->p_data->bank_max[bank]) { *bank_num = bank; *bank_pin_num = pin_num - platdata->p_data->bank_...
4ms/stm32mp1-baremetal
C++
Other
137
/* Write contents of register REGNO in task TASK. */
int put_reg(struct task_struct *task, unsigned int regno, unsigned long data)
/* Write contents of register REGNO in task TASK. */ int put_reg(struct task_struct *task, unsigned int regno, unsigned long data)
{ if (regno == PT_USP) task->thread.usp = data; else if (regno < PT_MAX) ((unsigned long *)task_pt_regs(task))[regno] = data; else return -1; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configure the active edge or edges used by the counter when the LPTIM is clocked by an external clock source. */
void LPTIM_ConfigClock(LPTIM_Module *LPTIMx, uint32_t ClockFilter, uint32_t ClockPolarity)
/* Configure the active edge or edges used by the counter when the LPTIM is clocked by an external clock source. */ void LPTIM_ConfigClock(LPTIM_Module *LPTIMx, uint32_t ClockFilter, uint32_t ClockPolarity)
{ MODIFY_REG(LPTIMx->CFG, LPTIM_CFG_CLKFLT | LPTIM_CFG_CLKPOL, ClockFilter | ClockPolarity); }
pikasTech/PikaPython
C++
MIT License
1,403
/* after initial setup during probe() and get_info(), this init() callback ensures that the link is up and subsequent send() and recv() calls can exchange ethernet frames */
static int mcs7830_init(struct eth_device *eth, bd_t *bd)
/* after initial setup during probe() and get_info(), this init() callback ensures that the link is up and subsequent send() and recv() calls can exchange ethernet frames */ static int mcs7830_init(struct eth_device *eth, bd_t *bd)
{ struct ueth_data *dev = eth->priv; return mcs7830_init_common(dev->pusb_dev); }
4ms/stm32mp1-baremetal
C++
Other
137
/* vmsplice splices a user address range into a pipe. It can be thought of as splice-from-memory, where the regular splice is splice-from-file (or to file). In both cases the output is a pipe, naturally. */
static long vmsplice_to_pipe(struct file *file, const struct iovec __user *iov, unsigned long nr_segs, unsigned int flags)
/* vmsplice splices a user address range into a pipe. It can be thought of as splice-from-memory, where the regular splice is splice-from-file (or to file). In both cases the output is a pipe, naturally. */ static long vmsplice_to_pipe(struct file *file, const struct iovec __user *iov, unsigned long nr_segs, unsigned ...
{ struct pipe_inode_info *pipe; struct page *pages[PIPE_BUFFERS]; struct partial_page partial[PIPE_BUFFERS]; struct splice_pipe_desc spd = { .pages = pages, .partial = partial, .flags = flags, .ops = &user_page_pipe_buf_ops, .spd_release = spd_release_page, }; pipe = pipe_info(file->f_path.dentry->d_ino...
robutest/uclinux
C++
GPL-2.0
60
/* Adjusts the Multi Speed oscillator (MSI) calibration value. */
void RCC_SetMsiCalibValue(uint8_t MSICalibrationValue)
/* Adjusts the Multi Speed oscillator (MSI) calibration value. */ void RCC_SetMsiCalibValue(uint8_t MSICalibrationValue)
{ uint32_t tmpregister = 0; tmpregister = RCC->CTRLSTS; tmpregister &= CTRLSTS_MSITRIM_MASK; tmpregister |= (uint32_t)MSICalibrationValue << 15; RCC->CTRLSTS = tmpregister; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Is scheduled to transmit a frame after a delay */
static void sendframe_task_handler(struct hndrte_timer *t)
/* Is scheduled to transmit a frame after a delay */ static void sendframe_task_handler(struct hndrte_timer *t)
{ struct tx_task *task = (struct tx_task *) t->data; if (task->txrepetitions != 0 && task->txperiodicity > 0) { sendframe_repeatedly(task); } else { sendframe(task->wlc, task->p, task->fifo, task->rate); free(task); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get the parent device driver (us) structure from a child function device */
static struct sa1111* sa1111_chip_driver(struct sa1111_dev *sadev)
/* Get the parent device driver (us) structure from a child function device */ static struct sa1111* sa1111_chip_driver(struct sa1111_dev *sadev)
{ return (struct sa1111 *)dev_get_drvdata(sadev->dev.parent); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If PRC_RXD_DOORBELL_VPn.NEW_QW_CNT is larger or equal to PRC_CFG6_VPn.RXD_SPAT then a leak has occurred. Returns: VXGE_HW_FAIL, if leak has occurred. */
enum vxge_hw_status vxge_hw_vpath_check_leak(struct __vxge_hw_ring *ring)
/* If PRC_RXD_DOORBELL_VPn.NEW_QW_CNT is larger or equal to PRC_CFG6_VPn.RXD_SPAT then a leak has occurred. Returns: VXGE_HW_FAIL, if leak has occurred. */ enum vxge_hw_status vxge_hw_vpath_check_leak(struct __vxge_hw_ring *ring)
{ enum vxge_hw_status status = VXGE_HW_OK; u64 rxd_new_count, rxd_spat; if (ring == NULL) return status; rxd_new_count = readl(&ring->vp_reg->prc_rxd_doorbell); rxd_spat = readq(&ring->vp_reg->prc_cfg6); rxd_spat = VXGE_HW_PRC_CFG6_RXD_SPAT(rxd_spat); if (rxd_new_count >= rxd_spat) status = VXGE_HW_FAIL; re...
robutest/uclinux
C++
GPL-2.0
60
/* Selects the Queue Of Context Mode for injected channels. */
void ADC_SelectQueueOfContextMode(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Selects the Queue Of Context Mode for injected channels. */ void ADC_SelectQueueOfContextMode(ADC_TypeDef *ADCx, FunctionalState NewState)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->CFGR |= (uint32_t)(ADC_CFGR_JQM ); } else { ADCx->CFGR &= ~(uint32_t)(ADC_CFGR_JQM); } }
ajhc/demo-cortex-m3
C++
null
38
/* Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
/* Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
{ USB_Disable(); for(;;); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Data TLB Fault @ Data TLB vector Refer to SDM Vol2 Table 5-6 & 8-1 */
void dtlb_fault(struct kvm_vcpu *vcpu, u64 vadr)
/* Data TLB Fault @ Data TLB vector Refer to SDM Vol2 Table 5-6 & 8-1 */ void dtlb_fault(struct kvm_vcpu *vcpu, u64 vadr)
{ set_ifa_itir_iha(vcpu, vadr, 1, 1, 1); inject_guest_interruption(vcpu, IA64_DATA_TLB_VECTOR); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the enable bits in the HOST side IOINTCTL register. This function may be used to read the host side interrupt bits. */
uint32_t am_hal_ios_host_int_enable_get(void)
/* Get the enable bits in the HOST side IOINTCTL register. This function may be used to read the host side interrupt bits. */ uint32_t am_hal_ios_host_int_enable_get(void)
{ return AM_BFR(IOSLAVE, IOINTCTL, IOINTEN); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs are ECC capable. */
static enum edac_type amd64_determine_edac_cap(struct amd64_pvt *pvt)
/* Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs are ECC capable. */ static enum edac_type amd64_determine_edac_cap(struct amd64_pvt *pvt)
{ int bit; enum dev_type edac_cap = EDAC_FLAG_NONE; bit = (boot_cpu_data.x86 > 0xf || pvt->ext_model >= K8_REV_F) ? 19 : 17; if (pvt->dclr0 & BIT(bit)) edac_cap = EDAC_FLAG_SECDED; return edac_cap; }
robutest/uclinux
C++
GPL-2.0
60
/* paging_init() sets up the page tables - in fact we've already done this. */
static void __init paging_init(void)
/* paging_init() sets up the page tables - in fact we've already done this. */ static void __init paging_init(void)
{ unsigned long zones_size[MAX_NR_ZONES]; memset(zones_size, 0, sizeof(zones_size)); zones_size[ZONE_NORMAL] = max_mapnr; free_area_init(zones_size); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* blk_queue_max_discard_sectors - set max sectors for a single discard @q: the request queue for the device @max_discard_sectors: maximum number of sectors to discard */
void blk_queue_max_discard_sectors(struct request_queue *q, unsigned int max_discard_sectors)
/* blk_queue_max_discard_sectors - set max sectors for a single discard @q: the request queue for the device @max_discard_sectors: maximum number of sectors to discard */ void blk_queue_max_discard_sectors(struct request_queue *q, unsigned int max_discard_sectors)
{ q->limits.max_discard_sectors = max_discard_sectors; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Reset the remap and EINT configuration registers to their default values. */
void SYSCFG_Reset(void)
/* Reset the remap and EINT configuration registers to their default values. */ void SYSCFG_Reset(void)
{ RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_SYSCFG); RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_SYSCFG); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Uses the scalar orientation value to convert from chip frame to body frame */
void inv_convert_to_body(unsigned short orientation, const long *input, long *output)
/* Uses the scalar orientation value to convert from chip frame to body frame */ void inv_convert_to_body(unsigned short orientation, const long *input, long *output)
{ output[0] = input[orientation & 0x03] * SIGNSET(orientation & 0x004); output[1] = input[(orientation>>3) & 0x03] * SIGNSET(orientation & 0x020); output[2] = input[(orientation>>6) & 0x03] * SIGNSET(orientation & 0x100); }
Luos-io/luos_engine
C++
MIT License
496
/* basic update to wheels based on full rotation of prior wheel. This could be modified to change the direction of rotation or order of updates */
void update_wheel_index(void)
/* basic update to wheels based on full rotation of prior wheel. This could be modified to change the direction of rotation or order of updates */ void update_wheel_index(void)
{ IW1++; if (IW1 >= WHEEL_SIZE) { IW1 %= WHEEL_SIZE; IW2++; } if (IW2 >= WHEEL_SIZE) { IW2 %= WHEEL_SIZE; IW3++; } if (IW3 >= WHEEL_SIZE) { IW3 %= WHEEL_SIZE; } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* check if file starts with a PKT_MAP header */
static int gxf_probe(AVProbeData *p)
/* check if file starts with a PKT_MAP header */ static int gxf_probe(AVProbeData *p)
{0, 0, 0, 0, 1, 0xbc}; static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2}; if (!memcmp(p->buf, startcode, sizeof(startcode)) && !memcmp(&p->buf[16 - sizeof(endcode)], endcode, sizeof(endcode))) return AVPROBE_SCORE_MAX; return 0; }
DC-SWAT/DreamShell
C++
null
404
/* This function wraps EFI_PEI_PCI_CFG2_PPI.Read() service. It reads and returns the PCI configuration register specified by Address, the width of data is specified by Width. */
UINT32 PeiPciLibPciCfg2ReadWorker(IN UINTN Address, IN EFI_PEI_PCI_CFG_PPI_WIDTH Width)
/* This function wraps EFI_PEI_PCI_CFG2_PPI.Read() service. It reads and returns the PCI configuration register specified by Address, the width of data is specified by Width. */ UINT32 PeiPciLibPciCfg2ReadWorker(IN UINTN Address, IN EFI_PEI_PCI_CFG_PPI_WIDTH Width)
{ EFI_STATUS Status; UINT32 Data; CONST EFI_PEI_PCI_CFG2_PPI *PciCfg2Ppi; UINT64 PciCfg2Address; Status = PeiServicesLocatePpi (&gEfiPciCfg2PpiGuid, 0, NULL, (VOID **)&PciCfg2Ppi); ASSERT_EFI_ERROR (Status); ASSERT (PciCfg2Ppi != NULL); PciCfg2...
tianocore/edk2
C++
Other
4,240
/* Application process. Needs to run in a loop. */
int32_t cn0531_process(struct cn0531_dev *dev)
/* Application process. Needs to run in a loop. */ int32_t cn0531_process(struct cn0531_dev *dev)
{ return cli_process(dev->cli_desc); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */
EFI_STATUS EFIAPI EfiShellGetGuidFromName(IN CONST CHAR16 *GuidName, OUT EFI_GUID *Guid)
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */ EFI_STATUS EFIAPI EfiShellGetGuidFromName(IN CONST CHAR16 *GuidName, OUT EFI_GUID *Guid)
{ EFI_GUID *NewGuid; EFI_STATUS Status; if ((Guid == NULL) || (GuidName == NULL)) { return (EFI_INVALID_PARAMETER); } Status = GetGuidFromStringName (GuidName, NULL, &NewGuid); if (!EFI_ERROR (Status)) { CopyGuid (Guid, NewGuid); } return (Status); }
tianocore/edk2
C++
Other
4,240
/* param base SAI base pointer param handle SAI eDMA handle pointer. param count Bytes count received by SAI. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress. */
status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count)
/* param base SAI base pointer param handle SAI eDMA handle pointer. param count Bytes count received by SAI. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress. */ status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma...
{ assert(handle != NULL); status_t status = kStatus_Success; if (handle->state != (uint32_t)kSAI_Busy) { status = kStatus_NoTransferInProgress; } else { *count = (handle->transferSize[handle->queueDriver] - (uint32_t)handle->nbytes * ED...
eclipse-threadx/getting-started
C++
Other
310
/* Called by a driver the first time it's needed, must be attached to desired connectors. */
int drm_mode_create_scaling_mode_property(struct drm_device *dev)
/* Called by a driver the first time it's needed, must be attached to desired connectors. */ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
{ struct drm_property *scaling_mode; int i; if (dev->mode_config.scaling_mode_property) return 0; scaling_mode = drm_property_create(dev, DRM_MODE_PROP_ENUM, "scaling mode", ARRAY_SIZE(drm_scaling_mode_enum_list)); for (i = 0; i < ARRAY_SIZE(drm_scaling_mode_enum_list); i++) drm_property_add_enum(sca...
robutest/uclinux
C++
GPL-2.0
60
/* Unregisters an interrupt handler for the timer interrupt. */
void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer)
/* Unregisters an interrupt handler for the timer interrupt. */ void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer)
{ ASSERT(TimerBaseValid(ulBase)); ASSERT((ulTimer == TIMER_A) || (ulTimer == TIMER_B) || (ulTimer == TIMER_BOTH)); ulBase = ((ulBase == TIMER0_BASE) ? INT_TIMER0A : ((ulBase == TIMER1_BASE) ? INT_TIMER1A : ((ulBase == TIMER2_BASE) ? INT_TIMER2A : INT_TIMER3A))); i...
watterott/WebRadio
C++
null
71
/* Checks whether the specified DMAy Channelx flag is set or not. */
FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG)
/* Checks whether the specified DMAy Channelx flag is set or not. */ FlagStatus DMA_GetFlagStatus(uint32_t DMA_FLAG)
{ FlagStatus bitstatus = RESET; assert_param(IS_DMA_GET_FLAG(DMA_FLAG)); if ((DMA1->ISR & DMA_FLAG) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
ajhc/demo-cortex-m3
C++
null
38
/* This function adds a work defined by @wrk to the tail of the pending works list. */
static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
/* This function adds a work defined by @wrk to the tail of the pending works list. */ static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
{ down_read(&ubi->work_sem); __schedule_ubi_work(ubi, wrk); up_read(&ubi->work_sem); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Switch main clock source selection to internal fast RC. */
void pmc_switch_mainck_to_fastrc(uint32_t ul_moscrcf)
/* Switch main clock source selection to internal fast RC. */ void pmc_switch_mainck_to_fastrc(uint32_t ul_moscrcf)
{ PMC->CKGR_MOR |= (CKGR_MOR_KEY_PASSWD | CKGR_MOR_MOSCRCEN); while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)); PMC->CKGR_MOR = (PMC->CKGR_MOR & ~CKGR_MOR_MOSCRCF_Msk) | CKGR_MOR_KEY_PASSWD | ul_moscrcf; while (!(PMC->PMC_SR & PMC_SR_MOSCRCS)); PMC->CKGR_MOR = (PMC->CKGR_MOR & ~CKGR_MOR_MOSCSEL) | CKGR_MOR_KEY_PASSWD...
remotemcu/remcu-chip-sdks
C++
null
436
/* return The selected power domain's requested low power mode, please refer to spc_power_domain_low_power_mode_t. */
spc_power_domain_low_power_mode_t SPC_GetPowerDomainLowPowerMode(SPC_Type *base, spc_power_domain_id_t powerDomainId)
/* return The selected power domain's requested low power mode, please refer to spc_power_domain_low_power_mode_t. */ spc_power_domain_low_power_mode_t SPC_GetPowerDomainLowPowerMode(SPC_Type *base, spc_power_domain_id_t powerDomainId)
{ uint32_t val; val = ((base->PD_STATUS[(uint8_t)powerDomainId] & SPC_PD_STATUS_LP_MODE_MASK) >> SPC_PD_STATUS_LP_MODE_SHIFT); return (spc_power_domain_low_power_mode_t)val; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the LSM6DSO gyroscope sensor output data rate. */
int32_t LSM6DSO_GYRO_SetOutputDataRate(LSM6DSO_Object_t *pObj, float_t Odr)
/* Set the LSM6DSO gyroscope sensor output data rate. */ int32_t LSM6DSO_GYRO_SetOutputDataRate(LSM6DSO_Object_t *pObj, float_t Odr)
{ return LSM6DSO_GYRO_SetOutputDataRate_With_Mode(pObj, Odr, LSM6DSO_GYRO_HIGH_PERFORMANCE_MODE); }
eclipse-threadx/getting-started
C++
Other
310
/* The inode is expected to already been mapped to its buffer and read in once, thus we can use the mapping information stored in the inode rather than calling xfs_imap(). This allows us to avoid the overhead of looking at the inode btree for small block file systems (see xfs_imap()). */
int xfs_itobp(xfs_mount_t *mp, xfs_trans_t *tp, xfs_inode_t *ip, xfs_dinode_t **dipp, xfs_buf_t **bpp, uint buf_flags)
/* The inode is expected to already been mapped to its buffer and read in once, thus we can use the mapping information stored in the inode rather than calling xfs_imap(). This allows us to avoid the overhead of looking at the inode btree for small block file systems (see xfs_imap()). */ int xfs_itobp(xfs_mount_t *mp,...
{ xfs_buf_t *bp; int error; ASSERT(ip->i_imap.im_blkno != 0); error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0); if (error) return error; if (!bp) { ASSERT(buf_flags & XFS_BUF_TRYLOCK); ASSERT(tp == NULL); *bpp = NULL; return EAGAIN; } *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_ima...
robutest/uclinux
C++
GPL-2.0
60
/* XXX Add a prefs_register_{uint16|port}_preference which sets max_value? Register a "custom" preference with a unsigned integral value. XXX - This should be temporary until we can find a better way to do "custom" preferences */
static void prefs_register_uint_custom_preference(module_t *module, const char *name, const char *title, const char *description, struct pref_custom_cbs *custom_cbs, guint *var)
/* XXX Add a prefs_register_{uint16|port}_preference which sets max_value? Register a "custom" preference with a unsigned integral value. XXX - This should be temporary until we can find a better way to do "custom" preferences */ static void prefs_register_uint_custom_preference(module_t *module, const char *name, con...
{ pref_t *preference; preference = register_preference(module, name, title, description, PREF_CUSTOM); preference->custom_cbs = *custom_cbs; preference->varp.uint = var; preference->default_val.uint = *var; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configures the routing interface to select which Input Output pin to be routed to TIM1 Input Capture. */
void SYSCFG_RITIMInputCaptureConfig(RI_InputCapture_TypeDef RI_InputCapture, RI_InputCaptureRouting_TypeDef RI_InputCaptureRouting)
/* Configures the routing interface to select which Input Output pin to be routed to TIM1 Input Capture. */ void SYSCFG_RITIMInputCaptureConfig(RI_InputCapture_TypeDef RI_InputCapture, RI_InputCaptureRouting_TypeDef RI_InputCaptureRouting)
{ assert_param(IS_RI_INPUTCAPTURE(RI_InputCapture)); assert_param(IS_RI_INPUTCAPTUREROUTING(RI_InputCaptureRouting)); if (RI_InputCapture == RI_InputCapture_IC2) { RI->ICR1 = (uint8_t) RI_InputCaptureRouting; } else { RI->ICR2 = (uint8_t) RI_InputCaptureRouting; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* calculate the CRC value of an array of 32-bit values */
uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size)
/* calculate the CRC value of an array of 32-bit values */ uint32_t crc_block_data_calculate(uint32_t array[], uint32_t size)
{ uint32_t index; for(index = 0U; index < size; index++){ CRC_DATA = array[index]; } return (CRC_DATA); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Compute aligned version of the found extent. Takes alignment and min length into account. */
STATIC void xfs_alloc_compute_aligned(xfs_agblock_t foundbno, xfs_extlen_t foundlen, xfs_extlen_t alignment, xfs_extlen_t minlen, xfs_agblock_t *resbno, xfs_extlen_t *reslen)
/* Compute aligned version of the found extent. Takes alignment and min length into account. */ STATIC void xfs_alloc_compute_aligned(xfs_agblock_t foundbno, xfs_extlen_t foundlen, xfs_extlen_t alignment, xfs_extlen_t minlen, xfs_agblock_t *resbno, xfs_extlen_t *reslen)
{ xfs_agblock_t bno; xfs_extlen_t diff; xfs_extlen_t len; if (alignment > 1 && foundlen >= minlen) { bno = roundup(foundbno, alignment); diff = bno - foundbno; len = diff >= foundlen ? 0 : foundlen - diff; } else { bno = foundbno; len = foundlen; } *resbno = bno; *reslen = len; }
robutest/uclinux
C++
GPL-2.0
60
/* LTDC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
/* LTDC MSP Initialization This function configures the hardware resources used in this example. */ void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
{ if(hltdc->Instance==LTDC) { __HAL_RCC_LTDC_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Assumption: *_mem_map is contiguous at least up to MAX_ORDER */
static struct page* __page_find_buddy(struct page *page, unsigned long page_idx, unsigned int order)
/* Assumption: *_mem_map is contiguous at least up to MAX_ORDER */ static struct page* __page_find_buddy(struct page *page, unsigned long page_idx, unsigned int order)
{ unsigned long buddy_idx = page_idx ^ (1 << order); return page + (buddy_idx - page_idx); }
robutest/uclinux
C++
GPL-2.0
60
/* Check if the SMM AP Sync timer is timeout. */
BOOLEAN EFIAPI IsSyncTimerTimeout(IN UINT64 Timer)
/* Check if the SMM AP Sync timer is timeout. */ BOOLEAN EFIAPI IsSyncTimerTimeout(IN UINT64 Timer)
{ UINT64 CurrentTimer; UINT64 Delta; CurrentTimer = GetPerformanceCounter (); if (mCountDown) { if (CurrentTimer <= Timer) { Delta = Timer - CurrentTimer; } else { Delta = mCycle - (CurrentTimer - Timer) + 1; } } else { if (CurrentTimer >= Timer) { Delta = CurrentTimer - Ti...
tianocore/edk2
C++
Other
4,240
/* Register the Service F and all its Characteristics... */
void service_f_1_init(void)
/* Register the Service F and all its Characteristics... */ void service_f_1_init(void)
{ bt_gatt_service_register(&service_f_1_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Write() service. It writes the PCI configuration register specified by Address with the value specified by Data. The width of data is specified by Width. Data is returned. */
UINT32 DxePciLibPciRootBridgeIoWriteWorker(IN UINTN Address, IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, IN UINT32 Data)
/* This function wraps EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Pci.Write() service. It writes the PCI configuration register specified by Address with the value specified by Data. The width of data is specified by Width. Data is returned. */ UINT32 DxePciLibPciRootBridgeIoWriteWorker(IN UINTN Address, IN EFI_PCI_ROOT_BRIDGE_IO...
{ mPciRootBridgeIo->Pci.Write ( mPciRootBridgeIo, Width, PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS (Address), 1, &Data ); return Data; }
tianocore/edk2
C++
Other
4,240
/* ADC Window Monitor mode. This function configures the ADC as window monitor mode and predefine the voltage level for monitoring. If the ADC input exceeds the voltage level the LED0 will be in ON state in SAMD21 Xplained Pro. */
void adc_window_monitor(void)
/* ADC Window Monitor mode. This function configures the ADC as window monitor mode and predefine the voltage level for monitoring. If the ADC input exceeds the voltage level the LED0 will be in ON state in SAMD21 Xplained Pro. */ void adc_window_monitor(void)
{ configure_adc_window_monitor(); adc_start_conversion(&adc_instance); while((adc_get_status(&adc_instance) & ADC_STATUS_RESULT_READY) != 1); status = adc_get_status(&adc_instance); adc_read(&adc_instance, &raw_result); if (status & ADC_STATUS_WINDOW){ port_pin_set_output_level(LED0_PIN, LOW); printf("\nLED0 ...
memfault/zero-to-main
C++
null
200
/* Outputs: None. Return: 0 if successful -EFAULT if data unavailable -ENXIO if no such device -EAGAIN if resource problem -ENOMEM if no memory for SGE -EMLINK if too many chain buffers required -EBADRQC if adapter does not support FW download -EBUSY if adapter is busy -ENOMSG if FW upload returned bad status */
static int mptctl_fw_download(unsigned long arg)
/* Outputs: None. Return: 0 if successful -EFAULT if data unavailable -ENXIO if no such device -EAGAIN if resource problem -ENOMEM if no memory for SGE -EMLINK if too many chain buffers required -EBADRQC if adapter does not support FW download -EBUSY if adapter is busy -ENOMSG if FW upload returned bad status */ stati...
{ struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; struct mpt_fw_xfer kfwdl; if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " "Unable to copy mpt_fw_xfer struct @ %p\n", __FILE__, __LINE__, ufwdl); return -EFAULT; } return mptctl_do_...
robutest/uclinux
C++
GPL-2.0
60
/* Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. ...
VOID* EFIAPI AllocateReservedZeroPool(IN UINTN AllocationSize)
/* Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. ...
{ VOID *Buffer; Buffer = InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize); if (Buffer != NULL) { MemoryProfileLibRecord ( (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0), MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL, EfiReservedMemoryType, Buffer, Allocation...
tianocore/edk2
C++
Other
4,240
/* Returns the timeval representation of the nsec parameter. */
struct timeval ns_to_timeval(const s64 nsec)
/* Returns the timeval representation of the nsec parameter. */ struct timeval ns_to_timeval(const s64 nsec)
{ struct timespec ts = ns_to_timespec(nsec); struct timeval tv; tv.tv_sec = ts.tv_sec; tv.tv_usec = (suseconds_t) ts.tv_nsec / 1000; return tv; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Opens a CAN channel and returns a handle which is used in subsequent calls. */
static CanHandle LeafLightLibFuncOpenChannel(int32_t channel, int32_t flags)
/* Opens a CAN channel and returns a handle which is used in subsequent calls. */ static CanHandle LeafLightLibFuncOpenChannel(int32_t channel, int32_t flags)
{ canHandle result = (canHandle)canERR_NOTINITIALIZED; assert(leafLightLibFuncOpenChannelPtr != NULL); assert(leafLightDllHandle != NULL); if ((leafLightLibFuncOpenChannelPtr != NULL) && (leafLightDllHandle != NULL)) { result = leafLightLibFuncOpenChannelPtr(channel, flags); } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Reads and return a packet of data on the specified USART peripheral. This function operates asynchronously, so it waits until some data has been received. */
unsigned short USART_Read(AT91S_USART *usart, volatile unsigned int timeOut)
/* Reads and return a packet of data on the specified USART peripheral. This function operates asynchronously, so it waits until some data has been received. */ unsigned short USART_Read(AT91S_USART *usart, volatile unsigned int timeOut)
{ if (timeOut == 0) { while ((usart->US_CSR & AT91C_US_RXRDY) == 0); } else { while ((usart->US_CSR & AT91C_US_RXRDY) == 0) { if (timeOut == 0) { trace_LOG(trace_ERROR, "-E- USART_Read: Timed out.\n\r"); return 0; } timeOut-...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Description: This routine is called by the pci error recovery code after the PCI slot has been reset, just before we should resume normal operations. */
static pci_ers_result_t ipr_pci_slot_reset(struct pci_dev *pdev)
/* Description: This routine is called by the pci error recovery code after the PCI slot has been reset, just before we should resume normal operations. */ static pci_ers_result_t ipr_pci_slot_reset(struct pci_dev *pdev)
{ unsigned long flags = 0; struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev); spin_lock_irqsave(ioa_cfg->host->host_lock, flags); if (ioa_cfg->needs_warm_reset) ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE); else _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space, IPR_SHUTDOWN_NONE); spi...
robutest/uclinux
C++
GPL-2.0
60
/* Clears a module status flag. Clears the given status flag of the module. */
void dac_clear_status(struct dac_module *const module_inst, uint32_t status_flags)
/* Clears a module status flag. Clears the given status flag of the module. */ void dac_clear_status(struct dac_module *const module_inst, uint32_t status_flags)
{ Assert(module_inst); Assert(module_inst->hw); Dac *const dac_module = module_inst->hw; uint32_t intflags = 0; if (status_flags & DAC_STATUS_CHANNEL_0_EMPTY) { intflags |= DAC_INTFLAG_EMPTY0; } if (status_flags & DAC_STATUS_CHANNEL_1_EMPTY) { intflags |= DAC_INTFLAG_EMPTY1; } if (status_flags & DAC_STATUS...
memfault/zero-to-main
C++
null
200
/* tipc_reg_stop - shut down & delete TIPC user registry */
void tipc_reg_stop(void)
/* tipc_reg_stop - shut down & delete TIPC user registry */ void tipc_reg_stop(void)
{ int id; if (!users) return; for (id = 1; id <= MAX_USERID; id++) { if (users[id].callback) reg_callback(&users[id]); } kfree(users); users = NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initialize a display driver with default values. It is used to surly have known values in the fields ant not memory junk. After it you can set the fields. */
void lv_disp_drv_init(lv_disp_drv_t *driver)
/* Initialize a display driver with default values. It is used to surly have known values in the fields ant not memory junk. After it you can set the fields. */ void lv_disp_drv_init(lv_disp_drv_t *driver)
{ lv_memset_00(driver, sizeof(lv_disp_drv_t)); driver->hor_res = 320; driver->ver_res = 240; driver->physical_hor_res = -1; driver->physical_ver_res = -1; driver->offset_x = 0; driver->offset_y = 0; driver->antialiasing = LV_COLOR_DEPTH > 8 ? 1 : 0; ...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* menu_enable_device - scans a CPU's states and does setup @dev: the CPU */
static int menu_enable_device(struct cpuidle_device *dev)
/* menu_enable_device - scans a CPU's states and does setup @dev: the CPU */ static int menu_enable_device(struct cpuidle_device *dev)
{ struct menu_device *data = &per_cpu(menu_devices, dev->cpu); memset(data, 0, sizeof(struct menu_device)); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns the custom data from the frame's attributes. The custom data can be used for e.g. linking to associated applications. */
void* wtk_frame_get_custom_data(struct wtk_frame const *frame)
/* This function returns the custom data from the frame's attributes. The custom data can be used for e.g. linking to associated applications. */ void* wtk_frame_get_custom_data(struct wtk_frame const *frame)
{ Assert(frame); return frame->custom_data; }
memfault/zero-to-main
C++
null
200
/* Time Stamp Update Fine When reset the timestamp update is done using Fine method. */
void synopGMAC_TS_fine_update(synopGMACdevice *gmacdev)
/* Time Stamp Update Fine When reset the timestamp update is done using Fine method. */ void synopGMAC_TS_fine_update(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase, GmacTSControl, GmacTSCFUPDT); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* low level hrtimer wake routine. Because this runs in hardirq context we schedule a tasklet to do the real work. */
enum hrtimer_restart kvmppc_decrementer_wakeup(struct hrtimer *timer)
/* low level hrtimer wake routine. Because this runs in hardirq context we schedule a tasklet to do the real work. */ enum hrtimer_restart kvmppc_decrementer_wakeup(struct hrtimer *timer)
{ struct kvm_vcpu *vcpu; vcpu = container_of(timer, struct kvm_vcpu, arch.dec_timer); tasklet_schedule(&vcpu->arch.tasklet); return HRTIMER_NORESTART; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables the specified ADC DMA request. */
void ADC_DMAConfig(ADC_TypeDef *ADCx, uint32_t ADC_DMAMode)
/* Enables or disables the specified ADC DMA request. */ void ADC_DMAConfig(ADC_TypeDef *ADCx, uint32_t ADC_DMAMode)
{ assert_param(IS_ADC_DMA_PERIPH(ADCx)); assert_param(IS_ADC_DMA_MODE(ADC_DMAMode)); ADCx->CFGR &= ~(uint32_t)ADC_CFGR_DMACFG; ADCx->CFGR |= ADC_DMAMode; }
ajhc/demo-cortex-m3
C++
null
38
/* The 'NAS Config' flash partition has an ext2 filesystem which contains a file that has the ethernet MAC address in plain text (format "xx:xx:xx:xx:xx:xx\n"). */
void __init qnap_tsx09_find_mac_addr(u32 mem_base, u32 size)
/* The 'NAS Config' flash partition has an ext2 filesystem which contains a file that has the ethernet MAC address in plain text (format "xx:xx:xx:xx:xx:xx\n"). */ void __init qnap_tsx09_find_mac_addr(u32 mem_base, u32 size)
{ unsigned long addr; for (addr = mem_base; addr < (mem_base + size); addr += 1024) { char *nor_page; int ret = 0; nor_page = ioremap(addr, 1024); if (nor_page != NULL) { ret = qnap_tsx09_check_mac_addr(nor_page); iounmap(nor_page); } if (ret == 0) break; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the tilt factor of a formant filter from its transfer function */
static float tilt_factor(float *lpc_n, float *lpc_d)
/* Get the tilt factor of a formant filter from its transfer function */ static float tilt_factor(float *lpc_n, float *lpc_d)
{ float rh0, rh1; float impulse_buffer[LP_FILTER_ORDER + AMR_TILT_RESPONSE] = { 0 }; float *hf = impulse_buffer + LP_FILTER_ORDER; hf[0] = 1.0; memcpy(hf + 1, lpc_n, sizeof(float) * LP_FILTER_ORDER); ff_celp_lp_synthesis_filterf(hf, lpc_d, hf, AMR_TILT_RESPONSE, ...
DC-SWAT/DreamShell
C++
null
404
/* ks8695_get_pause - Retrieve network pause/flow-control advertising @ndev: The device to retrieve settings from */
static void ks8695_get_pause(struct net_device *ndev, struct ethtool_pauseparam *param)
/* ks8695_get_pause - Retrieve network pause/flow-control advertising @ndev: The device to retrieve settings from */ static void ks8695_get_pause(struct net_device *ndev, struct ethtool_pauseparam *param)
{ struct ks8695_priv *ksp = netdev_priv(ndev); u32 ctrl; switch (ksp->dtype) { case KS8695_DTYPE_HPNA: return; case KS8695_DTYPE_WAN: ctrl = readl(ksp->phyiface_regs + KS8695_WMC); param->autoneg = (ctrl & WMC_WANAP); ctrl = ks8695_readreg(ksp, KS8695_DRXC); param->rx_pause = (ctrl & DRXC_RFCE); ctrl =...
robutest/uclinux
C++
GPL-2.0
60
/* Initializes config with predefined default values. The default configuration is as follows: */
void timer_get_config_defaults(struct timer_config *config)
/* Initializes config with predefined default values. The default configuration is as follows: */ void timer_get_config_defaults(struct timer_config *config)
{ config->reload_value = 0; config->interrupt_enable = true; }
memfault/zero-to-main
C++
null
200
/* If the status lines take on the desired values before the timeout period elapses, parport_poll_peripheral() returns zero immediately. A return value greater than zero indicates a timeout. An error code (less than zero) indicates an error, most likely a signal that arrived, and the caller should finish what it is doi...
int parport_poll_peripheral(struct parport *port, unsigned char mask, unsigned char result, int usec)
/* If the status lines take on the desired values before the timeout period elapses, parport_poll_peripheral() returns zero immediately. A return value greater than zero indicates a timeout. An error code (less than zero) indicates an error, most likely a signal that arrived, and the caller should finish what it is doi...
{ int count = usec / 5 + 2; int i; unsigned char status; for (i = 0; i < count; i++) { status = parport_read_status (port); if ((status & mask) == result) return 0; if (signal_pending (current)) return -EINTR; if (need_resched()) break; if (i >= 2) udelay (5); } return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* XXX - This won't be reliable if a packet containing SSID "B" shows up in the middle of a 4-way handshake for SSID "A". We should probably use a small array or hash table to keep multiple SSIDs. */
INT AirPDcapSetLastSSID(PAIRPDCAP_CONTEXT ctx, CHAR *pkt_ssid, size_t pkt_ssid_len)
/* XXX - This won't be reliable if a packet containing SSID "B" shows up in the middle of a 4-way handshake for SSID "A". We should probably use a small array or hash table to keep multiple SSIDs. */ INT AirPDcapSetLastSSID(PAIRPDCAP_CONTEXT ctx, CHAR *pkt_ssid, size_t pkt_ssid_len)
{ if (!ctx || !pkt_ssid || pkt_ssid_len < 1 || pkt_ssid_len > WPA_SSID_MAX_SIZE) return AIRPDCAP_RET_UNSUCCESS; memcpy(ctx->pkt_ssid, pkt_ssid, pkt_ssid_len); ctx->pkt_ssid_len = pkt_ssid_len; return AIRPDCAP_RET_SUCCESS; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* VIA's AGP3 chipsets do magick to put the AGP bridge compliant with the same standards version as the graphics card. */
static void check_via_agp3(struct agp_bridge_data *bridge)
/* VIA's AGP3 chipsets do magick to put the AGP bridge compliant with the same standards version as the graphics card. */ static void check_via_agp3(struct agp_bridge_data *bridge)
{ u8 reg; pci_read_config_byte(bridge->dev, VIA_AGPSEL, &reg); if ((reg & (1<<1))==0) bridge->driver = &via_agp3_driver; }
robutest/uclinux
C++
GPL-2.0
60
/* Inverts the R and B in an RGB565 color. */
uint16_t invert565Color(uint16_t color)
/* Inverts the R and B in an RGB565 color. */ uint16_t invert565Color(uint16_t color)
{ uint16_t r, g, b; b = (color>>0) & 0x1f; g = (color>>5) & 0x3f; r = (color>>11) & 0x1f; return( (b<<11) + (g<<5) + (r<<0) ); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Set SCBPTR to the SCB that contains the busy table entry for TCL. Return the offset into the SCB that contains the entry for TCL. saved_scbid is dereferenced and set to the scbid that should be restored once manipualtion of the TCL entry is complete. */
static u_int ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
/* Set SCBPTR to the SCB that contains the busy table entry for TCL. Return the offset into the SCB that contains the entry for TCL. saved_scbid is dereferenced and set to the scbid that should be restored once manipualtion of the TCL entry is complete. */ static u_int ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *...
{ AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); *saved_scbid = ahd_get_scbptr(ahd); ahd_set_scbptr(ahd, TCL_LUN(tcl) | ((TCL_TARGET_OFFSET(tcl) & 0xC) << 4)); return (((TCL_TARGET_OFFSET(tcl) & 0x3) << 1) + SCB_DISCONNECTED_LISTS); }
robutest/uclinux
C++
GPL-2.0
60
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ int32_t GPIOPinRead(uint32_t ui32Port, uint8_t ui8Pins)
{ ASSERT(_GPIOBaseValid(ui32Port)); return (HWREG(ui32Port + (GPIO_O_DATA + (ui8Pins << 2)))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Copy pixels from the screen to a pixel buffer. Use this function to copy pixels from the display to an internal SRAM buffer. */
void ili93xx_copy_pixels_from_screen(ili93xx_color_t *pixels, uint32_t count)
/* Copy pixels from the screen to a pixel buffer. Use this function to copy pixels from the display to an internal SRAM buffer. */ void ili93xx_copy_pixels_from_screen(ili93xx_color_t *pixels, uint32_t count)
{ UNUSED(pixels); UNUSED(count); }
remotemcu/remcu-chip-sdks
C++
null
436
/* set_srp_direction: Set the fields in the srp related to data direction and number of buffers based on the direction in the scsi_cmnd and the number of buffers */
static void set_srp_direction(struct scsi_cmnd *cmd, struct srp_cmd *srp_cmd, int numbuf)
/* set_srp_direction: Set the fields in the srp related to data direction and number of buffers based on the direction in the scsi_cmnd and the number of buffers */ static void set_srp_direction(struct scsi_cmnd *cmd, struct srp_cmd *srp_cmd, int numbuf)
{ u8 fmt; if (numbuf == 0) return; if (numbuf == 1) fmt = SRP_DATA_DESC_DIRECT; else { fmt = SRP_DATA_DESC_INDIRECT; numbuf = min(numbuf, MAX_INDIRECT_BUFS); if (cmd->sc_data_direction == DMA_TO_DEVICE) srp_cmd->data_out_desc_cnt = numbuf; else srp_cmd->data_in_desc_cnt = numbuf; } if (cmd->sc_d...
robutest/uclinux
C++
GPL-2.0
60
/* Determins if the specified Generic Clock Generator is enabled. */
bool system_gclk_gen_is_enabled(const uint8_t generator)
/* Determins if the specified Generic Clock Generator is enabled. */ bool system_gclk_gen_is_enabled(const uint8_t generator)
{ bool enabled; system_interrupt_enter_critical_section(); *((uint8_t*)&GCLK->GENCTRL.reg) = generator; enabled = (GCLK->GENCTRL.reg & GCLK_GENCTRL_GENEN); system_interrupt_leave_critical_section(); return enabled; }
memfault/zero-to-main
C++
null
200
/* Read data from NVM. Another requirement is the ability to read unaligned blocks of data with single byte precision. */
void NVMHAL_Read(uint8_t *pAddress, void *pObject, uint16_t len)
/* Read data from NVM. Another requirement is the ability to read unaligned blocks of data with single byte precision. */ void NVMHAL_Read(uint8_t *pAddress, void *pObject, uint16_t len)
{ uint8_t *pObjectInt = (uint8_t*) pObject; while (0 < len) { *pObjectInt = *pAddress; ++pObjectInt; ++pAddress; --len; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */
BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. */ BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN Input...
{ AES_KEY *AesKey; UINT8 IvecBuffer[AES_BLOCK_SIZE]; if ((AesContext == NULL) || (Input == NULL) || ((InputSize % AES_BLOCK_SIZE) != 0)) { return FALSE; } if ((Ivec == NULL) || (Output == NULL) || (InputSize > INT_MAX)) { return FALSE; } AesKey = (AES_KEY *)AesContext; CopyMem (IvecBuffer, I...
tianocore/edk2
C++
Other
4,240
/* Tells whether the Programming Error interrupt is enabled. */
bool flashcalw_is_prog_error_int_enabled(void)
/* Tells whether the Programming Error interrupt is enabled. */ bool flashcalw_is_prog_error_int_enabled(void)
{ return ((HFLASHC->FLASHCALW_FCR & FLASHCALW_FCR_PROGE) != 0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Stop the mac, transmit and receive units hw - Struct containing variables accessed by shared code return : 0 or idle status (if error) */
static int atl1c_stop_mac(struct atl1c_hw *hw)
/* Stop the mac, transmit and receive units hw - Struct containing variables accessed by shared code return : 0 or idle status (if error) */ static int atl1c_stop_mac(struct atl1c_hw *hw)
{ u32 data; AT_READ_REG(hw, REG_RXQ_CTRL, &data); data &= ~(RXQ1_CTRL_EN | RXQ2_CTRL_EN | RXQ3_CTRL_EN | RXQ_CTRL_EN); AT_WRITE_REG(hw, REG_RXQ_CTRL, data); AT_READ_REG(hw, REG_TXQ_CTRL, &data); data &= ~TXQ_CTRL_EN; AT_WRITE_REG(hw, REG_TWSI_CTRL, data); atl1c_wait_until_idle(hw); AT_READ_REG(hw, REG_MAC_...
robutest/uclinux
C++
GPL-2.0
60
/* Configure for PIO mode. This is complicated as the register is shared by PIO and MWDMA and for both channels. */
static void it821x_passthru_set_piomode(struct ata_port *ap, struct ata_device *adev)
/* Configure for PIO mode. This is complicated as the register is shared by PIO and MWDMA and for both channels. */ static void it821x_passthru_set_piomode(struct ata_port *ap, struct ata_device *adev)
{ static const u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; static const u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; struct it821x_dev *itdev = ap->private_data; int unit = adev->devno; int mode_wanted = adev->pio_mode - XFER_PIO_0; itdev->want[unit][1] = pio_want[mode_wanted]; itd...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Update L1 table with new L2 table offset and write it out */
static void qed_aio_write_l1_update(void *opaque, int ret)
/* Update L1 table with new L2 table offset and write it out */ static void qed_aio_write_l1_update(void *opaque, int ret)
{ QEDAIOCB *acb = opaque; BDRVQEDState *s = acb_to_s(acb); int index; if (ret) { qed_aio_complete(acb, ret); return; } index = qed_l1_index(s, acb->cur_pos); s->l1_table->offsets[index] = acb->request.l2_table->offset; qed_write_l1_table(s, index, 1, qed_commit_l2_update,...
ve3wwg/teensy3_qemu
C++
Other
15
/* Copy an user page memory section to a RAM buffer. */
static void mem_user_read(void *dst, isp_addr_t src, uint16_t nbytes)
/* Copy an user page memory section to a RAM buffer. */ static void mem_user_read(void *dst, isp_addr_t src, uint16_t nbytes)
{ memcpy(dst, (U8 *) FLASH_API_USER_PAGE + src, nbytes); }
memfault/zero-to-main
C++
null
200
/* Function deletes the variable specified by VarName and VarGuid. */
EFI_STATUS EfiLibDeleteVariable(IN CHAR16 *VarName, IN EFI_GUID *VarGuid)
/* Function deletes the variable specified by VarName and VarGuid. */ EFI_STATUS EfiLibDeleteVariable(IN CHAR16 *VarName, IN EFI_GUID *VarGuid)
{ return gRT->SetVariable ( VarName, VarGuid, 0, 0, NULL ); }
tianocore/edk2
C++
Other
4,240
/* Lookup scheduler and try to load it if it doesn't exist */
struct ip_vs_scheduler* ip_vs_scheduler_get(const char *sched_name)
/* Lookup scheduler and try to load it if it doesn't exist */ struct ip_vs_scheduler* ip_vs_scheduler_get(const char *sched_name)
{ struct ip_vs_scheduler *sched; sched = ip_vs_sched_getbyname(sched_name); if (sched == NULL) { request_module("ip_vs_%s", sched_name); sched = ip_vs_sched_getbyname(sched_name); } return sched; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */
void RCC_SetHsiCalibValue(uint8_t HSICalibrationValue)
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */ void RCC_SetHsiCalibValue(uint8_t HSICalibrationValue)
{ uint32_t tmpregister = 0; assert_param(IS_RCC_CALIB_VALUE(HSICalibrationValue)); tmpregister = RCC->CTRL; tmpregister &= CTRL_HSITRIM_MASK; tmpregister |= (uint32_t)HSICalibrationValue << 3; RCC->CTRL = tmpregister; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables offset cancellation in single measurement mode. The OFF_CANC bit must be set to 1 when enabling offset cancellation in single measurement mode this means a call function "set_rst_mode(SENS_OFF_CANC_EVERY_ODR)" is need.. */
int32_t iis2mdc_set_rst_sensor_single_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Enables offset cancellation in single measurement mode. The OFF_CANC bit must be set to 1 when enabling offset cancellation in single measurement mode this means a call function "set_rst_mode(SENS_OFF_CANC_EVERY_ODR)" is need.. */ int32_t iis2mdc_set_rst_sensor_single_get(stmdev_ctx_t *ctx, uint8_t *val)
{ iis2mdc_cfg_reg_b_t reg; int32_t ret; ret = iis2mdc_read_reg(ctx, IIS2MDC_CFG_REG_B, (uint8_t *) &reg, 1); *val = reg.off_canc_one_shot; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Read the IT status of the selected IO pin(s) (clears all the pending bits if any). */
uint32_t stmpe1600_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin)
/* Read the IT status of the selected IO pin(s) (clears all the pending bits if any). */ uint32_t stmpe1600_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin)
{ uint8_t tmpData[2] = {0 , 0}; IOE_ReadMultiple(DeviceAddr, STMPE1600_REG_ISGPIOR, tmpData, 2); tmp = ((uint16_t)tmpData[0] | (((uint16_t)tmpData[1]) << 8)); return((tmp & IO_Pin) == IO_Pin); }
eclipse-threadx/getting-started
C++
Other
310
/* ZigBee Device Profile dissector for the device replacement */
void dissect_zbee_zdp_rsp_replace_device(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the device replacement */ void dissect_zbee_zdp_rsp_replace_device(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint8 status; status = zdp_parse_status(tree, tvb, &offset); zbee_append_info(tree, pinfo, ", Status: %s", zdp_status_name(status)); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Transmits the address byte to select the slave device. */
void I2C_Send7bitAddress(I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
/* Transmits the address byte to select the slave device. */ void I2C_Send7bitAddress(I2C_TypeDef *I2Cx, uint8_t Address, uint8_t I2C_Direction)
{ I2Cx->IC_TAR = Address>>1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Delete selected partition from the partion list of the specified device. */
static int part_del(struct mtd_device *dev, struct part_info *part)
/* Delete selected partition from the partion list of the specified device. */ static int part_del(struct mtd_device *dev, struct part_info *part)
{ u8 current_save_needed = 0; if (dev->num_parts == 1) return device_del(dev); if (dev == current_mtd_dev) { struct part_info *curr_pi; curr_pi = mtd_part_info(current_mtd_dev, current_mtd_partnum); if (curr_pi) { if (curr_pi == part) { printf("current partition deleted, resetting current to 0\n"); ...
EmcraftSystems/u-boot
C++
Other
181
/* Returns 1 if the request completed, 0 otherwise */
static int read_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
/* Returns 1 if the request completed, 0 otherwise */ static int read_fifo(struct pxa_ep *ep, struct pxa27x_request *req)
{ int count, is_short, completed = 0; while (epout_has_pkt(ep)) { count = read_packet(ep, req); inc_ep_stats_bytes(ep, count, !USB_DIR_IN); is_short = (count < ep->fifo_size); ep_dbg(ep, "read udccsr:%03x, count:%d bytes%s req %p %d/%d\n", udc_ep_readl(ep, UDCCSR), count, is_short ? "/S" : "", &req->req...
robutest/uclinux
C++
GPL-2.0
60
/* Convert text to the binary representation of a device node. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDeviceNode(IN CONST CHAR16 *TextDeviceNode)
/* Convert text to the binary representation of a device node. */ EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDeviceNode(IN CONST CHAR16 *TextDeviceNode)
{ if (mDevicePathLibDevicePathFromText == NULL) { mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid); } if (mDevicePathLibDevicePathFromText != NULL) { return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode); } else { re...
tianocore/edk2
C++
Other
4,240
/* Checks whether the specified IWDG flag is set or not. */
FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
/* Checks whether the specified IWDG flag is set or not. */ FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
{ FlagStatus bitstatus = RESET; assert_param(IS_IWDG_FLAG(IWDG_FLAG)); if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = RESET; } return bitstatus; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Flush output from our internal buffers. Called for the TCFLSH ioctl. */
static void ppp_sync_flush_output(struct syncppp *ap)
/* Flush output from our internal buffers. Called for the TCFLSH ioctl. */ static void ppp_sync_flush_output(struct syncppp *ap)
{ int done = 0; spin_lock_bh(&ap->xmit_lock); if (ap->tpkt != NULL) { kfree_skb(ap->tpkt); ap->tpkt = NULL; clear_bit(XMIT_FULL, &ap->xmit_flags); done = 1; } spin_unlock_bh(&ap->xmit_lock); if (done) ppp_output_wakeup(&ap->chan); }
robutest/uclinux
C++
GPL-2.0
60
/* nilfs_sufile_read - read sufile inode @sufile: sufile inode @raw_inode: on-disk sufile inode */
int nilfs_sufile_read(struct inode *sufile, struct nilfs_inode *raw_inode)
/* nilfs_sufile_read - read sufile inode @sufile: sufile inode @raw_inode: on-disk sufile inode */ int nilfs_sufile_read(struct inode *sufile, struct nilfs_inode *raw_inode)
{ struct nilfs_sufile_info *sui = NILFS_SUI(sufile); struct buffer_head *header_bh; struct nilfs_sufile_header *header; void *kaddr; int ret; ret = nilfs_read_inode_common(sufile, raw_inode); if (ret < 0) return ret; ret = nilfs_sufile_get_header_block(sufile, &header_bh); if (!ret) { kaddr = kmap_atomic(h...
robutest/uclinux
C++
GPL-2.0
60
/* Initialize all page table entries to be illegal. */
static void init_page_table(uint32_t *ptable, size_t num_entries)
/* Initialize all page table entries to be illegal. */ static void init_page_table(uint32_t *ptable, size_t num_entries)
{ int i; for (i = 0; i < num_entries; i++) { ptable[i] = XTENSA_MMU_PTE_ILLEGAL; } }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* DAC Channel DMA Enable. Enable a digital to analog converter channel DMA mode (connected to DMA2 channel 3 for DAC channel 1 and DMA2 channel 4 for DAC channel 2). A DMA request is generated following an external trigger. */
void dac_dma_enable(uint32_t dac, int channel)
/* DAC Channel DMA Enable. Enable a digital to analog converter channel DMA mode (connected to DMA2 channel 3 for DAC channel 1 and DMA2 channel 4 for DAC channel 2). A DMA request is generated following an external trigger. */ void dac_dma_enable(uint32_t dac, int channel)
{ switch (channel) { case DAC_CHANNEL1: DAC_CR(dac) |= DAC_CR_DMAEN1; break; case DAC_CHANNEL2: DAC_CR(dac) |= DAC_CR_DMAEN2; break; case DAC_CHANNEL_BOTH: DAC_CR(dac) |= (DAC_CR_DMAEN1 | DAC_CR_DMAEN2); break; default: break; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* This function set the scheduling parameter attributes in the attr argument. */
int pthread_attr_setschedparam(pthread_attr_t *attr, struct sched_param const *param)
/* This function set the scheduling parameter attributes in the attr argument. */ int pthread_attr_setschedparam(pthread_attr_t *attr, struct sched_param const *param)
{ RT_ASSERT(attr != RT_NULL); RT_ASSERT(param != RT_NULL); attr->schedparam.sched_priority = param->sched_priority; return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Free the transaction structure. If there is more clean up to do when the structure is freed, add it here. */
STATIC void xfs_trans_free(xfs_trans_t *)
/* Free the transaction structure. If there is more clean up to do when the structure is freed, add it here. */ STATIC void xfs_trans_free(xfs_trans_t *)
{ atomic_dec(&tp->t_mountp->m_active_trans); xfs_trans_free_dqinfo(tp); kmem_zone_free(xfs_trans_zone, tp); }
robutest/uclinux
C++
GPL-2.0
60
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data. */
void LPI2C_MasterTransferCreateHandle(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData)
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data. */ void LPI2C_MasterTransferCreateHandle(LPI2C_Type *base, lpi2c_ma...
{ uint32_t instance; assert(NULL != handle); lpi2c_to_lpflexcomm_t handler; (void)memset(&handler, 0, sizeof(handler)); (void)memset(handle, 0, sizeof(*handle)); instance = LPI2C_GetInstance(base); handle->completionCallback = callback; handle->userData = userData; handler....
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* xs_tcp_data_ready - "data ready" callback for TCP sockets @sk: socket with data to read @bytes: how much data to read */
static void xs_tcp_data_ready(struct sock *sk, int bytes)
/* xs_tcp_data_ready - "data ready" callback for TCP sockets @sk: socket with data to read @bytes: how much data to read */ static void xs_tcp_data_ready(struct sock *sk, int bytes)
{ struct rpc_xprt *xprt; read_descriptor_t rd_desc; int read; dprintk("RPC: xs_tcp_data_ready...\n"); read_lock(&sk->sk_callback_lock); if (!(xprt = xprt_from_sock(sk))) goto out; if (xprt->shutdown) goto out; if (xprt->reestablish_timeout) xprt->reestablish_timeout = 0; rd_desc.arg.data = xprt; d...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Sets the icon for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_ICON. */
void g_file_info_set_icon(GFileInfo *info, GIcon *icon)
/* Sets the icon for a given #GFileInfo. See G_FILE_ATTRIBUTE_STANDARD_ICON. */ void g_file_info_set_icon(GFileInfo *info, GIcon *icon)
{ static guint32 attr = 0; GFileAttributeValue *value; g_return_if_fail (G_IS_FILE_INFO (info)); g_return_if_fail (G_IS_ICON (icon)); if (attr == 0) attr = lookup_attribute (G_FILE_ATTRIBUTE_STANDARD_ICON); value = g_file_info_create_value (info, attr); if (value) _g_file_attribute_value_set_objec...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* If the EXT4_FEATURE_COMPAT_EXT_ATTR feature of this file system is not set, set it. */
static void ext4_xattr_update_super_block(handle_t *handle, struct super_block *sb)
/* If the EXT4_FEATURE_COMPAT_EXT_ATTR feature of this file system is not set, set it. */ static void ext4_xattr_update_super_block(handle_t *handle, struct super_block *sb)
{ if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR)) return; if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); sb->s_dirt = 1; ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); } }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns a pointer to the superblock node or a negative error code. */
struct ubifs_sb_node* ubifs_read_sb_node(struct ubifs_info *c)
/* This function returns a pointer to the superblock node or a negative error code. */ struct ubifs_sb_node* ubifs_read_sb_node(struct ubifs_info *c)
{ struct ubifs_sb_node *sup; int err; sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS); if (!sup) return ERR_PTR(-ENOMEM); err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ, UBIFS_SB_LNUM, 0); if (err) { kfree(sup); return ERR_PTR(err); } return sup; }
EmcraftSystems/u-boot
C++
Other
181
/* Suspend console: Set suspend flag and flush console */
static void sclp_console_suspend(void)
/* Suspend console: Set suspend flag and flush console */ static void sclp_console_suspend(void)
{ unsigned long flags; spin_lock_irqsave(&sclp_con_lock, flags); sclp_con_suspended = 1; spin_unlock_irqrestore(&sclp_con_lock, flags); sclp_console_flush(); }
robutest/uclinux
C++
GPL-2.0
60
/* disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */
void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
/* disable the oscillator bypass mode, HXTALEN or LXTALEN must be reset before it */ void rcu_osci_bypass_mode_disable(rcu_osci_type_enum osci)
{ uint32_t reg; switch(osci) { case RCU_HXTAL: reg = RCU_CTL; RCU_CTL &= ~RCU_CTL_HXTALEN; RCU_CTL = (reg & ~RCU_CTL_HXTALBPS); break; case RCU_LXTAL: reg = RCU_BDCTL; RCU_BDCTL &= ~RCU_BDCTL_LXTALEN; RCU_BDCTL = (reg & ~RCU_BDCTL_LXTALBPS); ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535