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: Pointer to allocated memory on success, NULL on failure. */
void* devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
/* RETURNS: Pointer to allocated memory on success, NULL on failure. */ void* devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
{ struct devres *dr; dr = alloc_dr(devm_kzalloc_release, size, gfp); if (unlikely(!dr)) return NULL; set_node_dbginfo(&dr->node, "devm_kzalloc_release", size); devres_add(dev, dr->data); return dr->data; }
robutest/uclinux
C++
GPL-2.0
60
/* Set/clear i2c slave NAK or ACK data part in transfer. */
int i2c_slave_set_for_data_nak(i2c_t *obj, int set_nak)
/* Set/clear i2c slave NAK or ACK data part in transfer. */ int i2c_slave_set_for_data_nak(i2c_t *obj, int set_nak)
{ I2C_TypeDef * I2Cx = obj->I2Cx; u32 temp; while (1) { temp = I2Cx->IC_STATUS; if ((BIT_IC_STATUS_SLV_ACTIVITY & temp) == 0) { break; } } I2Cx->IC_SLV_DATA_NACK_ONLY = set_nak; return 0; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Clear the Watchdog Timer Wake-Up Flag of the WDT. */
void WDTWakeUpFlagClear(void)
/* Clear the Watchdog Timer Wake-Up Flag of the WDT. */ void WDTWakeUpFlagClear(void)
{ xHWREG(WDT_WTCR) |= WDT_WTCR_WTWKF; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Gets the count of storage security devices that one specific driver detects. */
EFI_STATUS EFIAPI NvmeStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
/* Gets the count of storage security devices that one specific driver detects. */ EFI_STATUS EFIAPI NvmeStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
{ PEI_NVME_CONTROLLER_PRIVATE_DATA *Private; if ((This == NULL) || (NumberofDevices == NULL)) { return EFI_INVALID_PARAMETER; } Private = GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This); *NumberofDevices = Private->ActiveNamespaceNum; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Kill all bound sockets on a dropped device. */
static void x25_kill_by_device(struct net_device *dev)
/* Kill all bound sockets on a dropped device. */ static void x25_kill_by_device(struct net_device *dev)
{ struct sock *s; struct hlist_node *node; write_lock_bh(&x25_list_lock); sk_for_each(s, node, &x25_list) if (x25_sk(s)->neighbour && x25_sk(s)->neighbour->dev == dev) x25_disconnect(s, ENETUNREACH, 0, 0); write_unlock_bh(&x25_list_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get actual compare value @rmtoll CMP CMP LPTIM_GetCompare. */
uint32_t LPTIM_GetCompare(LPTIM_Module *LPTIMx)
/* Get actual compare value @rmtoll CMP CMP LPTIM_GetCompare. */ uint32_t LPTIM_GetCompare(LPTIM_Module *LPTIMx)
{ return (uint32_t)(READ_BIT(LPTIMx->COMPx, LPTIM_COMP_CMPVAL)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Forward the timer expiry so it will expire in the future. Returns the number of overruns. */
u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
/* Forward the timer expiry so it will expire in the future. Returns the number of overruns. */ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
{ u64 orun = 1; ktime_t delta; delta = ktime_sub(now, hrtimer_get_expires(timer)); if (delta.tv64 < 0) return 0; if (interval.tv64 < timer->base->resolution.tv64) interval.tv64 = timer->base->resolution.tv64; if (unlikely(delta.tv64 >= interval.tv64)) { s64 incr = ktime_to_ns(interval); orun = ktime_divns...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Minimum threshold to detect a peak. Default is 10h.. */
int32_t lsm6dsl_pedo_threshold_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Minimum threshold to detect a peak. Default is 10h.. */ int32_t lsm6dsl_pedo_threshold_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dsl_config_pedo_ths_min_t config_pedo_ths_min; int32_t ret; ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A); if(ret == 0){ ret = lsm6dsl_read_reg(ctx, LSM6DSL_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); if(ret == 0){ *val = config_pedo_ths...
eclipse-threadx/getting-started
C++
Other
310
/* Output a single byte to the usb client port. */
void usbtty_putc(struct stdio_dev *dev, const char c)
/* Output a single byte to the usb client port. */ void usbtty_putc(struct stdio_dev *dev, const char c)
{ if (!usbtty_configured ()) return; if (c == '\n') buf_push (&usbtty_output, "\r", 1); buf_push(&usbtty_output, &c, 1); if ((usbtty_output.size + 2) >= usbtty_output.totalsize) { usbtty_poll (); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* The function doesn't garentee the device path points to existing FV file. */
BOOLEAN BmIsFvFilePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* The function doesn't garentee the device path points to existing FV file. */ BOOLEAN BmIsFvFilePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ EFI_STATUS Status; EFI_HANDLE Handle; EFI_DEVICE_PATH_PROTOCOL *Node; Node = DevicePath; Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &Handle); if (!EFI_ERROR (Status)) { return TRUE; } if ((DevicePathType (DevicePath) == HARDWARE_DEVICE...
tianocore/edk2
C++
Other
4,240
/* This routine is the driver initialization entry point. It registers a notification function. This notification function are responsible for building the FV stack dynamically. */
EFI_STATUS EFIAPI FwVolDriverInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This routine is the driver initialization entry point. It registers a notification function. This notification function are responsible for building the FV stack dynamically. */ EFI_STATUS EFIAPI FwVolDriverInit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ gEfiFwVolBlockEvent = EfiCreateProtocolNotifyEvent ( &gEfiFirmwareVolumeBlockProtocolGuid, TPL_CALLBACK, NotifyFwVolBlock, NULL, &gEfiFwVolBlockNotifyReg ); r...
tianocore/edk2
C++
Other
4,240
/* libc/string/strrchr.c Finds the last occurrence of a byte in a string */
char* strrchr(const char *s, int c)
/* libc/string/strrchr.c Finds the last occurrence of a byte in a string */ char* strrchr(const char *s, int c)
{ const char * p = s + strlen(s); do { if (*p == (char)c) return (char *)p; } while (--p >= s); return NULL; }
xboot/xboot
C++
MIT License
779
/* Don't touch any member of the md after calling this function because the md may be freed in dm_put() at the end of this function. Or do dm_get() before calling this function and dm_put() later. */
static void rq_completed(struct mapped_device *md, int rw, int run_queue)
/* Don't touch any member of the md after calling this function because the md may be freed in dm_put() at the end of this function. Or do dm_get() before calling this function and dm_put() later. */ static void rq_completed(struct mapped_device *md, int rw, int run_queue)
{ atomic_dec(&md->pending[rw]); if (!md_in_flight(md)) wake_up(&md->wait); if (run_queue) blk_run_queue(md->queue); dm_put(md); }
robutest/uclinux
C++
GPL-2.0
60
/* Sets the pulse width for the specified PWM output. */
void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut, unsigned long ulWidth)
/* Sets the pulse width for the specified PWM output. */ void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut, unsigned long ulWidth)
{ unsigned long ulGenBase, ulReg; ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT(PWMOutValid(ulPWMOut)); ulGenBase = PWM_OUT_BADDR(ulBase, ulPWMOut); if(HWREG(ulGenBase + PWM_O_X_CTL) & PWM_X_CTL_MODE) { ulWidth /= 2; } ulReg = HWREG(ulGenBase + PWM_O_X_LOAD); ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* To generate a key to KS SRAM for ECDH. */
int32_t RNG_ECDH(uint32_t u32KeySize)
/* To generate a key to KS SRAM for ECDH. */ int32_t RNG_ECDH(uint32_t u32KeySize)
{ int32_t timeout; int32_t i; CRPT->PRNG_CTL = (u32KeySize << CRPT_PRNG_CTL_KEYSZ_Pos) | CRPT_PRNG_CTL_START_Msk | PRNG_CTL_SEEDSRC_TRNG; timeout = 0x10000; i = 0; while (CRPT->PRNG_CTL & CRPT_PRNG_CTL_BUSY_Msk) { if (i++ > timeout) return -1; } if (CRPT->PRNG_KSS...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Encode a point. This method assumes that the point is correct and is not the point at infinity. Encoded size is always 1+2*plen, where plen is the field modulus length, in bytes. */
static void point_encode(void *dst, const jacobian *P, const curve_params *cc)
/* Encode a point. This method assumes that the point is correct and is not the point at infinity. Encoded size is always 1+2*plen, where plen is the field modulus length, in bytes. */ static void point_encode(void *dst, const jacobian *P, const curve_params *cc)
{ unsigned char *buf; size_t plen; jacobian Q, T; buf = dst; plen = (pgm_read_word(&cc->p[0]) - (pgm_read_word(&cc->p[0]) >> 4) + 7) >> 3; buf[0] = 0x04; memcpy(&Q, P, sizeof *P); set_one(T.c[2], cc->p); run_code(&Q, &T, cc, code_affine); br_i15_encode(buf + 1, plen, Q.c[0]); br_i15_encode(buf + 1 + plen, pl...
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* Returns the current value of the hash filter used to control reception of VLAN-tagged frames. */
uint32_t EMACVLANHashFilterGet(uint32_t ui32Base)
/* Returns the current value of the hash filter used to control reception of VLAN-tagged frames. */ uint32_t EMACVLANHashFilterGet(uint32_t ui32Base)
{ ASSERT(ui32Base == EMAC0_BASE); return(HWREG(ui32Base + EMAC_O_VLANHASH)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The function is used to return if the provided JSON value contains a JSON boolean. */
BOOLEAN EFIAPI JsonValueIsBoolean(IN EDKII_JSON_VALUE Json)
/* The function is used to return if the provided JSON value contains a JSON boolean. */ BOOLEAN EFIAPI JsonValueIsBoolean(IN EDKII_JSON_VALUE Json)
{ return json_is_boolean ((json_t *)Json); }
tianocore/edk2
C++
Other
4,240
/* Gets the value of the requested RTC match register. */
uint32_t HibernateRTCMatchGet(uint32_t ui32Match)
/* Gets the value of the requested RTC match register. */ uint32_t HibernateRTCMatchGet(uint32_t ui32Match)
{ ASSERT(ui32Match == 0); return (HWREG(HIB_RTCM0)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return: 0 if setting the DP phy clock speed was successful, -ve on error */
static int set_clk_speed(struct udevice *dev, u32 speed)
/* Return: 0 if setting the DP phy clock speed was successful, -ve on error */ static int set_clk_speed(struct udevice *dev, u32 speed)
{ struct dp_tx *dp_tx = dev_get_priv(dev); int status; u32 val; u32 mask; val = get_reg(dev, REG_ENABLE); set_reg(dev, REG_ENABLE, 0x0); set_reg(dev, REG_PHY_CLOCK_SELECT, speed); if (val) set_reg(dev, REG_ENABLE, 0x1); mask = phy_status_lanes_ready_mask(dp_tx->max_lane_count); status = wait_phy_ready(dev, ...
4ms/stm32mp1-baremetal
C++
Other
137
/* param handle The RTOS I2C handle. param transfer Structure specifying the transfer parameters. return status of the operation. */
status_t I2C_RTOS_Transfer(i2c_rtos_handle_t *handle, i2c_master_transfer_t *transfer)
/* param handle The RTOS I2C handle. param transfer Structure specifying the transfer parameters. return status of the operation. */ status_t I2C_RTOS_Transfer(i2c_rtos_handle_t *handle, i2c_master_transfer_t *transfer)
{ status_t status; if (xSemaphoreTake(handle->mutex, portMAX_DELAY) != pdTRUE) { return kStatus_I2C_Busy; } status = I2C_MasterTransferNonBlocking(handle->base, &handle->drv_handle, transfer); if (status != kStatus_Success) { (void)xSemaphoreGive(handle->mutex); retur...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set GPIO port mask register of the specified GPIO pin(s). 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. */
void GPIOPinMaskSet(unsigned long ulPort, unsigned long ulPins)
/* Set GPIO port mask register of the specified GPIO pin(s). 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. */ void GPIOPinMaskSet(unsigned long ulPort, ...
{ unsigned long ulPortBase; unsigned long ulBit; xASSERT(GPIOBaseValid(ulPort)); ulPortBase = GPIOToPortGet(ulPort); for(ulBit = 0; ulBit < 32; ulBit++) { if(((ulPins >> ulBit) & 1) != 0) { if(ulBit < 16) { xHWREG(ulPortBase + PORT_GPCLR) |= (1 << (ulBit +...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* here we start the process of spliting out the fb update into individual blocks of pixels. we end up spliting into 64x64 blocks and finally down to 64x8 pages. */
static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx, unsigned int dy, unsigned int w, unsigned int h)
/* here we start the process of spliting out the fb update into individual blocks of pixels. we end up spliting into 64x64 blocks and finally down to 64x8 pages. */ static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx, unsigned int dy, unsigned int w, unsigned int h)
{ unsigned int left, right, distance, y; y = floor8(dy); h += dy - y; h = iceil8(h); distance = w; left = dx; right = min(left + w - 1, ceil64(left)); while (distance > 0) { arcfb_lcd_update_horiz(par, left, right, y, h); distance -= ((right - left) + 1); left = right + 1; right = min(left + distance - ...
robutest/uclinux
C++
GPL-2.0
60
/* Deinitializes the SPIx peripheral registers to their default reset values (Affects also the I2Ss). */
void SPI_I2S_DeInit(SPI_Module *SPIx)
/* Deinitializes the SPIx peripheral registers to their default reset values (Affects also the I2Ss). */ void SPI_I2S_DeInit(SPI_Module *SPIx)
{ assert_param(IS_SPI_PERIPH(SPIx)); if (SPIx == SPI1) { RCC_EnableAPB2PeriphReset(RCC_APB2_PERIPH_SPI1, ENABLE); RCC_EnableAPB2PeriphReset(RCC_APB2_PERIPH_SPI1, DISABLE); } else if (SPIx == SPI2) { RCC_EnableAPB2PeriphReset(RCC_APB2_PERIPH_SPI2, ENABLE); RCC_Enab...
pikasTech/PikaPython
C++
MIT License
1,403
/* pnp_add_card_device - adds a device to the specified card @card: pointer to the card to add to @dev: pointer to the device to add */
int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
/* pnp_add_card_device - adds a device to the specified card @card: pointer to the card to add to @dev: pointer to the device to add */ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
{ dev->dev.parent = &card->dev; dev->card_link = NULL; dev_set_name(&dev->dev, "%02x:%02x.%02x", dev->protocol->number, card->number, dev->number); spin_lock(&pnp_lock); dev->card = card; list_add_tail(&dev->card_list, &card->devices); spin_unlock(&pnp_lock); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* The usable MAS of a reservation may be less than the negotiated MAS if alien BPs are present. */
void uwb_rsv_get_usable_mas(struct uwb_rsv *rsv, struct uwb_mas_bm *mas)
/* The usable MAS of a reservation may be less than the negotiated MAS if alien BPs are present. */ void uwb_rsv_get_usable_mas(struct uwb_rsv *rsv, struct uwb_mas_bm *mas)
{ bitmap_zero(mas->bm, UWB_NUM_MAS); bitmap_andnot(mas->bm, rsv->mas.bm, rsv->rc->cnflt_alien_bitmap.bm, UWB_NUM_MAS); }
robutest/uclinux
C++
GPL-2.0
60
/* It install the RepublishSecPpi depent on PcdMigrateTemporaryRamFirmwareVolumes, install the PPI when the PcdMigrateTemporaryRamFirmwareVolumes enabled. */
EFI_STATUS EFIAPI SecMigrationPeiInitialize(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
/* It install the RepublishSecPpi depent on PcdMigrateTemporaryRamFirmwareVolumes, install the PPI when the PcdMigrateTemporaryRamFirmwareVolumes enabled. */ EFI_STATUS EFIAPI SecMigrationPeiInitialize(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
{ EFI_STATUS Status; Status = EFI_ABORTED; if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { Status = PeiServicesInstallPpi (&mEdkiiRepublishSecPpiDescriptor); ASSERT_EFI_ERROR (Status); } return Status; }
tianocore/edk2
C++
Other
4,240
/* Doubles the value of a byte for values up to 127. */
uint8_t _double_byte(uint8_t a)
/* Doubles the value of a byte for values up to 127. */ uint8_t _double_byte(uint8_t a)
{ return ((a<<1) ^ ((a>>7) * MASK_TWENTY_SEVEN)); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Experimental initialization sequence for the integrated sound system of the Compaq Deskpro M. */
static int init_deskpro_m(struct address_info *hw_config)
/* Experimental initialization sequence for the integrated sound system of the Compaq Deskpro M. */ static int init_deskpro_m(struct address_info *hw_config)
{ unsigned char tmp; if ((tmp = inb(0xc44)) == 0xff) { DDB(printk("init_deskpro_m: Dead port 0xc44\n")); return 0; } outb(0x10, 0xc44); outb(0x40, 0xc45); outb(0x00, 0xc46); outb(0xe8, 0xc47); outb(0x14, 0xc44); outb(0x40, 0xc45); outb(0x00, 0xc46); outb(0xe8, 0xc47); outb(0x10, 0xc44); return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* This function adds any additional addresses reported by the system_map firmware to the parisc device. */
static void __init add_system_map_addresses(struct parisc_device *dev, int num_addrs, int module_instance)
/* This function adds any additional addresses reported by the system_map firmware to the parisc device. */ static void __init add_system_map_addresses(struct parisc_device *dev, int num_addrs, int module_instance)
{ int i; long status; struct pdc_system_map_addr_info addr_result; dev->addr = kmalloc(num_addrs * sizeof(unsigned long), GFP_KERNEL); if(!dev->addr) { printk(KERN_ERR "%s %s(): memory allocation failure\n", __FILE__, __func__); return; } for(i = 1; i <= num_addrs; ++i) { status = pdc_system_map_f...
EmcraftSystems/linux-emcraft
C++
Other
266
/* retval kStatus_Success Enable System Low Voltage Detect in low power mode successfully. */
status_t SPC_EnableLowPowerModeSystemLowVoltageDetect(SPC_Type *base, bool enable)
/* retval kStatus_Success Enable System Low Voltage Detect in low power mode successfully. */ status_t SPC_EnableLowPowerModeSystemLowVoltageDetect(SPC_Type *base, bool enable)
{ status_t status = kStatus_Success; if (enable) { base->LP_CFG |= SPC_LP_CFG_SYS_LVDE_MASK; } else { base->LP_CFG &= ~SPC_LP_CFG_SYS_LVDE_MASK; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base DCIC peripheral base address. param regionIdx Region index, from 0 to (DCIC_REGION_COUNT - 1). param config Pointer to the configuration. */
void DCIC_EnableRegion(DCIC_Type *base, uint8_t regionIdx, const dcic_region_config_t *config)
/* param base DCIC peripheral base address. param regionIdx Region index, from 0 to (DCIC_REGION_COUNT - 1). param config Pointer to the configuration. */ void DCIC_EnableRegion(DCIC_Type *base, uint8_t regionIdx, const dcic_region_config_t *config)
{ assert(regionIdx < DCIC_REGION_COUNT); assert(NULL != config); base->REGION[regionIdx].DCICRRS = config->refCrc; base->REGION[regionIdx].DCICRS = (((uint32_t)config->lowerRightX << DCIC_DCICRS_END_OFFSET_X_SHIFT) | ((uint32_t)config->lowerRightY << DCIC_DCICRS_END...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Clear one bit of the operational register while keeping other bits. */
VOID XhcClearOpRegBit(IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
/* Clear one bit of the operational register while keeping other bits. */ VOID XhcClearOpRegBit(IN USB_XHCI_INSTANCE *Xhc, IN UINT32 Offset, IN UINT32 Bit)
{ UINT32 Data; Data = XhcReadOpReg (Xhc, Offset); Data &= ~Bit; XhcWriteOpReg (Xhc, Offset, Data); }
tianocore/edk2
C++
Other
4,240
/* Query the Numonyx flash ID Parameter: data: buffer to store the ID queried Return: SUCCESS on success, otherwise FAIL */
int spi_nor_query_numonyx(uint8_t *data)
/* Query the Numonyx flash ID Parameter: data: buffer to store the ID queried Return: SUCCESS on success, otherwise FAIL */ int spi_nor_query_numonyx(uint8_t *data)
{ spi_nor_tx_buf[3] = RDID; if (ecspi_xfer(dev_spi_nor, spi_nor_tx_buf, spi_nor_rx_buf, 20 * 8) == FALSE) { return FAIL; } data[0] = spi_nor_rx_buf[0]; data[1] = spi_nor_rx_buf[1]; data[2] = spi_nor_rx_buf[2]; data[3] = spi_nor_rx_buf[3]; return SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is used to setup the voltage switch. */
s32 XSdPs_SetupVoltageSwitch(XSdPs *InstancePtr)
/* This function is used to setup the voltage switch. */ s32 XSdPs_SetupVoltageSwitch(XSdPs *InstancePtr)
{ u32 Timeout = 10000; s32 Status; u32 ReadReg; Status = XSdPs_CmdTransfer(InstancePtr, CMD11, 0U, 0U); if (Status != XST_SUCCESS) { Status = XST_FAILURE; goto RETURN_PATH; } do { ReadReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress, XSDPS_PRES_STAT...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */
int32_t lsm6dso_xl_fast_settling_get(lsm6dso_ctx_t *ctx, uint8_t *val)
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */ int32_t lsm6dso_xl_fast_settling_get(lsm6dso_ctx_t *ctx, uint8_t *val)
{ lsm6dso_ctrl8_xl_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t*)&reg, 1); *val = reg.fastsettl_mode_xl; return ret; }
alexander-g-dean/ESF
C++
null
41
/* Write data element to the SPI interface with block. */
void xSPIDataPut(unsigned long ulBase, unsigned long ulData)
/* Write data element to the SPI interface with block. */ void xSPIDataPut(unsigned long ulBase, unsigned long ulData)
{ unsigned char ucBitLength = SPIBitLengthGet(ulBase); unsigned long ulFlag; xASSERT(ulBase == SPI0_BASE); ulFlag = xHWREG(ulBase + SPI_FCR) & SPI_FCR_FIFOEN; if(ulFlag != SPI_FCR_FIFOEN) { while(!(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE)) { } } else { while(!(xHWREG(ulBase + SPI_S...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Init interrupts callback for the specified SPI Port. */
void SPIIntCallbackInit(unsigned long ulBase, xtEventCallback xtSPICallback)
/* Init interrupts callback for the specified SPI Port. */ void SPIIntCallbackInit(unsigned long ulBase, xtEventCallback xtSPICallback)
{ xASSERT((ulBase == SPI3_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)); switch(ulBase) { case SPI1_BASE: { g_pfnSPIHandlerCallbacks[0] = xtSPICallback; break; } case SPI2_BASE: { g_pfnSPIHandlerCallbacks[1] = ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */
long SSIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData)
/* This function replaces the original SSIDataNonBlockingGet() API and performs the same actions. A macro is provided in */ long SSIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData)
{ ASSERT(SSIBaseValid(ulBase)); if(HWREG(ulBase + SSI_O_SR) & SSI_SR_RNE) { *pulData = HWREG(ulBase + SSI_O_DR); return(1); } else { return(0); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* atl2_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */
static u32 atl2_hash_mc_addr(struct atl2_hw *hw, u8 *mc_addr)
/* atl2_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */ static u32 atl2_hash_mc_addr(struct atl2_hw *hw, u8 *mc_addr)
{ u32 crc32, value; int i; value = 0; crc32 = ether_crc_le(6, mc_addr); for (i = 0; i < 32; i++) value |= (((crc32 >> i) & 1) << (31 - i)); return value; }
robutest/uclinux
C++
GPL-2.0
60
/* Comparator Interrupt Handler. If users want to user the ACMP Interrupt Callback feature, Users should promise that the ACMP Handle in the vector table is ACMPIntHandler. */
void ACMP01IntHandler(void)
/* Comparator Interrupt Handler. If users want to user the ACMP Interrupt Callback feature, Users should promise that the ACMP Handle in the vector table is ACMPIntHandler. */ void ACMP01IntHandler(void)
{ unsigned long ulBase = ACMP01_BASE; unsigned long ulIntFlags; ulIntFlags = xHWREG(ulBase + ACMP_SR); xHWREG(ulBase + ACMP_SR) = ulIntFlags; if((ulIntFlags & ACMP_SR_CMPF0) && g_pfnACMPHandlerCallbacks[0]) { g_pfnACMPHandlerCallbacks[0](0, 0, 0, 0); } if((ulIntFlags & ACMP_SR_CM...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* DMA Channel Set Priority. Channel Priority has four levels: low to very high. This has precedence over the hardware priority. */
void dma_set_priority(uint32_t dma, uint8_t channel, uint32_t prio)
/* DMA Channel Set Priority. Channel Priority has four levels: low to very high. This has precedence over the hardware priority. */ void dma_set_priority(uint32_t dma, uint8_t channel, uint32_t prio)
{ DMA_CCR(dma, channel) &= ~(DMA_CCR_PL_MASK); DMA_CCR(dma, channel) |= prio; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Allocate buffer for HCI command, fill in parameters and send the command... */
static int send_hci_command(uint16_t opcode, uint8_t param_len, uint16_t response)
/* Allocate buffer for HCI command, fill in parameters and send the command... */ static int send_hci_command(uint16_t opcode, uint8_t param_len, uint16_t response)
{ struct net_buf *buf; void *cp; int err = 0; waiting_response = response; buf = hci_cmd_create(waiting_opcode = opcode, param_len); if (buf) { if (param_len) { cp = net_buf_add(buf, param_len); edtt_read((uint8_t *)cp, param_len, EDTTT_BLOCK); } err = bt_send(buf); if (err) { LOG_ERR("Failed to ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This is a callback routine supplied to UNDI at undi_start time. */
VOID EFIAPI SnpUndi32CallbackDelay(IN UINT64 UniqueId, IN UINT64 MicroSeconds)
/* This is a callback routine supplied to UNDI at undi_start time. */ VOID EFIAPI SnpUndi32CallbackDelay(IN UINT64 UniqueId, IN UINT64 MicroSeconds)
{ if (MicroSeconds != 0) { gBS->Stall ((UINTN)MicroSeconds); } }
tianocore/edk2
C++
Other
4,240
/* The next set of routines handle the different operation types, associated with UCP. */
static void add_00O(proto_tree *tree, tvbuff_t *tvb)
/* The next set of routines handle the different operation types, associated with UCP. */ static void add_00O(proto_tree *tree, tvbuff_t *tvb)
{ int offset = 1; UcpHandleString(hf_ucp_parm_AdC); UcpHandleString(hf_ucp_parm_OAdC); UcpHandleString(hf_ucp_parm_OAC); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Unregisters a USB host pipe callback. Unregisters an asynchronous callback implemented by the user. Removing it from the internal callback registration table. */
enum status_code usb_host_pipe_unregister_callback(struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type)
/* Unregisters a USB host pipe callback. Unregisters an asynchronous callback implemented by the user. Removing it from the internal callback registration table. */ enum status_code usb_host_pipe_unregister_callback(struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type)
{ Assert(module_inst); Assert(pipe_num < USB_PIPE_NUM); module_inst->host_pipe_callback[pipe_num][callback_type] = NULL; module_inst->host_pipe_registered_callback_mask[pipe_num] &= ~(1 << callback_type); return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Check for program or erase operation is completed. */
static uint32_t check_status(const struct nand_flash_raw *raw)
/* Check for program or erase operation is completed. */ static uint32_t check_status(const struct nand_flash_raw *raw)
{ uint32_t status; WRITE_COMMAND(raw, NAND_COMMAND_STATUS); status = READ_DATA8(raw); if (((status & NAND_STATUS_READY) != NAND_STATUS_READY) || ((status & NAND_STATUS_ERROR) != 0)) { return 0; } return 1; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables the Time Triggered Communication mode for CAN. */
void CAN_EnableTTComMode(void)
/* Enables the Time Triggered Communication mode for CAN. */ void CAN_EnableTTComMode(void)
{ CAN->MCTRL_B.TTCM = BIT_SET; CAN->sTxMailBox[0].TXDLEN_B.TXGT = BIT_SET; CAN->sTxMailBox[1].TXDLEN_B.TXGT = BIT_SET; CAN->sTxMailBox[2].TXDLEN_B.TXGT = BIT_SET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* brief Return Frequency of High-Freq output of FRO return Frequency of High-Freq output of FRO */
static uint32_t GetFroHfFreq(void)
/* brief Return Frequency of High-Freq output of FRO return Frequency of High-Freq output of FRO */ static uint32_t GetFroHfFreq(void)
{ return ((ANACTRL->FRO192M_CTRL & ANACTRL_FRO192M_CTRL_ENA_96MHZCLK_MASK) != 0UL) ? 96000000U : 0U; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* param base Pointer to FLEXIO_I2C_Type structure. param enable True to configure send ACK, false configure to send NAK. */
void FLEXIO_I2C_MasterEnableAck(FLEXIO_I2C_Type *base, bool enable)
/* param base Pointer to FLEXIO_I2C_Type structure. param enable True to configure send ACK, false configure to send NAK. */ void FLEXIO_I2C_MasterEnableAck(FLEXIO_I2C_Type *base, bool enable)
{ uint32_t tmpConfig = 0; tmpConfig = base->flexioBase->SHIFTCFG[base->shifterIndex[0]]; tmpConfig &= ~FLEXIO_SHIFTCFG_SSTOP_MASK; if (enable) { tmpConfig |= FLEXIO_SHIFTCFG_SSTOP(kFLEXIO_ShifterStopBitLow); } else { tmpConfig |= FLEXIO_SHIFTCFG_SSTOP(kFLEXIO_ShifterStopB...
eclipse-threadx/getting-started
C++
Other
310
/* Process all network interface present on the system. */
static int process_iflist(int skfd, char *args[], int count)
/* Process all network interface present on the system. */ static int process_iflist(int skfd, char *args[], int count)
{ num_takeover = 0; iw_enum_devices(skfd, &process_ifname, args, count); if(force_takeover && num_takeover) iw_enum_devices(skfd, &process_ifname, args, count); return(0); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Add a pinned breakpoint for the given task in our constraint table */
static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
/* Add a pinned breakpoint for the given task in our constraint table */ static void toggle_bp_task_slot(struct task_struct *tsk, int cpu, bool enable)
{ unsigned int *tsk_pinned; int count = 0; count = task_bp_pinned(tsk); tsk_pinned = per_cpu(nr_task_bp_pinned, cpu); if (enable) { tsk_pinned[count]++; if (count > 0) tsk_pinned[count-1]--; } else { tsk_pinned[count]--; if (count > 0) tsk_pinned[count-1]++; } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable control interrupts on a given USB controller. */
void USBIntEnableControl(unsigned long ulBase, unsigned long ulFlags)
/* Enable control interrupts on a given USB controller. */ void USBIntEnableControl(unsigned long ulBase, unsigned long ulFlags)
{ ASSERT(ulBase == USB0_BASE); ASSERT((ulFlags & (~USB_INTCTRL_ALL)) == 0); if(ulFlags & USB_INTCTRL_STATUS) { HWREGB(ulBase + USB_O_IE) |= ulFlags; } if(ulFlags & USB_INTCTRL_POWER_FAULT) { HWREG(ulBase + USB_O_EPCIM) = USB_EPCIM_PF; } if(ulFlags & USB_INTCTRL_MODE_D...
watterott/WebRadio
C++
null
71
/* Note: no_uld_attach flag determines whether the disk device is attached to block layer. A value of */
static void _scsih_reprobe_target(struct scsi_target *starget, int no_uld_attach)
/* Note: no_uld_attach flag determines whether the disk device is attached to block layer. A value of */ static void _scsih_reprobe_target(struct scsi_target *starget, int no_uld_attach)
{ struct MPT2SAS_TARGET *sas_target_priv_data = starget->hostdata; if (no_uld_attach) sas_target_priv_data->flags |= MPT_TARGET_FLAGS_RAID_COMPONENT; else sas_target_priv_data->flags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; starget_for_each_device(starget, no_uld_attach ? (void *)1 : NULL, _scsih_reprobe_lun);...
robutest/uclinux
C++
GPL-2.0
60
/* Compare two strings for equality, in a case-insensitive way. This function handles casing only for ASCII letters. */
static int eqnocase(const void *s1, const void *s2, size_t len)
/* Compare two strings for equality, in a case-insensitive way. This function handles casing only for ASCII letters. */ static int eqnocase(const void *s1, const void *s2, size_t len)
{ const unsigned char *buf1, *buf2; buf1 = s1; buf2 = s2; while (len -- > 0) { int x1, x2; x1 = *buf1 ++; x2 = *buf2 ++; if (x1 >= 'A' && x1 <= 'Z') { x1 += 'a' - 'A'; } if (x2 >= 'A' && x2 <= 'Z') { x2 += 'a' - 'A'; } if (x1 != x2) { return 0; } } return 1; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* wait RTC last write operation finished flag set */
void rtc_lwoff_wait(void)
/* wait RTC last write operation finished flag set */ void rtc_lwoff_wait(void)
{ while(RESET == (RTC_CTL & RTC_CTL_LWOFF)){ } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Puts a data element into the SPI transmit FIFO. This function replaces the original SSIDataNonBlockingPut() API and performs the same actions. A macro is provided in */
long SPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
/* Puts a data element into the SPI transmit FIFO. This function replaces the original SSIDataNonBlockingPut() API and performs the same actions. A macro is provided in */ long SPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
{ xASSERT((ulBase == SPI3_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)); if(xHWREG(ulBase + SPI_SR) & SPI_SR_TXE) { xHWREG(ulBase + SPI_DR) = ulData; return(1); } else { return(0); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Converts a I20 device path structure to its string representative. */
VOID DevPathToTextI2O(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a I20 device path structure to its string representative. */ VOID DevPathToTextI2O(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ I2O_DEVICE_PATH *I2ODevPath; I2ODevPath = DevPath; UefiDevicePathLibCatPrint (Str, L"I2O(0x%x)", I2ODevPath->Tid); }
tianocore/edk2
C++
Other
4,240
/* This function sets the signature algorithms for use by a specified TLS object. */
EFI_STATUS EFIAPI TlsSetSignatureAlgoList(IN VOID *Tls, IN UINT8 *Data, IN UINTN DataSize)
/* This function sets the signature algorithms for use by a specified TLS object. */ EFI_STATUS EFIAPI TlsSetSignatureAlgoList(IN VOID *Tls, IN UINT8 *Data, IN UINTN DataSize)
{ CALL_CRYPTO_SERVICE (TlsSetSignatureAlgoList, (Tls, Data, DataSize), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* Enables the interrupt of a pin with the specified settings. */
uint32_t gpio_enable_pin_interrupt(uint32_t pin, uint32_t mode)
/* Enables the interrupt of a pin with the specified settings. */ uint32_t gpio_enable_pin_interrupt(uint32_t pin, uint32_t mode)
{ volatile avr32_gpio_port_t *gpio_port = &AVR32_GPIO.port[pin >> 5]; gpio_port->gfers = 1 << (pin & 0x1F); if (GPIO_INVALID_ARGUMENT == gpio_configure_edge_detector(pin, mode)) { return(GPIO_INVALID_ARGUMENT); } gpio_port->iers = 1 << (pin & 0x1F); return GPIO_SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Find the next packet and parse it; called from wtap_read(). */
static gboolean iseries_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
/* Find the next packet and parse it; called from wtap_read(). */ static gboolean iseries_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{ gint64 offset; offset = iseries_seek_next_packet (wth, err, err_info); if (offset < 0) return FALSE; *data_offset = offset; return iseries_parse_packet (wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Return pointer to the string mapped by 'key'. */
const char* qdict_get_str(const QDict *qdict, const char *key)
/* Return pointer to the string mapped by 'key'. */ const char* qdict_get_str(const QDict *qdict, const char *key)
{ QObject *obj = qdict_get_obj(qdict, key, QTYPE_QSTRING); return qstring_get_str(qobject_to_qstring(obj)); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Sets the rawmidi operators for the given stream direction. */
void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, struct snd_rawmidi_ops *ops)
/* Sets the rawmidi operators for the given stream direction. */ void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, struct snd_rawmidi_ops *ops)
{ struct snd_rawmidi_substream *substream; list_for_each_entry(substream, &rmidi->streams[stream].substreams, list) substream->ops = ops; }
robutest/uclinux
C++
GPL-2.0
60
/* Creates a new tvbuff and call decode_IOR with a NULL tree, just to grab repoid etc for our objkey hash. */
static guint32 string_to_IOR(guchar *in, guint32 in_len, guint8 **out)
/* Creates a new tvbuff and call decode_IOR with a NULL tree, just to grab repoid etc for our objkey hash. */ static guint32 string_to_IOR(guchar *in, guint32 in_len, guint8 **out)
{ return 0; } for (i=4; i<in_len-1; i+=2) { if ( g_ascii_isxdigit(in[i]) && g_ascii_isxdigit(in[i+1]) ) { if ( (tmpval_msb = ws_xton(in[i])) < 0 ) { report_failure("giop: Invalid value in IOR %i", tmpval_msb); } if ( (tmpval_lsb = ws_xton(in[i+1])) < 0 ) { report_failure("g...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* brief DMA instance 1, channel 6 IRQ handler. */
void EDMA_1_CH6_DriverIRQHandler(void)
/* brief DMA instance 1, channel 6 IRQ handler. */ void EDMA_1_CH6_DriverIRQHandler(void)
{ EDMA_DriverIRQHandler(1U, 6U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Deinitialize the I2Cx peripheral registers to their default reset values. */
void I2C_DeInit(I2C_TypeDef *I2Cx)
/* Deinitialize the I2Cx peripheral registers to their default reset values. */ void I2C_DeInit(I2C_TypeDef *I2Cx)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); if (I2Cx == I2C1) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); } else if (I2Cx == I2C2) { RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2...
MaJerle/stm32f429
C++
null
2,036
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt8Sub(IN INT8 Minuend, IN INT8 Subtrahend, OUT INT8 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to INT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeInt8Sub(IN INT8 Minuend, IN INT8 Subtrahend, OUT INT8 *Result)
{ return SafeInt32ToInt8 (((INT32)Minuend) - ((INT32)Subtrahend), Result); }
tianocore/edk2
C++
Other
4,240
/* Program a Half Word to FLASH. Status bit polling is used to detect end of operation. */
void flash_program_half_word(uint32_t address, uint16_t data)
/* Program a Half Word to FLASH. Status bit polling is used to detect end of operation. */ void flash_program_half_word(uint32_t address, uint16_t data)
{ flash_wait_for_last_operation(); if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) { FLASH_CR2 |= FLASH_CR_PG; } else { FLASH_CR |= FLASH_CR_PG; } MMIO16(address) = data; flash_wait_for_last_operation(); if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) { FLASH_CR2 &= ...
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* RETURNS: Zero if everything went ok, nonzero otherwise. */
bool drm_helper_initial_config(struct drm_device *dev)
/* RETURNS: Zero if everything went ok, nonzero otherwise. */ bool drm_helper_initial_config(struct drm_device *dev)
{ int count = 0; drm_helper_disable_unused_functions(dev); drm_fb_helper_parse_command_line(dev); count = drm_helper_probe_connector_modes(dev, dev->mode_config.max_width, dev->mode_config.max_height); if (count == 0) printk(KERN_INFO "No connectors reported connected with modes\n"); drm_setup_crt...
robutest/uclinux
C++
GPL-2.0
60
/* Configures the priority grouping: pre-emption priority and subpriority. */
void NVIC_ConfigPriorityGroup(NVIC_PRIORITY_GROUP_T priorityGroup)
/* Configures the priority grouping: pre-emption priority and subpriority. */ void NVIC_ConfigPriorityGroup(NVIC_PRIORITY_GROUP_T priorityGroup)
{ SCB->AIRCR = AIRCR_VECTKEY_MASK | priorityGroup; }
pikasTech/PikaPython
C++
MIT License
1,403
/* @dev: GPIO peripheral device @offset: the GPIO pin offset from the GPIO controller */
int pinctrl_gpio_request(struct udevice *dev, unsigned offset)
/* @dev: GPIO peripheral device @offset: the GPIO pin offset from the GPIO controller */ int pinctrl_gpio_request(struct udevice *dev, unsigned offset)
{ const struct pinctrl_ops *ops; struct udevice *pctldev; unsigned int pin_selector; int ret; ret = pinctrl_gpio_get_pinctrl_and_offset(dev, offset, &pctldev, &pin_selector); if (ret) return ret; ops = pinctrl_get_ops(pctldev); if (!ops || !ops->gpio_request_enable) return -ENOTSUPP; return ops->gp...
4ms/stm32mp1-baremetal
C++
Other
137
/* Converts a 1394 device path structure to its string representative. */
VOID DevPathToText1394(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a 1394 device path structure to its string representative. */ VOID DevPathToText1394(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ F1394_DEVICE_PATH *F1394DevPath; F1394DevPath = DevPath; UefiDevicePathLibCatPrint (Str, L"I1394(%016lx)", F1394DevPath->Guid); }
tianocore/edk2
C++
Other
4,240
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the atl1c_resume routine. */
static void atl1c_io_resume(struct pci_dev *pdev)
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. Implementation resembles the second-half of the atl1c_resume routine. */ static void atl1c_io_resume(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct atl1c_adapter *adapter = netdev_priv(netdev); if (netif_running(netdev)) { if (atl1c_up(adapter)) { if (netif_msg_hw(adapter)) dev_err(&pdev->dev, "Cannot bring device back up after reset\n"); return; } } netif_device_attach(netdev); }
robutest/uclinux
C++
GPL-2.0
60
/* Prevent the BIOS trapping accesses to the Cyrix CS5530A video device configuration space. */
static void pci_early_fixup_cyrix_5530(struct pci_dev *dev)
/* Prevent the BIOS trapping accesses to the Cyrix CS5530A video device configuration space. */ static void pci_early_fixup_cyrix_5530(struct pci_dev *dev)
{ u8 r; pci_read_config_byte(dev, 0x42, &r); r &= 0xfd; pci_write_config_byte(dev, 0x42, r); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Set the position in a file being parsed. This can be used to print error messages deeper down in a parser. */
VOID ParserSetPosition(CHAR8 *SourceFileName, UINT32 LineNum)
/* Set the position in a file being parsed. This can be used to print error messages deeper down in a parser. */ VOID ParserSetPosition(CHAR8 *SourceFileName, UINT32 LineNum)
{ mSourceFileName = SourceFileName; mSourceFileLineNum = LineNum; }
tianocore/edk2
C++
Other
4,240
/* This function calculates and updates an UINT8 checksum. */
EFI_STATUS AcpiPlatformChecksum(IN VOID *Buffer, IN UINTN Size, IN UINTN ChecksumOffset)
/* This function calculates and updates an UINT8 checksum. */ EFI_STATUS AcpiPlatformChecksum(IN VOID *Buffer, IN UINTN Size, IN UINTN ChecksumOffset)
{ UINT8 Sum; UINT8 *Ptr; Sum = 0; Ptr = Buffer; Ptr[ChecksumOffset] = 0; while ((Size--) != 0) { Sum = (UINT8)(Sum + (*Ptr++)); } Ptr = Buffer; Ptr[ChecksumOffset] = (UINT8)(0xff - Sum + 1); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* It is up to the caller to serialize access to the runlists @dstbase and @srcbase. */
static void ntfs_rl_mc(runlist_element *dstbase, int dst, runlist_element *srcbase, int src, int size)
/* It is up to the caller to serialize access to the runlists @dstbase and @srcbase. */ static void ntfs_rl_mc(runlist_element *dstbase, int dst, runlist_element *srcbase, int src, int size)
{ if (likely(size > 0)) memcpy(dstbase + dst, srcbase + src, size * sizeof(*dstbase)); }
robutest/uclinux
C++
GPL-2.0
60
/* brief Return Frequency of FRO 1MHz return Frequency of FRO 1MHz */
uint32_t CLOCK_GetFro1MFreq(void)
/* brief Return Frequency of FRO 1MHz return Frequency of FRO 1MHz */ uint32_t CLOCK_GetFro1MFreq(void)
{ return ((SYSCON->CLOCK_CTRL & SYSCON_CLOCK_CTRL_FRO1MHZ_CLK_ENA_MASK) != 0UL) ? 1000000U : 0U; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Selects Batching Data Rate (writing frequency in FIFO) for fourth data set.. */
int32_t lsm6dsl_fifo_dataset_4_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_ds4_fifo_t val)
/* Selects Batching Data Rate (writing frequency in FIFO) for fourth data set.. */ int32_t lsm6dsl_fifo_dataset_4_batch_set(stmdev_ctx_t *ctx, lsm6dsl_dec_ds4_fifo_t val)
{ lsm6dsl_fifo_ctrl4_t fifo_ctrl4; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); if(ret == 0){ fifo_ctrl4.dec_ds4_fifo = (uint8_t)val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* We defer the timer blanking to work queue so it can take the console mutex (console operations can still happen at irq time, but only from printk which has the console mutex. Not perfect yet, but better than no locking */
static void blank_screen_t(unsigned long dummy)
/* We defer the timer blanking to work queue so it can take the console mutex (console operations can still happen at irq time, but only from printk which has the console mutex. Not perfect yet, but better than no locking */ static void blank_screen_t(unsigned long dummy)
{ if (unlikely(!keventd_up())) { mod_timer(&console_timer, jiffies + (blankinterval * HZ)); return; } blank_timer_expired = 1; schedule_work(&console_work); }
robutest/uclinux
C++
GPL-2.0
60
/* The constructor function caches the pointer of the MM Services Table. */
EFI_STATUS EFIAPI StandaloneMmServicesTableLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
/* The constructor function caches the pointer of the MM Services Table. */ EFI_STATUS EFIAPI StandaloneMmServicesTableLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
{ gMmst = MmSystemTable; ASSERT (gMmst != NULL); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Un-Register the Service D and all its Characteristics... */
void service_d_2_remove(void)
/* Un-Register the Service D and all its Characteristics... */ void service_d_2_remove(void)
{ bt_gatt_service_unregister(&service_d_2_svc); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enter sleep mode using WFI instruction. Enable interrupt first and then disable it after wake up. */
static void enter_asleep(void)
/* Enter sleep mode using WFI instruction. Enable interrupt first and then disable it after wake up. */ static void enter_asleep(void)
{ while (1) { puts("Now switching the device into sleep mode...\r"); adc_get_status(ADC); adc_enable_interrupt(ADC, ADC_IER_COMPE); __WFI(); break; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Called by the low layer protocol to copy some data in the socket send buffer starting from the specific offset to a buffer provided by the caller. */
UINT32 SockGetDataToSend(IN SOCKET *Sock, IN UINT32 Offset, IN UINT32 Len, OUT UINT8 *Dest)
/* Called by the low layer protocol to copy some data in the socket send buffer starting from the specific offset to a buffer provided by the caller. */ UINT32 SockGetDataToSend(IN SOCKET *Sock, IN UINT32 Offset, IN UINT32 Len, OUT UINT8 *Dest)
{ ASSERT ((Sock != NULL) && SockStream == Sock->Type); return NetbufQueCopy ( Sock->SndBuffer.DataQueue, Offset, Len, Dest ); }
tianocore/edk2
C++
Other
4,240
/* Reset ETH peripheral registers to their default reset values. ETH Configuration */
void ETH_Reset(void)
/* Reset ETH peripheral registers to their default reset values. ETH Configuration */ void ETH_Reset(void)
{ RCM_EnableAHB1PeriphReset(RCM_AHB1_PERIPH_ETH_MAC); RCM_DisableAHB1PeriphReset(RCM_AHB1_PERIPH_ETH_MAC); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Device enumeration step 6 End of Get device descriptor request. Wait 20ms in IDLE state. */
static void uhc_enumeration_step6(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
/* Device enumeration step 6 End of Get device descriptor request. Wait 20ms in IDLE state. */ static void uhc_enumeration_step6(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans)
{ UNUSED(add); if ((status != UHD_TRANS_NOERROR) || (payload_trans < 8) || (uhc_dev_enum->dev_desc.bDescriptorType != USB_DT_DEVICE)) { uhc_enumeration_error((status == UHD_TRANS_DISCONNECT)? UHC_ENUM_DISCONNECT:UHC_ENUM_FAIL); return; } uhc_enable_timeout_callback(20, uhc_enumeration_step7); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge. */
void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
/* Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge. */ void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
{ uint32_t tmpreg = 0; assert_param(IS_RTC_TIMESTAMP_EDGE(RTC_TimeStampEdge)); assert_param(IS_FUNCTIONAL_STATE(NewState)); tmpreg = (uint32_t)(RTC->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE)); if (NewState != DISABLE) { tmpreg |= (uint32_t)(RTC_TimeStampEdge | RTC_CR_TSE); } else { tmpreg |...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable the automatic slave select function of the specified SPI port. The */
void SPIAutoSSEnable(unsigned long ulBase, unsigned long ulSlaveSel)
/* Enable the automatic slave select function of the specified SPI port. The */ void SPIAutoSSEnable(unsigned long ulBase, unsigned long ulSlaveSel)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) || (ulBase == SPI3_BASE)); xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) || (ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1)); xHWREG(ulBase + SPI_SSR) |= SPI_AUTOSS; xHWREG(ul...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Add 32-bit fixed memory resource to resources list. */
static void __init isapnp_parse_fixed_mem32_resource(struct pnp_dev *dev, unsigned int option_flags, int size)
/* Add 32-bit fixed memory resource to resources list. */ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_dev *dev, unsigned int option_flags, int size)
{ unsigned char tmp[9]; resource_size_t base, len; unsigned char flags; isapnp_peek(tmp, size); base = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; len = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; flags = tmp[0]; pnp_register_mem_resource(dev, option_flags, base, base, 0, len, flags)...
robutest/uclinux
C++
GPL-2.0
60
/* To generate a key to KS SRAM for ECDSA. */
int32_t RNG_ECDSA(uint32_t u32KeySize)
/* To generate a key to KS SRAM for ECDSA. */ int32_t RNG_ECDSA(uint32_t u32KeySize)
{ int32_t timeout; int32_t i; CRPT->PRNG_CTL = (u32KeySize << CRPT_PRNG_CTL_KEYSZ_Pos) | CRPT_PRNG_CTL_START_Msk | PRNG_CTL_SEEDSRC_TRNG; timeout = 0x10000; i = 0; while (CRPT->PRNG_CTL & CRPT_PRNG_CTL_BUSY_Msk) { if (i++ > timeout) { return -1; } } ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* LOCKING: This routine uses the host lock to protect the DMA stop. */
static void mv_port_stop(struct ata_port *ap)
/* LOCKING: This routine uses the host lock to protect the DMA stop. */ static void mv_port_stop(struct ata_port *ap)
{ unsigned long flags; spin_lock_irqsave(ap->lock, flags); mv_stop_edma(ap); mv_enable_port_irqs(ap, 0); spin_unlock_irqrestore(ap->lock, flags); mv_port_free_dma_mem(ap); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* brief Gets the slave transfer status during a non-blocking transfer. param base The LPI2C peripheral base address. param handle Pointer to i2c_slave_handle_t structure. param count Pointer to a value to hold the number of bytes transferred. May be NULL if the count is not required. retval #kStatus_Success retval #kS...
status_t LPI2C_SlaveTransferGetCount(LPI2C_Type *base, lpi2c_slave_handle_t *handle, size_t *count)
/* brief Gets the slave transfer status during a non-blocking transfer. param base The LPI2C peripheral base address. param handle Pointer to i2c_slave_handle_t structure. param count Pointer to a value to hold the number of bytes transferred. May be NULL if the count is not required. retval #kStatus_Success retval #kS...
{ assert(handle); if (!count) { return kStatus_InvalidArgument; } if (!handle->isBusy) { *count = 0; return kStatus_NoTransferInProgress; } *count = handle->transferredCount; return kStatus_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Match asymmetric keys by an exact match on an ID. */
static bool asymmetric_key_cmp(const struct key *key, const struct key_match_data *match_data)
/* Match asymmetric keys by an exact match on an ID. */ static bool asymmetric_key_cmp(const struct key *key, const struct key_match_data *match_data)
{ const struct asymmetric_key_ids *kids = asymmetric_key_ids(key); const struct asymmetric_key_id *match_id = match_data->preparsed; return asymmetric_match_key_ids(kids, match_id, asymmetric_key_id_same); }
4ms/stm32mp1-baremetal
C++
Other
137
/* helper function to move a thread off the idle list after new pending work is added. */
static void check_busy_worker(struct btrfs_worker_thread *worker)
/* helper function to move a thread off the idle list after new pending work is added. */ static void check_busy_worker(struct btrfs_worker_thread *worker)
{ if (worker->idle && atomic_read(&worker->num_pending) >= worker->workers->idle_thresh) { unsigned long flags; spin_lock_irqsave(&worker->workers->lock, flags); worker->idle = 0; if (!list_empty(&worker->worker_list)) { list_move_tail(&worker->worker_list, &worker->workers->worker_list); }...
robutest/uclinux
C++
GPL-2.0
60
/* IDL long ClientAttach( IDL void *element_1, IDL long element_2, IDL long element_3, IDL wchar_t *element_4, IDL wchar_t *element_5 IDL ); */
static int dissect_tapi_client_attach_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL long ClientAttach( IDL void *element_1, IDL long element_2, IDL long element_3, IDL wchar_t *element_4, IDL wchar_t *element_5 IDL ); */ static int dissect_tapi_client_attach_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_tapi_unknown_long, NULL); offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, di, drep, NDR_POINTER_REF, "unknown string", hf_tapi_unknown_string, 0); offset = dissect_ndr_str_pointer_item(tvb, offset, pinfo, tree, di, drep, ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Update the record referred to by cur to the value given by . This either works (return 0) or gets an EFSCORRUPTED error. */
STATIC int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len)
/* Update the record referred to by cur to the value given by . This either works (return 0) or gets an EFSCORRUPTED error. */ STATIC int xfs_alloc_update(struct xfs_btree_cur *cur, xfs_agblock_t bno, xfs_extlen_t len)
{ union xfs_btree_rec rec; rec.alloc.ar_startblock = cpu_to_be32(bno); rec.alloc.ar_blockcount = cpu_to_be32(len); return xfs_btree_update(cur, &rec); }
robutest/uclinux
C++
GPL-2.0
60
/* Authors: Dave Airlie Alex Deucher Jerome Glisse BIOS. */
static bool igp_read_bios_from_vram(struct radeon_device *rdev)
/* Authors: Dave Airlie Alex Deucher Jerome Glisse BIOS. */ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
{ uint8_t __iomem *bios; resource_size_t vram_base; resource_size_t size = 256 * 1024; rdev->bios = NULL; vram_base = drm_get_resource_start(rdev->ddev, 0); bios = ioremap(vram_base, size); if (!bios) { return false; } if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { iounmap(bios); return false; }...
robutest/uclinux
C++
GPL-2.0
60
/* alloc_swapdev_block - allocate a swap page and register that it has been allocated, so that it can be freed in case of an error. */
sector_t alloc_swapdev_block(int swap)
/* alloc_swapdev_block - allocate a swap page and register that it has been allocated, so that it can be freed in case of an error. */ sector_t alloc_swapdev_block(int swap)
{ unsigned long offset; offset = swp_offset(get_swap_page_of_type(swap)); if (offset) { if (swsusp_extents_insert(offset)) swap_free(swp_entry(swap, offset)); else return swapdev_block(swap, offset); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */
int32_t lsm6dso_filter_settling_mask_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */ int32_t lsm6dso_filter_settling_mask_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dso_ctrl4_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t *)&reg, 1); *val = reg.drdy_mask; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* This internal API writes the power mode in the sensor. */
static int8_t write_power_mode(uint8_t sensor_mode, struct bme280_dev *dev)
/* This internal API writes the power mode in the sensor. */ static int8_t write_power_mode(uint8_t sensor_mode, struct bme280_dev *dev)
{ int8_t rslt; uint8_t reg_addr = BME280_PWR_CTRL_ADDR; uint8_t sensor_mode_reg_val; rslt = bme280_get_regs(reg_addr, &sensor_mode_reg_val, 1, dev); if (rslt == BME280_OK) { sensor_mode_reg_val = BME280_SET_BITS_POS_0(sensor_mode_reg_val, BME280_SENSOR_MODE, sensor_mode); rslt = ...
eclipse-threadx/getting-started
C++
Other
310