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
/* Wrap Read register component function to Bus IO function. */
static int32_t ReadRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length)
/* Wrap Read register component function to Bus IO function. */ static int32_t ReadRegWrap(void *Handle, uint8_t Reg, uint8_t *pData, uint16_t Length)
{ HTS221_Object_t *pObj = (HTS221_Object_t *)Handle; if (pObj->IO.BusType == (uint32_t)HTS221_I2C_BUS) { return pObj->IO.ReadReg(pObj->IO.Address, (Reg | 0x80U), pData, Length); } else { return pObj->IO.ReadReg(pObj->IO.Address, (Reg | 0x40U), pData, Length); } }
eclipse-threadx/getting-started
C++
Other
310
/* Sets the output voltage of the SLCD charge pump. */
void SUPC_SetSlcdVoltage(unsigned int voltage)
/* Sets the output voltage of the SLCD charge pump. */ void SUPC_SetSlcdVoltage(unsigned int voltage)
{ SANITY_CHECK((voltage & ~AT91C_SUPC_LCDOUT) == 0); AT91C_BASE_SUPC->SUPC_MR = SUPC_KEY | (AT91C_BASE_SUPC->SUPC_MR & ~AT91C_SUPC_LCDOUT) | voltage; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Deinitializes the BKP peripheral registers to their default reset values. */
void BKP_DeInit(void)
/* Deinitializes the BKP peripheral registers to their default reset values. */ void BKP_DeInit(void)
{ RCC_BackupResetCmd(ENABLE); RCC_BackupResetCmd(DISABLE); }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Set detach state attribute in thread attributes object. See IEEE 1003.1 */
int pthread_attr_setdetachstate(pthread_attr_t *_attr, int detachstate)
/* Set detach state attribute in thread attributes object. See IEEE 1003.1 */ int pthread_attr_setdetachstate(pthread_attr_t *_attr, int detachstate)
{ struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; if (!__attr_is_initialized(attr) || ((detachstate != PTHREAD_CREATE_DETACHED) && (detachstate != PTHREAD_CREATE_JOINABLE))) { return EINVAL; } attr->detachstate = detachstate; return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This routine is called to get boot option by OptionNumber. */
EFI_STATUS GetBootOptionByNumber(IN UINT16 Number, OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf)
/* This routine is called to get boot option by OptionNumber. */ EFI_STATUS GetBootOptionByNumber(IN UINT16 Number, OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf)
{ EFI_STATUS Status; CHAR16 BootOptionName[20]; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", Number); ZeroMem (&BootOption, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION)); Status = EfiBootManagerVariableToLoa...
tianocore/edk2
C++
Other
4,240
/* If the target is a DevAddr (e.g., a WUSB cluster reservation) then the stream is allocated from a pool of per-RC stream indexes, otherwise a unique stream index for the target is selected. */
static int uwb_rsv_get_stream(struct uwb_rsv *rsv)
/* If the target is a DevAddr (e.g., a WUSB cluster reservation) then the stream is allocated from a pool of per-RC stream indexes, otherwise a unique stream index for the target is selected. */ static int uwb_rsv_get_stream(struct uwb_rsv *rsv)
{ struct uwb_rc *rc = rsv->rc; struct device *dev = &rc->uwb_dev.dev; unsigned long *streams_bm; int stream; switch (rsv->target.type) { case UWB_RSV_TARGET_DEV: streams_bm = rsv->target.dev->streams; break; case UWB_RSV_TARGET_DEVADDR: streams_bm = rc->uwb_dev.streams; break; default: return -EINVAL;...
robutest/uclinux
C++
GPL-2.0
60
/* The ShellCEntryLib library instance wrappers the actual UEFI application entry point and calls this ShellAppMain function. */
INTN EFIAPI ShellAppMain(IN UINTN Argc, IN CHAR16 **Argv)
/* The ShellCEntryLib library instance wrappers the actual UEFI application entry point and calls this ShellAppMain function. */ INTN EFIAPI ShellAppMain(IN UINTN Argc, IN CHAR16 **Argv)
{ UINTN Index; if (Argc == 1) { Print (L"Argv[1] = NULL\n"); } for (Index = 1; Index < Argc; Index++) { Print (L"Argv[%d]: \"%s\"\n", Index, Argv[Index]); } return 0; }
tianocore/edk2
C++
Other
4,240
/* This API is used to get the range in the register 0x0F bits from 0 to 2. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_range_reg(u8 *v_range_u8)
/* This API is used to get the range in the register 0x0F bits from 0 to 2. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_range_reg(u8 *v_range_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC (p_bmg160->dev_addr, BMG160_RANGE_ADDR_RANGE__REG, &v...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Show and set the primary slave. The store function is much simpler than bonding_store_slaves function because it only needs to handle one interface name. The bond must be a mode that supports a primary for this be set. */
static ssize_t bonding_show_primary(struct device *d, struct device_attribute *attr, char *buf)
/* Show and set the primary slave. The store function is much simpler than bonding_store_slaves function because it only needs to handle one interface name. The bond must be a mode that supports a primary for this be set. */ static ssize_t bonding_show_primary(struct device *d, struct device_attribute *attr, char *buf...
{ int count = 0; struct bonding *bond = to_bond(d); if (bond->primary_slave) count = sprintf(buf, "%s\n", bond->primary_slave->dev->name); return count; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_cascade_set_sheet(CRCascade *a_this, CRStyleSheet *a_sheet, enum CRStyleOrigin a_origin)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_cascade_set_sheet(CRCascade *a_this, CRStyleSheet *a_sheet, enum CRStyleOrigin a_origin)
{ g_return_val_if_fail (a_this && a_sheet && a_origin >= ORIGIN_UA && a_origin < NB_ORIGINS, CR_BAD_PARAM_ERROR); if (PRIVATE (a_this)->sheets[a_origin]) cr_stylesheet_unref (PRIVATE (a_this)->sheet...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the time of the specified clock. Note that only the */
int clock_settime(clockid_t clock_id, const struct timespec *tp)
/* Set the time of the specified clock. Note that only the */ int clock_settime(clockid_t clock_id, const struct timespec *tp)
{ struct timespec base; k_spinlock_key_t key; if (clock_id != CLOCK_REALTIME) { errno = EINVAL; return -1; } if (tp->tv_nsec < 0 || tp->tv_nsec >= NSEC_PER_SEC) { errno = EINVAL; return -1; } uint64_t elapsed_nsecs = k_ticks_to_ns_floor64(k_uptime_ticks()); int64_t delta = (int64_t)NSEC_PER_SEC * tp->tv...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Return with head node of the linked list */
void* _lv_ll_get_head(const lv_ll_t *ll_p)
/* Return with head node of the linked list */ void* _lv_ll_get_head(const lv_ll_t *ll_p)
{ if(ll_p == NULL) return NULL; return ll_p->head; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Draws a bitmap picture loaded in the STM32 MCU internal memory. */
void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp)
/* Draws a bitmap picture loaded in the STM32 MCU internal memory. */ void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp)
{ uint32_t height = 0; uint32_t width = 0; width = pBmp[18] + (pBmp[19] << 8) + (pBmp[20] << 16) + (pBmp[21] << 24); height = pBmp[22] + (pBmp[23] << 8) + (pBmp[24] << 16) + (pBmp[25] << 24); if(lcd_drv == &st7735_drv) { Ypos = BSP_LCD_GetYSize() - Ypos - height; } SetDisplayWindow(Xpos, Ypos, wi...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* pdc_hardware_init - Initialize the hardware. @host: target ATA host @board_idx: board identifier */
static int pdc_hardware_init(struct ata_host *host, unsigned int board_idx)
/* pdc_hardware_init - Initialize the hardware. @host: target ATA host @board_idx: board identifier */ static int pdc_hardware_init(struct ata_host *host, unsigned int board_idx)
{ long pll_clock; pll_clock = pdc_detect_pll_input_clock(host); dev_printk(KERN_INFO, host->dev, "PLL input clock %ld kHz\n", pll_clock/1000); pdc_adjust_pll(host, pll_clock, board_idx); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* similar to sys_arch_mbox_fetch, however if a message is not present in the mailbox, it immediately returns with the code SYS_MBOX_EMPTY. */
int k_mbox_tryfetch(k_mbox_t *mb, void **msg)
/* similar to sys_arch_mbox_fetch, however if a message is not present in the mailbox, it immediately returns with the code SYS_MBOX_EMPTY. */ int k_mbox_tryfetch(k_mbox_t *mb, void **msg)
{ k_mbox_t *mbox; if (NULL == mb) { BT_ERR("invaild mbox"); return ERR_MEM; } mbox = mb; k_sem_take(&mbox->mutex, K_FOREVER); if (mbox->first == mbox->last) { k_sem_give(&mbox->mutex); return SYS_MBOX_EMPTY; } if (msg != NULL) { BT_DBG("k_mbox_tryf...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Set the ready status for assign sequence number. */
static void SetPrioSeqNumStatus(U8 seqNum, BOOL isRdy)
/* Set the ready status for assign sequence number. */ static void SetPrioSeqNumStatus(U8 seqNum, BOOL isRdy)
{ U32 tmp; tmp = RdyTaskPriInfo[seqNum/32]; tmp &= ~(1<<(seqNum%32)); tmp |= isRdy<<(seqNum%32); RdyTaskPriInfo[seqNum/32] = tmp; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* @cmd: pointer to cmd that is used as cancelling command @cmd_to_cancel: pointer to the command that needs to be cancelled */
static void pmcraid_prepare_cancel_cmd(struct pmcraid_cmd *cmd, struct pmcraid_cmd *cmd_to_cancel)
/* @cmd: pointer to cmd that is used as cancelling command @cmd_to_cancel: pointer to the command that needs to be cancelled */ static void pmcraid_prepare_cancel_cmd(struct pmcraid_cmd *cmd, struct pmcraid_cmd *cmd_to_cancel)
{ struct pmcraid_ioarcb *ioarcb = &cmd->ioa_cb->ioarcb; __be64 ioarcb_addr = cmd_to_cancel->ioa_cb->ioarcb.ioarcb_bus_addr; ioarcb->resource_handle = cmd_to_cancel->ioa_cb->ioarcb.resource_handle; ioarcb->request_type = REQ_TYPE_IOACMD; memset(ioarcb->cdb, 0, PMCRAID_MAX_CDB_LEN); ioarcb->cdb[0] = PMCRAID_ABORT_C...
robutest/uclinux
C++
GPL-2.0
60
/* Initializes the data interface to the LCD controller SSD2119. */
EMSTATUS DMDIF_init(uint32_t cmdRegAddr, uint32_t dataRegAddr)
/* Initializes the data interface to the LCD controller SSD2119. */ EMSTATUS DMDIF_init(uint32_t cmdRegAddr, uint32_t dataRegAddr)
{ command_register = (volatile uint16_t*) cmdRegAddr; data_register = (volatile uint16_t*) dataRegAddr; return DMD_OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the last ADCx conversion result data for regular channel. */
uint16_t ADC_GetConversionValue(ADC_TypeDef *ADCx)
/* Returns the last ADCx conversion result data for regular channel. */ uint16_t ADC_GetConversionValue(ADC_TypeDef *ADCx)
{ assert_param(IS_ADC_ALL_PERIPH(ADCx)); return (uint16_t) ADCx->ADDATA; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Note bis : Don't try to access HERMES_CMD during the reset phase. It just won't work ! */
static int orinoco_pci_cor_reset(struct orinoco_private *priv)
/* Note bis : Don't try to access HERMES_CMD during the reset phase. It just won't work ! */ static int orinoco_pci_cor_reset(struct orinoco_private *priv)
{ hermes_t *hw = &priv->hw; unsigned long timeout; u16 reg; hermes_write_regn(hw, PCI_COR, HERMES_PCI_COR_MASK); mdelay(HERMES_PCI_COR_ONT); hermes_write_regn(hw, PCI_COR, 0x0000); mdelay(HERMES_PCI_COR_OFFT); timeout = jiffies + (HERMES_PCI_COR_BUSYT * HZ / 1000); reg = hermes_read_regn(hw, CMD); while (time...
robutest/uclinux
C++
GPL-2.0
60
/* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */
status_t HAL_CODEC_WM8904_Init(void *handle, void *config)
/* param handle codec handle. param config codec configuration. return kStatus_Success is success, else initial failed. */ status_t HAL_CODEC_WM8904_Init(void *handle, void *config)
{ assert((config != NULL) && (handle != NULL)); codec_config_t *codecConfig = (codec_config_t *)config; wm8904_config_t *wm8904Config = (wm8904_config_t *)(codecConfig->codecDevConfig); wm8904_handle_t *wm8904Handle = (wm8904_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)); ((cod...
eclipse-threadx/getting-started
C++
Other
310
/* Enable or disable the PWM ouput of the specified channel. */
void TMRA_PWM_OutputCmd(CM_TMRA_TypeDef *TMRAx, uint32_t u32Ch, en_functional_state_t enNewState)
/* Enable or disable the PWM ouput of the specified channel. */ void TMRA_PWM_OutputCmd(CM_TMRA_TypeDef *TMRAx, uint32_t u32Ch, en_functional_state_t enNewState)
{ uint32_t u32PCONRAddr; DDL_ASSERT(IS_TMRA_UNIT_CH(TMRAx, u32Ch)); DDL_ASSERT(IS_FUNCTIONAL_STATE(enNewState)); u32PCONRAddr = (uint32_t)&TMRAx->PCONR1 + (u32Ch * 4U); WRITE_REG32(PERIPH_BIT_BAND(u32PCONRAddr, TMRA_PCONR_OUTEN_POS), enNewState); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function remove duplicate and invalid offsets in Offsets. Invalid offset means MAX_UINT64 in Offsets. */
VOID RemoveDuplicateAndInvalidOffset(IN UINT64 *Offsets, IN OUT UINTN *Count)
/* This function remove duplicate and invalid offsets in Offsets. Invalid offset means MAX_UINT64 in Offsets. */ VOID RemoveDuplicateAndInvalidOffset(IN UINT64 *Offsets, IN OUT UINTN *Count)
{ UINTN Index; UINTN NewCount; UINT64 LastOffset; UINT64 QuickSortBuffer; QuickSort ( Offsets, *Count, sizeof (UINT64), MicrocodePatchOffsetCompareFunction, (VOID *)&QuickSortBuffer ); NewCount = 0; LastOffset = MAX_UINT64; for (Index = 0; Index < *Count; Index++) { i...
tianocore/edk2
C++
Other
4,240
/* Unregisters the interrupt handler for the LCD controller module. */
void LCDIntUnregister(uint32_t ui32Base)
/* Unregisters the interrupt handler for the LCD controller module. */ void LCDIntUnregister(uint32_t ui32Base)
{ ASSERT(ui32Base == LCD0_BASE); IntDisable(INT_LCD0); IntUnregister(INT_LCD0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Polls the PHY status register for link, 'iterations' number of times. */
s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations, u32 usec_interval, bool *success)
/* Polls the PHY status register for link, 'iterations' number of times. */ s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations, u32 usec_interval, bool *success)
{ s32 ret_val = 0; u16 i, phy_status; for (i = 0; i < iterations; i++) { ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) { udelay(usec_interval); } ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) break; if (phy_status & MII_SR_LINK_STATUS) brea...
robutest/uclinux
C++
GPL-2.0
60
/* Program the UDMA timing for this drive according to the current clock. */
static void it821x_program_udma(ide_drive_t *drive, u16 timing)
/* Program the UDMA timing for this drive according to the current clock. */ static void it821x_program_udma(ide_drive_t *drive, u16 timing)
{ ide_hwif_t *hwif = drive->hwif; struct pci_dev *dev = to_pci_dev(hwif->dev); struct it821x_dev *itdev = ide_get_hwifdata(hwif); int channel = hwif->channel; u8 unit = drive->dn & 1, conf; if(itdev->clock_mode == ATA_66) conf = timing >> 8; else conf = timing & 0xFF; if (itdev->timing10 == 0) pci_write_c...
robutest/uclinux
C++
GPL-2.0
60
/* The module Entry Point of the Crypto Dxe Driver. */
EFI_STATUS EFIAPI CryptoDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The module Entry Point of the Crypto Dxe Driver. */ EFI_STATUS EFIAPI CryptoDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ return gBS->InstallMultipleProtocolInterfaces ( &ImageHandle, &gEdkiiCryptoProtocolGuid, (EDKII_CRYPTO_PROTOCOL *)&mEdkiiCrypto, NULL ); }
tianocore/edk2
C++
Other
4,240
/* Note that we can't do proper reference counting without major contortions because the code in fs/locks.c creates, deletes and splits locks without notification. Our only way is to walk the entire lock list each time we remove a lock. */
void nlm_release_file(struct nlm_file *file)
/* Note that we can't do proper reference counting without major contortions because the code in fs/locks.c creates, deletes and splits locks without notification. Our only way is to walk the entire lock list each time we remove a lock. */ void nlm_release_file(struct nlm_file *file)
{ dprintk("lockd: nlm_release_file(%p, ct = %d)\n", file, file->f_count); mutex_lock(&nlm_file_mutex); if (--file->f_count == 0 && !nlm_file_inuse(file)) nlm_delete_file(file); mutex_unlock(&nlm_file_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the current setting of the ADC reference. */
unsigned long ADCReferenceGet(unsigned long ulBase)
/* Returns the current setting of the ADC reference. */ unsigned long ADCReferenceGet(unsigned long ulBase)
{ ASSERT((ulBase == ADC0_BASE) || (ulBase == ADC1_BASE)); return(HWREG(ulBase + ADC_O_CTL) & ADC_CTL_VREF_M); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disable the MMC Rx interrupt. The MMC rx interrupts are masked out as per the mask specified. */
void synopGMAC_disable_mmc_rx_interrupt(synopGMACdevice *gmacdev, u32 mask)
/* Disable the MMC Rx interrupt. The MMC rx interrupts are masked out as per the mask specified. */ void synopGMAC_disable_mmc_rx_interrupt(synopGMACdevice *gmacdev, u32 mask)
{ synopGMACSetBits(gmacdev->MacBase, GmacMmcIntrMaskRx, mask); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* hwalk_r() Walk all of the entries in the hash, calling the callback for each one. this allows some generic operation to be performed on each element. */
int hwalk_r(struct hsearch_data *htab, int(*callback)(struct env_entry *entry))
/* hwalk_r() Walk all of the entries in the hash, calling the callback for each one. this allows some generic operation to be performed on each element. */ int hwalk_r(struct hsearch_data *htab, int(*callback)(struct env_entry *entry))
{ int i; int retval; for (i = 1; i <= htab->size; ++i) { if (htab->table[i].used > 0) { retval = callback(&htab->table[i].entry); if (retval) return retval; } } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Writes the base/extended device id from a device. */
static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
/* Writes the base/extended device id from a device. */ static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
{ rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR, RIO_SET_DID(port->sys_size, did)); }
robutest/uclinux
C++
GPL-2.0
60
/* Event notification that is fired when IOMMU protocol is installed. */
VOID EFIAPI IoMmuProtocolCallback(IN EFI_EVENT Event, IN VOID *Context)
/* Event notification that is fired when IOMMU protocol is installed. */ VOID EFIAPI IoMmuProtocolCallback(IN EFI_EVENT Event, IN VOID *Context)
{ EFI_STATUS Status; Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu); if (!EFI_ERROR (Status)) { gBS->CloseEvent (mIoMmuEvent); } }
tianocore/edk2
C++
Other
4,240
/* Description: Perform a label mapping to translate a local MLS level to the correct CIPSO level using the given DOI definition. Returns zero on success, negative values otherwise. */
static int cipso_v4_map_lvl_hton(const struct cipso_v4_doi *doi_def, u32 host_lvl, u32 *net_lvl)
/* Description: Perform a label mapping to translate a local MLS level to the correct CIPSO level using the given DOI definition. Returns zero on success, negative values otherwise. */ static int cipso_v4_map_lvl_hton(const struct cipso_v4_doi *doi_def, u32 host_lvl, u32 *net_lvl)
{ switch (doi_def->type) { case CIPSO_V4_MAP_PASS: *net_lvl = host_lvl; return 0; case CIPSO_V4_MAP_TRANS: if (host_lvl < doi_def->map.std->lvl.local_size && doi_def->map.std->lvl.local[host_lvl] < CIPSO_V4_INV_LVL) { *net_lvl = doi_def->map.std->lvl.local[host_lvl]; return 0; } return -EPERM; ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* g e t W o r k i n g S e t B o u n d s */
returnValue QProblem_getWorkingSetBounds(QProblem *_THIS, real_t *workingSetB)
/* g e t W o r k i n g S e t B o u n d s */ returnValue QProblem_getWorkingSetBounds(QProblem *_THIS, real_t *workingSetB)
{ int i; int nV = QProblem_getNV( _THIS ); for (i = 0; i < nV; i++) { switch ( Bounds_getStatus( &(_THIS->bounds),i ) ) { case ST_LOWER: workingSetB[i] = -1.0; break; case ST_UPPER: workingSetB[i] = +1.0; break; default: workingSetB[i] = 0.0; break; } } return SUCCESSFUL_RETURN; }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* Reschedule call back. Nothing to do, all the work is done automatically when we return from the interrupt. */
void smp_reschedule_interrupt(struct pt_regs *regs)
/* Reschedule call back. Nothing to do, all the work is done automatically when we return from the interrupt. */ void smp_reschedule_interrupt(struct pt_regs *regs)
{ ack_APIC_irq(); inc_irq_stat(irq_resched_count); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function sets up the Generator delay setting of the VTC core. */
void XVtc_SetDelay(XVtc *InstancePtr, int VertDelay, int HoriDelay)
/* This function sets up the Generator delay setting of the VTC core. */ void XVtc_SetDelay(XVtc *InstancePtr, int VertDelay, int HoriDelay)
{ u32 RegValue; Xil_AssertVoid(InstancePtr != NULL); Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); Xil_AssertVoid(VertDelay >= 0); Xil_AssertVoid(HoriDelay >= 0); Xil_AssertVoid(VertDelay <= 4095); Xil_AssertVoid(HoriDelay <= 4095); RegValue = HoriDelay & XVTC_GGD_HDELAY_MASK; RegValue |= (Ve...
ua1arn/hftrx
C++
null
69
/* Dissect 802.11 with a variable-length link-layer header and with an FCS, but no pseudo-header. */
static int dissect_ieee80211_withfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
/* Dissect 802.11 with a variable-length link-layer header and with an FCS, but no pseudo-header. */ static int dissect_ieee80211_withfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{ struct ieee_802_11_phdr phdr; memset(&phdr, 0, sizeof(phdr)); phdr.fcs_len = 4; phdr.decrypted = FALSE; phdr.datapad = FALSE; phdr.phy = PHDR_802_11_PHY_UNKNOWN; dissect_ieee80211_common(tvb, pinfo, tree, IEEE80211_COMMON_OPT_NORMAL_QOS, &phdr); return tvb_captured_length(tvb); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Code to run on secondary just after probing the CPU */
static void __cpuinit sb1250_init_secondary(void)
/* Code to run on secondary just after probing the CPU */ static void __cpuinit sb1250_init_secondary(void)
{ extern void sb1250_smp_init(void); sb1250_smp_init(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Requests the target to erase the specified range of memory on the target. Note that the target automatically aligns this to the erasable memory block sizes. This typically results in more memory being erased than the range that was specified here. Refer to the target implementation for details. */
LIBOPENBLT_EXPORT uint32_t BltSessionClearMemory(uint32_t address, uint32_t len)
/* Requests the target to erase the specified range of memory on the target. Note that the target automatically aligns this to the erasable memory block sizes. This typically results in more memory being erased than the range that was specified here. Refer to the target implementation for details. */ LIBOPENBLT_EXPORT...
{ uint32_t result = BLT_RESULT_ERROR_GENERIC; assert(len > 0); if (len > 0) { if (SessionClearMemory(address, len)) { result = BLT_RESULT_OK; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Allocate and set up resources for the i960 based AAC variants. The device_interface in the commregion will be allocated and linked to the comm region. */
int aac_rkt_init(struct aac_dev *dev)
/* Allocate and set up resources for the i960 based AAC variants. The device_interface in the commregion will be allocated and linked to the comm region. */ int aac_rkt_init(struct aac_dev *dev)
{ dev->a_ops.adapter_ioremap = aac_rkt_ioremap; dev->a_ops.adapter_comm = aac_rkt_select_comm; return _aac_rx_init(dev); }
robutest/uclinux
C++
GPL-2.0
60
/* Send data on RS485 bus with specified parity stick value (9-bit mode). */
uint32_t UART_RS485Send(LPC_UART_TypeDef *UARTx, uint8_t *pDatFrm, uint32_t size, uint8_t ParityStick)
/* Send data on RS485 bus with specified parity stick value (9-bit mode). */ uint32_t UART_RS485Send(LPC_UART_TypeDef *UARTx, uint8_t *pDatFrm, uint32_t size, uint8_t ParityStick)
{ uint8_t tmp, save; uint32_t cnt; if (ParityStick) { save = tmp = UARTx->LCR & UART_LCR_BITMASK; tmp &= ~(UART_LCR_PARITY_EVEN); UARTx->LCR = tmp; cnt = UART_Send((LPC_UART_TypeDef *)UARTx, pDatFrm, size, BLOCKING); while (!(UARTx->LSR & UART_LSR_TEMT)); ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Verify the header of the Flattened Device Tree */
INT32 EFIAPI FdtCheckHeader(IN CONST VOID *Fdt)
/* Verify the header of the Flattened Device Tree */ INT32 EFIAPI FdtCheckHeader(IN CONST VOID *Fdt)
{ return fdt_check_header (Fdt); }
tianocore/edk2
C++
Other
4,240
/* Gets the enabled attributes of a uDMA channel. */
unsigned long uDMAChannelAttributeGet(unsigned long ulChannelNum)
/* Gets the enabled attributes of a uDMA channel. */ unsigned long uDMAChannelAttributeGet(unsigned long ulChannelNum)
{ unsigned long ulAttr = 0; ASSERT((ulChannelNum & 0xffff) < 32); ulChannelNum &= 0x1f; if(HWREG(UDMA_USEBURSTSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_USEBURST; } if(HWREG(UDMA_ALTSET) & (1 << ulChannelNum)) { ulAttr |= UDMA_ATTR_ALTSELECT; } if(HWREG(UDM...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This api used to reads the interrupt status of data, auto_offset, fast_offset and fifo_int in the register 0x0A. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr_stat_reg_one(u8 *v_stat1_data_u8)
/* This api used to reads the interrupt status of data, auto_offset, fast_offset and fifo_int in the register 0x0A. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_intr_stat_reg_one(u8 *v_stat1_data_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC (p_bmg160->dev_addr, BMG160_INTR_STAT_ONE__REG, &v_da...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is a veneer that replaces the function originally installed by the NAND Flash MTD code. */
static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
/* This function is a veneer that replaces the function originally installed by the NAND Flash MTD code. */ static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops)
{ struct nand_chip *chip = mtd_to_nand(mtd); struct mxs_nand_info *nand_info = nand_get_controller_data(chip); int ret; if (ops->mode == MTD_OPS_RAW) nand_info->raw_oob_mode = 1; else nand_info->raw_oob_mode = 0; ret = nand_info->hooked_read_oob(mtd, from, ops); nand_info->raw_oob_mode = 0; return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* param base Pointer to the FLEXIO_UART_Type structure. return FlexIO UART status flags. */
uint32_t FLEXIO_UART_GetStatusFlags(FLEXIO_UART_Type *base)
/* param base Pointer to the FLEXIO_UART_Type structure. return FlexIO UART status flags. */ uint32_t FLEXIO_UART_GetStatusFlags(FLEXIO_UART_Type *base)
{ uint32_t status = 0U; status = ((FLEXIO_GetShifterStatusFlags(base->flexioBase) & (1UL << base->shifterIndex[0])) >> base->shifterIndex[0]); status |= (((FLEXIO_GetShifterStatusFlags(base->flexioBase) & (1UL << base->shifterIndex[1])) >> (base->shifterIndex[1])) << 1U); status...
eclipse-threadx/getting-started
C++
Other
310
/* This function Pauses or Resumes the audio file stream. In case of using DMA, the DMA Pause feature is used. In all cases the I2S peripheral is disabled. @WARNING When calling */
uint32_t EVAL_AUDIO_PauseResume(uint32_t Cmd)
/* This function Pauses or Resumes the audio file stream. In case of using DMA, the DMA Pause feature is used. In all cases the I2S peripheral is disabled. @WARNING When calling */ uint32_t EVAL_AUDIO_PauseResume(uint32_t Cmd)
{ if (Codec_PauseResume(Cmd) != 0) { return 1; } else { Audio_MAL_PauseResume(Cmd, 0); return 0; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list */
static int tcp_oos_tcplen(struct tcp_pcb *pcb)
/* Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list */ static int tcp_oos_tcplen(struct tcp_pcb *pcb)
{ int len = 0; struct tcp_seg* seg = pcb->ooseq; while(seg != NULL) { len += TCP_TCPLEN(seg); seg = seg->next; } return len; }
ua1arn/hftrx
C++
null
69
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_doc_handler_set_default_sac_handler(CRDocHandler *a_this)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_doc_handler_set_default_sac_handler(CRDocHandler *a_this)
{ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR); a_this->start_document = NULL; a_this->end_document = NULL; a_this->import_style = NULL; a_this->namespace_declaration = NULL; a_this->comment = NULL; a_this->start_selector = NULL; a_this->end_selector ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Save the FDT address provided by TF-A in r2 at boot time This function is called from start.S */
void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2, unsigned long r3)
/* Save the FDT address provided by TF-A in r2 at boot time This function is called from start.S */ void save_boot_params(unsigned long r0, unsigned long r1, unsigned long r2, unsigned long r3)
{ nt_fw_dtb = r2; save_boot_params_ret(); }
4ms/stm32mp1-baremetal
C++
Other
137
/* If the lookup would cross a mountpoint, and the mounted filesystem is exported to the client with NFSEXP_NOHIDE, then the lookup is accepted as it stands and the mounted directory is returned. Otherwise the covered directory is returned. NOTE: this mountpoint crossing is not supported properly by all clients and is ...
__be32 nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name, unsigned int len, struct svc_fh *resfh)
/* If the lookup would cross a mountpoint, and the mounted filesystem is exported to the client with NFSEXP_NOHIDE, then the lookup is accepted as it stands and the mounted directory is returned. Otherwise the covered directory is returned. NOTE: this mountpoint crossing is not supported properly by all clients and is ...
{ struct svc_export *exp; struct dentry *dentry; __be32 err; err = nfsd_lookup_dentry(rqstp, fhp, name, len, &exp, &dentry); if (err) return err; err = check_nfsd_access(exp, rqstp); if (err) goto out; err = fh_compose(resfh, exp, dentry, fhp); if (!err && !dentry->d_inode) err = nfserr_noent; out: dpu...
robutest/uclinux
C++
GPL-2.0
60
/* We don't support multiple originated sequences on the same exchange. By implication, any previously originated sequence on this exchange is complete, and we reallocate the same sequence. */
static struct fc_seq* fc_seq_alloc(struct fc_exch *ep, u8 seq_id)
/* We don't support multiple originated sequences on the same exchange. By implication, any previously originated sequence on this exchange is complete, and we reallocate the same sequence. */ static struct fc_seq* fc_seq_alloc(struct fc_exch *ep, u8 seq_id)
{ struct fc_seq *sp; sp = &ep->seq; sp->ssb_stat = 0; sp->cnt = 0; sp->id = seq_id; return sp; }
robutest/uclinux
C++
GPL-2.0
60
/* Stalls the CPU for the number of nanoseconds specified by NanoSeconds. */
UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
/* Stalls the CPU for the number of nanoseconds specified by NanoSeconds. */ UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
{ EFI_STATUS Status; UINT64 HundredNanoseconds; UINTN Index; if ((gTimerPeriod != 0) && ((UINT64)NanoSeconds > gTimerPeriod) && (EfiGetCurrentTpl () == TPL_APPLICATION)) { HundredNanoseconds = DivU64x32 (NanoSeconds, 100); Status = gBS->SetTimer (gTimerEvent, TimerR...
tianocore/edk2
C++
Other
4,240
/* I/O work flow of in 8042 Aux data. */
EFI_STATUS In8042AuxData(IN OUT UINT8 *Data)
/* I/O work flow of in 8042 Aux data. */ EFI_STATUS In8042AuxData(IN OUT UINT8 *Data)
{ EFI_STATUS Status; Status = WaitOutputFull (BAT_TIMEOUT); if (EFI_ERROR (Status)) { return Status; } *Data = IoRead8 (KBC_DATA_PORT); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Open the device and initialize all of its memory. The device is only opened once, but can be "queried" by multiple processes that know its file descriptor. */
static int perf_open(struct inode *inode, struct file *file)
/* Open the device and initialize all of its memory. The device is only opened once, but can be "queried" by multiple processes that know its file descriptor. */ static int perf_open(struct inode *inode, struct file *file)
{ lock_kernel(); spin_lock(&perf_lock); if (perf_enabled) { spin_unlock(&perf_lock); unlock_kernel(); return -EBUSY; } perf_enabled = 1; spin_unlock(&perf_lock); unlock_kernel(); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Perform basic hardware initialization. Initialize the interrupt controller device drivers. Also initialize the timer device driver, if required. */
static int fsl_frdm_k22f_init(void)
/* Perform basic hardware initialization. Initialize the interrupt controller device drivers. Also initialize the timer device driver, if required. */ static int fsl_frdm_k22f_init(void)
{ PMC->REGSC |= PMC_REGSC_ACKISO_MASK; clock_init(); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. */
VOID ArchSaveExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
/* Save CPU exception context when handling EFI_VECTOR_HANDOFF_HOOK_AFTER case. */ VOID ArchSaveExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
{ IA32_EFLAGS32 Eflags; RESERVED_VECTORS_DATA *ReservedVectors; ReservedVectors = ExceptionHandlerData->ReservedVectors; ReservedVectors[ExceptionType].OldFlags = SystemContext.SystemContextIa32->Eflags; ReservedVectors[ExceptionType].OldCs = SystemContext.SystemContextIa32->Cs; Reser...
tianocore/edk2
C++
Other
4,240
/* The caller must ensure that local interrupts are disabled and are reenabled after post_set() has been called. */
static void prepare_set(void)
/* The caller must ensure that local interrupts are disabled and are reenabled after post_set() has been called. */ static void prepare_set(void)
{ unsigned long cr0; spin_lock(&set_atomicity_lock); cr0 = read_cr0() | X86_CR0_CD; write_cr0(cr0); wbinvd(); if (cpu_has_pge) { cr4 = read_cr4(); write_cr4(cr4 & ~X86_CR4_PGE); } __flush_tlb(); rdmsr(MSR_MTRRdefType, deftype_lo, deftype_hi); mtrr_wrmsr(MSR_MTRRdefType, deftype_lo & ~0xcff, deftype_hi); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Wait for the SerialFlash device to be ready to accept new commands. */
static at25_status_t at25dfx_wait_ready(void)
/* Wait for the SerialFlash device to be ready to accept new commands. */ static at25_status_t at25dfx_wait_ready(void)
{ at25_status_t op_stat; uint8_t at25_stat; uint8_t ready = 0; while (!ready) { op_stat = at25dfx_read_status(&at25_stat); if (op_stat != AT25_SUCCESS) { return op_stat; } if ((at25_stat & AT25_STATUS_RDYBSY) == AT25_STATUS_RDYBSY_READY) { ready = 1; } } return AT25_SUCCESS; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Do the filesystem syncing work. For simple filesystems writeback_inodes_sb(sb) just dirties buffers with inodes so we have to submit IO for these buffers via __sync_blockdev(). This also speeds up the wait == 1 case since in that case write_inode() functions do sync_dirty_buffer() and thus effectively write one bloc...
static int __sync_filesystem(struct super_block *sb, int wait)
/* Do the filesystem syncing work. For simple filesystems writeback_inodes_sb(sb) just dirties buffers with inodes so we have to submit IO for these buffers via __sync_blockdev(). This also speeds up the wait == 1 case since in that case write_inode() functions do sync_dirty_buffer() and thus effectively write one bloc...
{ if (!sb->s_bdi) return 0; if (!wait) { writeout_quota_sb(sb, -1); writeback_inodes_sb(sb); } else { sync_quota_sb(sb, -1); sync_inodes_sb(sb); } if (sb->s_op->sync_fs) sb->s_op->sync_fs(sb, wait); return __sync_blockdev(sb->s_bdev, wait); }
robutest/uclinux
C++
GPL-2.0
60
/* Filesystem code must call this function when inode is journaled in ordered mode before truncation happens and after the inode has been placed on orphan list with the new inode size. The second condition avoids the race that someone writes new data and we start committing the transaction after this function has been ...
int jbd2_journal_begin_ordered_truncate(journal_t *journal, struct jbd2_inode *jinode, loff_t new_size)
/* Filesystem code must call this function when inode is journaled in ordered mode before truncation happens and after the inode has been placed on orphan list with the new inode size. The second condition avoids the race that someone writes new data and we start committing the transaction after this function has been ...
{ transaction_t *inode_trans, *commit_trans; int ret = 0; if (!jinode->i_transaction) goto out; spin_lock(&journal->j_state_lock); commit_trans = journal->j_committing_transaction; spin_unlock(&journal->j_state_lock); spin_lock(&journal->j_list_lock); inode_trans = jinode->i_transaction; spin_unlock(&journal...
robutest/uclinux
C++
GPL-2.0
60
/* FPSR bit field FCC1 | FCC0: 0 = 1 < 2 > 3 unordered */
static void gen_mov_reg_FCC0(TCGv reg, TCGv src, unsigned int fcc_offset)
/* FPSR bit field FCC1 | FCC0: 0 = 1 < 2 > 3 unordered */ static void gen_mov_reg_FCC0(TCGv reg, TCGv src, unsigned int fcc_offset)
{ tcg_gen_shri_tl(reg, src, FSR_FCC0_SHIFT + fcc_offset); tcg_gen_andi_tl(reg, reg, 0x1); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Scramble the ID space with XTEA, so that the value of the files_struct pointer is not exposed to userspace. */
u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id)
/* Scramble the ID space with XTEA, so that the value of the files_struct pointer is not exposed to userspace. */ u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id)
{ u32 *k = fc->scramble_key; u64 v = (unsigned long) id; u32 v0 = v; u32 v1 = v >> 32; u32 sum = 0; int i; for (i = 0; i < 32; i++) { v0 += ((v1 << 4 ^ v1 >> 5) + v1) ^ (sum + k[sum & 3]); sum += 0x9E3779B9; v1 += ((v0 << 4 ^ v0 >> 5) + v0) ^ (sum + k[sum>>11 & 3]); } return (u64) v0 + ((u64) v1 << 32); ...
robutest/uclinux
C++
GPL-2.0
60
/* Custom handler for standard requests in order to catch the request and return the WebUSB Platform Capability Descriptor. */
int webusb_custom_handle_req(struct usb_setup_packet *pSetup, int32_t *len, uint8_t **data)
/* Custom handler for standard requests in order to catch the request and return the WebUSB Platform Capability Descriptor. */ int webusb_custom_handle_req(struct usb_setup_packet *pSetup, int32_t *len, uint8_t **data)
{ LOG_DBG(""); if (req_handlers && req_handlers->custom_handler) { return req_handlers->custom_handler(pSetup, len, data); } return -EINVAL; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* 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==LPUART1) { __HAL_RCC_LPUART1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); } else if(huart->Instance==USART2) { __HAL_RCC_USART2_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); } else if(huart->Instance==USART3) { __HAL_RCC_USART3...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks whether the Early Wakeup interrupt flag is set or not. */
FlagStatus WWDG_GetFlagStatus()
/* Checks whether the Early Wakeup interrupt flag is set or not. */ FlagStatus WWDG_GetFlagStatus()
{ return WWDG->SR ? SET : RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If this function returns, it means that the system does not support cold reset. */
VOID EFIAPI ResetCold(VOID)
/* If this function returns, it means that the system does not support cold reset. */ VOID EFIAPI ResetCold(VOID)
{ SbiSystemReset (SBI_SRST_RESET_TYPE_COLD_REBOOT, SBI_SRST_RESET_REASON_NONE); }
tianocore/edk2
C++
Other
4,240
/* Take two samples from the ADC and determine if the input is floating. */
int32_t cn0414_open_wire_detect(struct cn0414_dev *dev, uint32_t voltage_chan1, uint32_t voltage_chan2, uint8_t *floating)
/* Take two samples from the ADC and determine if the input is floating. */ int32_t cn0414_open_wire_detect(struct cn0414_dev *dev, uint32_t voltage_chan1, uint32_t voltage_chan2, uint8_t *floating)
{ int32_t ret; float fdata1, fdata2; ret = cn0414_compute_adc_value(dev, voltage_chan1, ADC_VOLTAGE_CHANNEL, &fdata1); if(ret != CN0414_SUCCESS) return ret; ret = cn0414_compute_adc_value(dev, voltage_chan2, ADC_VOLTAGE_CHANNEL, &fdata2); if(ret != CN0414_SUCCESS) return ret; if(((fdata...
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Gets interrupt status for the specified GPIO port. */
long GPIOPinIntStatus(unsigned long ulPort, tBoolean bMasked)
/* Gets interrupt status for the specified GPIO port. */ long GPIOPinIntStatus(unsigned long ulPort, tBoolean bMasked)
{ ASSERT(GPIOBaseValid(ulPort)); if(bMasked) { return(HWREG(ulPort + GPIO_O_MIS)); } else { return(HWREG(ulPort + GPIO_O_RIS)); } }
watterott/WebRadio
C++
null
71
/* Sensing chain FIFO stop values memorization at threshold level.. */
int32_t lsm6dso_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val)
/* Sensing chain FIFO stop values memorization at threshold level.. */ int32_t lsm6dso_fifo_stop_on_wtm_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dso_fifo_ctrl2_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&reg, 1); if (ret == 0) { reg.stop_on_wtm = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL2, (uint8_t *)&reg, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Write pointer of output buffer by consecutive reading Note: this function (OBUFSTAT) should only be usd in Enhanced Buffer Mode. */
static uint32_t shi_npcx_write_buf_pointer(struct shi_reg *const inst)
/* Write pointer of output buffer by consecutive reading Note: this function (OBUFSTAT) should only be usd in Enhanced Buffer Mode. */ static uint32_t shi_npcx_write_buf_pointer(struct shi_reg *const inst)
{ uint8_t stat; do { stat = inst->OBUFSTAT; } while (stat != inst->OBUFSTAT); return stat; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Normally, that accounting is done on IO completion, but that can result in more than a second's worth of IO being accounted for within any one second, leading to >100% utilisation. To deal with that, we call this function to do a round-off before returning the results when reading /proc/diskstats. This accounts imme...
void part_round_stats(int cpu, struct hd_struct *part)
/* Normally, that accounting is done on IO completion, but that can result in more than a second's worth of IO being accounted for within any one second, leading to >100% utilisation. To deal with that, we call this function to do a round-off before returning the results when reading /proc/diskstats. This accounts imme...
{ unsigned long now = jiffies; if (part->partno) part_round_stats_single(cpu, &part_to_disk(part)->part0, now); part_round_stats_single(cpu, part, now); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */
void I2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */ void I2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); if(bEndTransmition) { xHWREG(ulBase + I2C_CR) &= ~I2C_CR_AA; do { ulStatus = I2CStatusGet(ulBase); if(xHWREG(ulBase + I2C_CSR) & 0x0700) break; } ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* function : wb_ebios_get_status(u32 sel) description : get last frame write back status parameters : sel <controller select> return : 0 writeback finish 1 overflow 2 timeout 3 not start */
u32 wb_ebios_get_status(u32 sel)
/* function : wb_ebios_get_status(u32 sel) description : get last frame write back status parameters : sel <controller select> return : 0 writeback finish 1 overflow 2 timeout 3 not start */ u32 wb_ebios_get_status(u32 sel)
{ u32 status; status = wb_dev[sel]->status.dwval & 0x71; wb_dev[sel]->status.dwval = 0x71; if (status & 0x10) return 0; else if (status & 0x20) return 1; else if (status & 0x40) return 2; else return 3; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Allocate an event to send a connection complete event when initiating */
static int ble_ll_init_alloc_conn_comp_ev(void)
/* Allocate an event to send a connection complete event when initiating */ static int ble_ll_init_alloc_conn_comp_ev(void)
{ int rc; uint8_t *evbuf; rc = 0; evbuf = g_ble_ll_conn_comp_ev; if (evbuf == NULL) { evbuf = ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_EVT_HI); if (!evbuf) { rc = -1; } else { g_ble_ll_conn_comp_ev = evbuf; } } return rc; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Returns: a newly allocated string, with all characters converted to lowercase. */
gchar* g_utf8_strdown(const gchar *str, gssize len)
/* Returns: a newly allocated string, with all characters converted to lowercase. */ gchar* g_utf8_strdown(const gchar *str, gssize len)
{ gsize result_len; LocaleType locale_type; gchar *result; g_return_val_if_fail (str != NULL, NULL); locale_type = get_locale_type (); result_len = real_tolower (str, len, NULL, locale_type); result = g_malloc (result_len + 1); real_tolower (str, len, result, locale_type); result[result_len] = '\0'; ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This only works on machines with the VIA-based PRAM/RTC, which is basically any machine with Mac II-style ADB. */
static long via_read_time(void)
/* This only works on machines with the VIA-based PRAM/RTC, which is basically any machine with Mac II-style ADB. */ static long via_read_time(void)
{ union { __u8 cdata[4]; long idata; } result, last_result; int ct; ct = 0; do { if (++ct > 10) { printk("via_read_time: couldn't get valid time, " "last read = 0x%08lx and 0x%08lx\n", last_result.idata, result.idata); break; } last_result.idata = result.idata; result.idata ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for searching connection instance matching the connection handle and the state requested. Connection handle and state information is used to get a connection instance, it is possible to ignore the connection handle by using BLE_CONN_HANDLE_INVALID. */
static ret_code_t connection_instance_find(uint16_t conn_handle, uint8_t state, uint32_t *p_instance)
/* Function for searching connection instance matching the connection handle and the state requested. Connection handle and state information is used to get a connection instance, it is possible to ignore the connection handle by using BLE_CONN_HANDLE_INVALID. */ static ret_code_t connection_instance_find(uint16_t con...
{ ret_code_t err_code; uint32_t index; err_code = NRF_ERROR_INVALID_STATE; for (index = 0; index < DEVICE_MANAGER_MAX_CONNECTIONS; index++) { if (state & m_connection_table[index].state) { if ((conn_handle == BLE_CONN_HANDLE_INVALID) || (conn_handle ==...
labapart/polymcu
C++
null
201
/* Returns the number of characters generated on success; otherwise, < 0 on error. */
static int ppc4xx_edac_generate_plb_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size)
/* Returns the number of characters generated on success; otherwise, < 0 on error. */ static int ppc4xx_edac_generate_plb_message(const struct mem_ctl_info *mci, const struct ppc4xx_ecc_status *status, char *buffer, size_t size)
{ unsigned int master; bool read; if ((status->besr & SDRAM_BESR_MASK) == 0) return 0; if ((status->besr & SDRAM_BESR_M0ET_MASK) == SDRAM_BESR_M0ET_NONE) return 0; read = ((status->besr & SDRAM_BESR_M0RW_MASK) == SDRAM_BESR_M0RW_READ); master = SDRAM_BESR_M0ID_DECODE(status->besr); return snprintf(buffer, si...
robutest/uclinux
C++
GPL-2.0
60
/* This function handles ADC1 and ADC2 global interrupts requests. */
void ADC1_2_IRQHandler(void)
/* This function handles ADC1 and ADC2 global interrupts requests. */ void ADC1_2_IRQHandler(void)
{ ADC2ConvertedValue = ADC_GetConversionValue(ADC2); }
remotemcu/remcu-chip-sdks
C++
null
436
/* ECC Hamming calculation ECC is 3 bytes for 512 bytes of data (supports error correction up to max of 1-bit) */
static int stm32_fmc2_ham_calculate(struct mtd_info *mtd, const u8 *data, u8 *ecc)
/* ECC Hamming calculation ECC is 3 bytes for 512 bytes of data (supports error correction up to max of 1-bit) */ static int stm32_fmc2_ham_calculate(struct mtd_info *mtd, const u8 *data, u8 *ecc)
{ struct nand_chip *chip = mtd_to_nand(mtd); struct stm32_fmc2_nfc *fmc2 = to_stm32_nfc(chip->controller); u32 heccr, sr; int ret; ret = readl_poll_timeout(fmc2->io_base + FMC2_SR, sr, sr & FMC2_SR_NWRF, 10000); if (ret < 0) { pr_err("Ham timeout\n"); return ret; } heccr = readl(fmc2->io_base + FMC2_HE...
4ms/stm32mp1-baremetal
C++
Other
137
/* Platform devices are expected to contain 2 resources per port: */
static int bfin_ata_probe_port(struct ata_port *ap)
/* Platform devices are expected to contain 2 resources per port: */ static int bfin_ata_probe_port(struct ata_port *ap)
{ if (bfin_config_atapi_gpio(ap)) { printf("Requesting Peripherals faild\n"); return -EFAULT; } if (bfin_ata_reset_port(ap)) { printf("Fail to reset ATAPI device\n"); return -EFAULT; } if (ap->ata_mode >= XFER_PIO_0 && ap->ata_mode <= XFER_PIO_4) bfin_set_piomode(ap, ap->ata_mode); else { printf("Give...
EmcraftSystems/u-boot
C++
Other
181
/* Returns: TRUE if flush operation succeeded, FALSE otherwise. */
gboolean g_output_stream_flush_finish(GOutputStream *stream, GAsyncResult *result, GError **error)
/* Returns: TRUE if flush operation succeeded, FALSE otherwise. */ gboolean g_output_stream_flush_finish(GOutputStream *stream, GAsyncResult *result, GError **error)
{ g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE); g_return_val_if_fail (g_task_is_valid (result, stream), FALSE); g_return_val_if_fail (g_async_result_is_tagged (result, g_output_stream_flush_async), FALSE); return g_task_propagate_boolean (G_TASK (result), error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function is used when programming the IO chains to submit the instruction followed by variable length payload. */
static int scan_mgr_jtag_insn_data(const u8 iarg, const unsigned long *data, const unsigned int dlen)
/* This function is used when programming the IO chains to submit the instruction followed by variable length payload. */ static int scan_mgr_jtag_insn_data(const u8 iarg, const unsigned long *data, const unsigned int dlen)
{ int i, j; scan_mgr_jtag_io(JTAG_BP_INSN | JTAG_BP_2BYTE, iarg, dlen - 1); for (i = 0; i < dlen / 32; i++) scan_mgr_jtag_io(JTAG_BP_4BYTE, 0x0, data[i]); if ((dlen % 32) > 24) { scan_mgr_jtag_io(JTAG_BP_4BYTE, 0x0, data[i]); } else if (dlen % 32) { for (j = 0; j < dlen % 32; j += 8) scan_mgr_jtag_io(0, 0...
4ms/stm32mp1-baremetal
C++
Other
137
/* Return the powerdomain pwrdm's logic power state. Returns -EINVAL if the powerdomain pointer is null or returns the previous logic power state upon success. */
int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
/* Return the powerdomain pwrdm's logic power state. Returns -EINVAL if the powerdomain pointer is null or returns the previous logic power state upon success. */ int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm)
{ if (!pwrdm) return -EINVAL; return prm_read_mod_bits_shift(pwrdm->prcm_offs, OMAP3430_PM_PREPWSTST, OMAP3430_LASTLOGICSTATEENTERED); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns a new escaped string or NULL in case of error. */
char* uri_string_escape(const char *str, const char *list)
/* Returns a new escaped string or NULL in case of error. */ char* uri_string_escape(const char *str, const char *list)
{ if (len - out <= 3) { temp = realloc2n(ret, &len); ret = temp; } ch = *in; if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!strchr(list, ch))) { unsigned char val; ret[out++] = '%'; val = ch >> 4; if (val <= 9) ret[out++] = '0' + val; else ret[out++] = 'A' + val - 0xA; ...
ve3wwg/teensy3_qemu
C++
Other
15
/* Return the configuration descriptor of the current active configuration. */
EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor)
/* Return the configuration descriptor of the current active configuration. */ EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor)
{ USB_DEVICE *Dev; USB_INTERFACE *UsbIf; EFI_STATUS Status; EFI_TPL OldTpl; if (Descriptor == NULL) { return EFI_INVALID_PARAMETER; } Status = EFI_SUCCESS; OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; if (Dev->ActiveConfi...
tianocore/edk2
C++
Other
4,240
/* param base LPSPI peripheral base address. param handle LPSPI handle pointer to lpspi_slave_edma_handle_t. param callback LPSPI callback. param userData callback function parameter. param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t. param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle po...
void LPSPI_SlaveTransferCreateHandleEDMA(LPSPI_Type *base, lpspi_slave_edma_handle_t *handle, lpspi_slave_edma_transfer_callback_t callback, void *userData, edma_handle_t *edmaRxRegToRxDataHandle, edma_handle_t *edmaTxDataToTxRegHandle)
/* param base LPSPI peripheral base address. param handle LPSPI handle pointer to lpspi_slave_edma_handle_t. param callback LPSPI callback. param userData callback function parameter. param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t. param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle po...
{ assert(handle != NULL); assert(edmaRxRegToRxDataHandle != NULL); assert(edmaTxDataToTxRegHandle != NULL); (void)memset(handle, 0, sizeof(*handle)); uint32_t instance = LPSPI_GetInstance(base); s_lpspiSlaveEdmaPrivateHandle[instance].base = base; s_lpspiSlaveEdmaPrivateHandle[instance].ha...
eclipse-threadx/getting-started
C++
Other
310
/* This is a temporary kludge to deal with "automount" symlinks; proper solution is to trigger them on follow_mount(), so that do_lookup() would DTRT. To be killed before -final. */
static int follow_on_final(struct inode *inode, unsigned lookup_flags)
/* This is a temporary kludge to deal with "automount" symlinks; proper solution is to trigger them on follow_mount(), so that do_lookup() would DTRT. To be killed before -final. */ static int follow_on_final(struct inode *inode, unsigned lookup_flags)
{ return inode && unlikely(inode->i_op->follow_link) && ((lookup_flags & LOOKUP_FOLLOW) || S_ISDIR(inode->i_mode)); }
robutest/uclinux
C++
GPL-2.0
60
/* Gets the register offset for the GPIO bank. Low (0-15) starts at 0x00, high (16-31) starts at 0x80 */
static u32 cs5535_lowhigh_base(int reg)
/* Gets the register offset for the GPIO bank. Low (0-15) starts at 0x00, high (16-31) starts at 0x80 */ static u32 cs5535_lowhigh_base(int reg)
{ return (reg & 0x10) << 3; }
robutest/uclinux
C++
GPL-2.0
60
/* Called after unconfiguring / when releasing interfaces. See comments in __usb_queue_reset_device() regarding udev->reset_running. */
static void usb_cancel_queued_reset(struct usb_interface *iface)
/* Called after unconfiguring / when releasing interfaces. See comments in __usb_queue_reset_device() regarding udev->reset_running. */ static void usb_cancel_queued_reset(struct usb_interface *iface)
{ if (iface->reset_running == 0) cancel_work_sync(&iface->reset_ws); }
robutest/uclinux
C++
GPL-2.0
60
/* Send the row address to the NAND Flash chip. */
static void write_row_address(const struct nand_flash_raw *raw, uint32_t row_address)
/* Send the row address to the NAND Flash chip. */ static void write_row_address(const struct nand_flash_raw *raw, uint32_t row_address)
{ uint32_t num_page = nand_flash_model_get_device_size_in_pages(MODEL(raw)); while (num_page > 0) { if (nand_flash_model_get_data_bus_width(MODEL(raw)) == 16) { WRITE_ADDRESS16(raw, (row_address & 0xFF)); } else { WRITE_ADDRESS(raw, (row_address & 0xFF)); } num_page >>= 8; row_address >>= 8; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Determine if the system power state supports a capsule update. */
EFI_STATUS EFIAPI CheckSystemPower(OUT BOOLEAN *Good)
/* Determine if the system power state supports a capsule update. */ EFI_STATUS EFIAPI CheckSystemPower(OUT BOOLEAN *Good)
{ if (LookupCapsuleUpdatePolicyProtocol ()) { return mCapsuleUpdatePolicy->CheckSystemPower (mCapsuleUpdatePolicy, Good); } *Good = TRUE; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Tell whether this Operand is an Statement OpCode. */
BOOLEAN IsStorageOpCode(IN UINT8 Operand)
/* Tell whether this Operand is an Statement OpCode. */ BOOLEAN IsStorageOpCode(IN UINT8 Operand)
{ if ((Operand == EFI_IFR_VARSTORE_OP) || (Operand == EFI_IFR_VARSTORE_NAME_VALUE_OP) || (Operand == EFI_IFR_VARSTORE_EFI_OP)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* This will allocate the return buffer from boot services pool. */
CHAR16* EFIAPI DevicePathProtocolDumpInformation(IN CONST EFI_HANDLE TheHandle, IN CONST BOOLEAN Verbose)
/* This will allocate the return buffer from boot services pool. */ CHAR16* EFIAPI DevicePathProtocolDumpInformation(IN CONST EFI_HANDLE TheHandle, IN CONST BOOLEAN Verbose)
{ return DevicePathProtocolDumpInformationEx (TheHandle, Verbose, &gEfiDevicePathProtocolGuid); }
tianocore/edk2
C++
Other
4,240
/* Returns the bit number to set in the VLAN hash filter corresponding to a given tag. */
uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag)
/* Returns the bit number to set in the VLAN hash filter corresponding to a given tag. */ uint32_t EMACVLANHashFilterBitCalculate(uint16_t ui16Tag)
{ uint32_t ui32CRC, ui32Mask, ui32Loop; ui32CRC = Crc32(0xFFFFFFFF, (uint8_t *)&ui16Tag, 2); ui32CRC ^= 0xFFFFFFFF; ui32Mask = 0; for (ui32Loop = 0; ui32Loop < 4; ui32Loop++) { ui32Mask <<= 1; ui32Mask |= (ui32CRC & 1); ui32CRC >>= 1; } return (ui32Mask); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Find DXE core from FV and build DXE core HOBs. */
EFI_STATUS UniversalLoadDxeCore(IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv, OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint)
/* Find DXE core from FV and build DXE core HOBs. */ EFI_STATUS UniversalLoadDxeCore(IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv, OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint)
{ EFI_STATUS Status; EFI_FFS_FILE_HEADER *FileHeader; VOID *PeCoffImage; EFI_PHYSICAL_ADDRESS ImageAddress; UINT64 ImageSize; Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL, &FileHeader); if (EFI_ERROR (Status)) { return Status; } ...
tianocore/edk2
C++
Other
4,240
/* SVM radial basis function instance init function. Classes are integer used as output of the function (instead of having -1,1 as class values). */
void arm_svm_rbf_init_f32(arm_svm_rbf_instance_f32 *S, uint32_t nbOfSupportVectors, uint32_t vectorDimension, float32_t intercept, const float32_t *dualCoefficients, const float32_t *supportVectors, const int32_t *classes, float32_t gamma)
/* SVM radial basis function instance init function. Classes are integer used as output of the function (instead of having -1,1 as class values). */ void arm_svm_rbf_init_f32(arm_svm_rbf_instance_f32 *S, uint32_t nbOfSupportVectors, uint32_t vectorDimension, float32_t intercept, const float32_t *dualCoefficients, cons...
{ S->nbOfSupportVectors = nbOfSupportVectors; S->vectorDimension = vectorDimension; S->intercept = intercept; S->dualCoefficients = dualCoefficients; S->supportVectors = supportVectors; S->classes = classes; S->gamma = gamma; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* We are called with a valid reference to the device, or NULL if the event is not for a particular event (e.g., a BG join event). */
void uwb_notify(struct uwb_rc *rc, struct uwb_dev *uwb_dev, enum uwb_notifs event)
/* We are called with a valid reference to the device, or NULL if the event is not for a particular event (e.g., a BG join event). */ void uwb_notify(struct uwb_rc *rc, struct uwb_dev *uwb_dev, enum uwb_notifs event)
{ struct uwb_notifs_handler *handler; if (mutex_lock_interruptible(&rc->notifs_chain.mutex)) return; if (!list_empty(&rc->notifs_chain.list)) { list_for_each_entry(handler, &rc->notifs_chain.list, list_node) { handler->cb(handler->data, uwb_dev, event); } } mutex_unlock(&rc->notifs_chain.mutex); }
robutest/uclinux
C++
GPL-2.0
60