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 |
|---|---|---|---|---|---|---|---|
/* Enables the SGE for DMAs. This is the last step in starting packet transfers. */ | void t3_sge_start(struct adapter *adap) | /* Enables the SGE for DMAs. This is the last step in starting packet transfers. */
void t3_sge_start(struct adapter *adap) | {
t3_set_reg_field(adap, A_SG_CONTROL, F_GLOBALENABLE, F_GLOBALENABLE);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ | UINT32 EFIAPI PciExpressBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData) | /* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). If StartBit is greater than 31, then ASSERT(). If EndBit is greater than 31, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT32 EFIAPI PciExpressBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData) | {
if (Address >= mDxeRuntimePciExpressLibPciExpressBaseSize) {
return (UINT32)-1;
}
return MmioBitFieldOr32 (
GetPciExpressAddress (Address),
StartBit,
EndBit,
OrData
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* An abort indicates that the current memory access cannot be completed, which occurs during an instruction prefetch. */ | void rt_hw_trap_pabt(struct rt_hw_register *regs) | /* An abort indicates that the current memory access cannot be completed, which occurs during an instruction prefetch. */
void rt_hw_trap_pabt(struct rt_hw_register *regs) | {
rt_hw_show_register(regs);
rt_kprintf("prefetch abort\n");
rt_kprintf("thread - %s stack:\n", rt_current_thread->name);
rt_hw_backtrace((rt_uint32_t *)regs->fp, (rt_uint32_t)rt_current_thread->entry);
rt_hw_cpu_shutdown();
} | armink/FreeModbus_Slave-Master-RTT-STM32 | C++ | Other | 1,477 |
/* Join a multicast group. the group is specified by a class D multicast address 224.0.0.0/8 in the in_addr structure passed in as a parameter. */ | static int join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname) | /* Join a multicast group. the group is specified by a class D multicast address 224.0.0.0/8 in the in_addr structure passed in as a parameter. */
static int join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname) | {
struct ip_mreqn mreq;
struct net_device *dev;
int ret;
memset(&mreq, 0, sizeof(mreq));
memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr));
if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
return -ENODEV;
if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
return -EINVAL;
mreq.imr_ifindex = dev->ifindex;
lock_sock(sk);
ret = ip_mc_join_group(sk, &mreq);
release_sock(sk);
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Initialize the state information for the CPU Architectural Protocol */ | EFI_STATUS InterruptDxeInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | /* Initialize the state information for the CPU Architectural Protocol */
EFI_STATUS InterruptDxeInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | {
EFI_STATUS Status;
ARM_GIC_ARCH_REVISION Revision;
Revision = ArmGicGetSupportedArchRevision ();
if (Revision == ARM_GIC_ARCH_REVISION_2) {
Status = GicV2DxeInitialize (ImageHandle, SystemTable);
} else if (Revision == ARM_GIC_ARCH_REVISION_3) {
Status = GicV3DxeInitialize (ImageHandle, SystemTable);
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Raises an error if variable described by 'e' is read only */ | static void check_readonly(LexState *ls, expdesc *e) | /* Raises an error if variable described by 'e' is read only */
static void check_readonly(LexState *ls, expdesc *e) | {
case VCONST: {
varname = ls->dyd->actvar.arr[e->u.info].vd.name;
break;
}
case VLOCAL: {
Vardesc *vardesc = getlocalvardesc(fs, e->u.var.vidx);
if (vardesc->vd.kind != VDKREG)
varname = vardesc->vd.name;
break;
}
case VUPVAL: {
Upvaldesc *up = &fs->f->upvalues[e->u.info];
if (up->kind != VDKREG)
varname = up->name;
break;
}
default:
return;
}
if (varname) {
const char *msg = luaO_pushfstring(ls->L,
"attempt to assign to const variable '%s'", getstr(varname));
luaK_semerror(ls, msg);
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* This function handles DMA2 Stream 3 interrupt request. */ | void BSP_SD_DMA_Rx_IRQHandler(void) | /* This function handles DMA2 Stream 3 interrupt request. */
void BSP_SD_DMA_Rx_IRQHandler(void) | {
HAL_DMA_IRQHandler(uSdHandle.hdmarx);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Reset the PTC08 device.
Send reset Command to the PTC08 device. */ | xtBoolean PTC08PhotoReset(void) | /* Reset the PTC08 device.
Send reset Command to the PTC08 device. */
xtBoolean PTC08PhotoReset(void) | {
unsigned long i;
unsigned char ucTmp[4];
UARTBufferPut(PTC08_UART, (unsigned char *)&ucResetCmd[0], 4);
if (!UARTBufferGet(PTC08_UART, ucTmp, 4))
{
return xfalse;
}
for (i = 0; i < 4; i++)
{
if (ucTmp[i] != ucResetRcv[i])
{
return xfalse;
}
}
return xtrue;} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Get the peripheral clock speed for the USART at base specified. */ | uint32_t rcc_get_usart_clk_freq(uint32_t usart) | /* Get the peripheral clock speed for the USART at base specified. */
uint32_t rcc_get_usart_clk_freq(uint32_t usart) | {
if (usart == USART1_BASE) {
return rcc_get_usart_clksel_freq(RCC_CFGR3_USART1SW_SHIFT);
} else if (usart == USART2_BASE) {
return rcc_get_usart_clksel_freq(RCC_CFGR3_USART2SW_SHIFT);
} else if (usart == USART3_BASE) {
return rcc_get_usart_clksel_freq(RCC_CFGR3_USART3SW_SHIFT);
} else {
return rcc_apb1_frequency;
}
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Perform an isolation. The port selection code now tries to avoid "dangerous to read" ports. */ | static int __init isapnp_isolate_rdp_select(void) | /* Perform an isolation. The port selection code now tries to avoid "dangerous to read" ports. */
static int __init isapnp_isolate_rdp_select(void) | {
isapnp_wait();
isapnp_key();
isapnp_write_byte(0x02, isapnp_reset ? 0x05 : 0x04);
mdelay(2);
isapnp_wait();
isapnp_key();
isapnp_wake(0x00);
if (isapnp_next_rdp() < 0) {
isapnp_wait();
return -1;
}
isapnp_set_rdp();
udelay(1000);
write_address(0x01);
udelay(1000);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Return value: Number of elements in the utf16 string or 0 if an invalid unicode character */ | int _cairo_ucs4_to_utf16(uint32_t unicode, uint16_t *utf16) | /* Return value: Number of elements in the utf16 string or 0 if an invalid unicode character */
int _cairo_ucs4_to_utf16(uint32_t unicode, uint16_t *utf16) | {
if (unicode < 0x10000) {
if (utf16)
utf16[0] = unicode;
return 1;
} else if (unicode < 0x110000) {
if (utf16) {
utf16[0] = (unicode - 0x10000) / 0x400 + 0xd800;
utf16[1] = (unicode - 0x10000) % 0x400 + 0xdc00;
}
return 2;
} else {
return 0;
}
} | xboot/xboot | C++ | MIT License | 779 |
/* param base I2S base pointer. param handle pointer to handle structure. */ | void I2S_TxTransferAbort(I2S_Type *base, i2s_handle_t *handle) | /* param base I2S base pointer. param handle pointer to handle structure. */
void I2S_TxTransferAbort(I2S_Type *base, i2s_handle_t *handle) | {
assert(handle != NULL);
I2S_TxEnable(base, false);
handle->state = (uint32_t)kI2S_StateIdle;
(void)memset((void *)&handle->i2sQueue, 0, sizeof(i2s_transfer_t) * I2S_NUM_BUFFERS);
handle->queueDriver = 0U;
handle->queueUser = 0U;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Read/write access functions for various sizes of values in config space. Return all 1's for disallowed accesses for a kludgy but adequate simulation of master aborts. */ | static int sb1250_pcibios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) | /* Read/write access functions for various sizes of values in config space. Return all 1's for disallowed accesses for a kludgy but adequate simulation of master aborts. */
static int sb1250_pcibios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) | {
u32 data = 0;
if ((size == 2) && (where & 1))
return PCIBIOS_BAD_REGISTER_NUMBER;
else if ((size == 4) && (where & 3))
return PCIBIOS_BAD_REGISTER_NUMBER;
if (sb1250_pci_can_access(bus, devfn))
data = READCFG32(CFGADDR(bus, devfn, where));
else
data = 0xFFFFFFFF;
if (size == 1)
*val = (data >> ((where & 3) << 3)) & 0xff;
else if (size == 2)
*val = (data >> ((where & 3) << 3)) & 0xffff;
else
*val = data;
return PCIBIOS_SUCCESSFUL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* timekeeping_valid_for_hres - Check if timekeeping is suitable for hres */ | int timekeeping_valid_for_hres(void) | /* timekeeping_valid_for_hres - Check if timekeeping is suitable for hres */
int timekeeping_valid_for_hres(void) | {
unsigned long seq;
int ret;
do {
seq = read_seqbegin(&xtime_lock);
ret = timekeeper.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES;
} while (read_seqretry(&xtime_lock, seq));
return ret;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ARC architecture configure IP through IO auxiliary registers. Other architectures as ARM and x86 configure IP through MMIO registers */ | static uint32_t dw_read(uint32_t base_addr, uint32_t offset) | /* ARC architecture configure IP through IO auxiliary registers. Other architectures as ARM and x86 configure IP through MMIO registers */
static uint32_t dw_read(uint32_t base_addr, uint32_t offset) | {
return sys_read32(base_addr + offset);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Output a character in polled mode.
Checks if the transmitter is empty. If empty, a character is written to the data register. */ | static void uart_stellaris_poll_out(const struct device *dev, unsigned char c) | /* Output a character in polled mode.
Checks if the transmitter is empty. If empty, a character is written to the data register. */
static void uart_stellaris_poll_out(const struct device *dev, unsigned char c) | {
const struct uart_stellaris_config *config = dev->config;
while (!poll_tx_ready(dev)) {
}
config->uart->dr = (uint32_t)c;
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This is called to check if a tree of mounts has any open files, pwds, chroots or sub mounts that are busy. */ | int may_umount_tree(struct vfsmount *mnt) | /* This is called to check if a tree of mounts has any open files, pwds, chroots or sub mounts that are busy. */
int may_umount_tree(struct vfsmount *mnt) | {
int actual_refs = 0;
int minimum_refs = 0;
struct vfsmount *p;
spin_lock(&vfsmount_lock);
for (p = mnt; p; p = next_mnt(p, mnt)) {
actual_refs += atomic_read(&p->mnt_count);
minimum_refs += 2;
}
spin_unlock(&vfsmount_lock);
if (actual_refs > minimum_refs)
return 0;
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Drops a temporary reference, frees superblock if there's no references left. */ | void put_super(struct super_block *sb) | /* Drops a temporary reference, frees superblock if there's no references left. */
void put_super(struct super_block *sb) | {
spin_lock(&sb_lock);
__put_super(sb);
spin_unlock(&sb_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* For tight control over page level allocator and protection flags use __vmalloc() instead. */ | void* vmalloc(unsigned long size) | /* For tight control over page level allocator and protection flags use __vmalloc() instead. */
void* vmalloc(unsigned long size) | {
return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Write two datas element to the SPI interface. */ | void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData) | /* Write two datas element to the SPI interface. */
void SPIBurstDataWrite(unsigned long ulBase, unsigned long *pulData) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) );
while((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_GO_BUSY))
{
}
xHWREG(ulBase + SPI_TX0) = pulData[0];
xHWREG(ulBase + SPI_TX1) = pulData[1];
xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* There is no need to lock around as the "grandpa" would be refcounted by the target, and to remove the referemes, the uwb_rc_class->sem would have to be taken */ | struct uwb_rc* uwb_rc_get_by_grandpa(const struct device *grandpa_dev) | /* There is no need to lock around as the "grandpa" would be refcounted by the target, and to remove the referemes, the uwb_rc_class->sem would have to be taken */
struct uwb_rc* uwb_rc_get_by_grandpa(const struct device *grandpa_dev) | {
struct device *dev;
struct uwb_rc *rc = NULL;
dev = class_find_device(&uwb_rc_class, NULL, (void *)grandpa_dev,
find_rc_grandpa);
if (dev)
rc = dev_get_drvdata(dev);
return rc;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* ZigBee ZCL Meter Identification cluster dissector for wireshark. */ | static int dissect_zbee_zcl_met_idt(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) | /* ZigBee ZCL Meter Identification cluster dissector for wireshark. */
static int dissect_zbee_zcl_met_idt(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) | {
return tvb_captured_length(tvb);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* XDR encode functions There must be an encoding function for void results so svc_process will work properly. */ | int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy) | /* XDR encode functions There must be an encoding function for void results so svc_process will work properly. */
int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy) | {
return xdr_ressize_check(rqstp, p);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Fills each OPA_InitStruct member with its default value. */ | void OPA_StructInit(OPA_InitTypeDef *OPA_InitStruct) | /* Fills each OPA_InitStruct member with its default value. */
void OPA_StructInit(OPA_InitTypeDef *OPA_InitStruct) | {
OPA_InitStruct->OPA_OP0PSel = 0x00000000;
OPA_InitStruct->OPA_OP0NSel = 0x00002000;
OPA_InitStruct->OPA_OP0FR = 0x00000000;
OPA_InitStruct->OPA_OP0FCAPE = 0x00000000;
OPA_InitStruct->OPA_OPTODIG = 0x00000080;
OPA_InitStruct->OPA_OPTOIO = 0x00000040;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* set the bld color space based on the format if the format is UI, then set the bld in RGB color space if the format is Video, then set the bld in YUV color space */ | __s32 bld_cs_set(struct blender_submodule *p_bld, __u32 format) | /* set the bld color space based on the format if the format is UI, then set the bld in RGB color space if the format is Video, then set the bld in YUV color space */
__s32 bld_cs_set(struct blender_submodule *p_bld, __u32 format) | {
__s32 ret = -1;
struct g2d_mixer_bld_reg *p_reg = NULL;
p_reg = p_bld->get_reg(p_bld);
if (!p_reg)
goto OUT;
if (format <= G2D_FORMAT_BGRA1010102) {
p_reg->out_color.bits.alpha_mode = 0;
} else if (format <= G2D_FORMAT_YUV411_PLANAR) {
p_reg->out_color.bits.alpha_mode = 1;
} else
goto OUT;
p_bld->set_block_dirty(p_bld, 0, 1);
ret = 0;
OUT:
return ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* De-initialize UART Interface. stops operation and releases the software resources used by the interface. */ | int32_t csi_usart_uninitialize(usart_handle_t handle) | /* De-initialize UART Interface. stops operation and releases the software resources used by the interface. */
int32_t csi_usart_uninitialize(usart_handle_t handle) | {
USART_NULL_PARAM_CHK(handle);
dw_usart_priv_t *usart_priv = handle;
drv_nvic_disable_irq(usart_priv->irq);
usart_priv->cb_event = NULL;
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Note: Might want to change this later to allow for passing in a parameter to optionally set the sleep on exit bit. */ | void stop(void) | /* Note: Might want to change this later to allow for passing in a parameter to optionally set the sleep on exit bit. */
void stop(void) | {
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;
asm("WFI");
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* ISR will determine that interrupt arrives either for READ or WRITE command. According to command it will do the appropriate action. It will check transfer length and if it is not zero then dispatch transfer command again. If transfer length is zero then it will indicate the COMPLETION so that davinci_spi_bufs function can go ahead. */ | static void davinci_spi_irq(int irq, void *data) | /* ISR will determine that interrupt arrives either for READ or WRITE command. According to command it will do the appropriate action. It will check transfer length and if it is not zero then dispatch transfer command again. If transfer length is zero then it will indicate the COMPLETION so that davinci_spi_bufs function can go ahead. */
static void davinci_spi_irq(int irq, void *data) | {
struct davinci_spi *dspi = data;
int status;
status = davinci_spi_process_events(dspi);
if (unlikely(status != 0))
clear_io_bits(dspi->base + SPIINT, SPIINT_MASKINT);
if ((!dspi->rcount && !dspi->wcount) || status)
rt_completion_done(&dspi->done);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations. */ | unsigned long xI2CMasterError(unsigned long ulBase) | /* Gets the error status of the I2C Master module. This function is used to obtain the error status of the Master module send and receive operations. */
unsigned long xI2CMasterError(unsigned long ulBase) | {
unsigned long ulStatus;
xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE));
ulStatus = (xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M);
if((ulStatus == I2C_I2STAT_M_TX_DAT_NACK) ||
(ulStatus == I2C_I2STAT_M_RX_DAT_NACK))
{
return xI2C_MASTER_ERR_ADDR_ACK;
}
if((ulStatus == I2C_I2STAT_M_TX_SLAW_NACK) ||
(ulStatus == I2C_I2STAT_M_RX_SLAR_NACK))
{
return xI2C_MASTER_ERR_DATA_ACK;
}
if((ulStatus == I2C_I2STAT_M_TX_ARB_LOST))
{
return xI2C_MASTER_ERR_ARB_LOST;
}
return xI2C_MASTER_ERR_NONE;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Returns: (nullable): a #GWin32RegistryKey or NULL if can't be opened. Free with g_object_unref(). */ | GWin32RegistryKey* g_win32_registry_key_get_child(GWin32RegistryKey *key, const gchar *subkey, GError **error) | /* Returns: (nullable): a #GWin32RegistryKey or NULL if can't be opened. Free with g_object_unref(). */
GWin32RegistryKey* g_win32_registry_key_get_child(GWin32RegistryKey *key, const gchar *subkey, GError **error) | {
gunichar2 *subkey_w;
GWin32RegistryKey *result = NULL;
g_return_val_if_fail (G_IS_WIN32_REGISTRY_KEY (key), NULL);
g_return_val_if_fail (subkey != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
subkey_w = g_utf8_to_utf16 (subkey, -1, NULL, NULL, error);
if (subkey_w != NULL)
{
result = g_win32_registry_key_get_child_w (key, subkey_w, error);
g_free (subkey_w);
}
return result;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Remove bdi from bdi_list, and ensure that it is no longer visible */ | static void bdi_remove_from_list(struct backing_dev_info *bdi) | /* Remove bdi from bdi_list, and ensure that it is no longer visible */
static void bdi_remove_from_list(struct backing_dev_info *bdi) | {
spin_lock_bh(&bdi_lock);
list_del_rcu(&bdi->bdi_list);
spin_unlock_bh(&bdi_lock);
synchronize_rcu();
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set function for the contrast level of the LCD. */ | void halLcdSetContrast(unsigned char ContrastLevel) | /* Set function for the contrast level of the LCD. */
void halLcdSetContrast(unsigned char ContrastLevel) | {
if (ContrastLevel > 127) ContrastLevel = 127;
if (ContrastLevel < 70) ContrastLevel = 70;
LcdInitMacro[ 0x04 * 6 + 5 ] = ContrastLevel;
halLcdSendCommand(&LcdInitMacro[ 0x04 * 6 ]);
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Load PWM Register and LED Control Registers data. */ | esp_err_t is31fl3216_update_reg(is31fl3216_handle_t handle) | /* Load PWM Register and LED Control Registers data. */
esp_err_t is31fl3216_update_reg(is31fl3216_handle_t handle) | {
IS31_PARAM_CHECK(NULL != handle);
uint8_t m = 0;
return is31fl3216_write_reg(handle, IS31FL3216_REG_UPDATE, &m, 1);
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* register_asymmetric_key_parser - Register a asymmetric key blob parser @parser: The parser to register */ | int register_asymmetric_key_parser(struct asymmetric_key_parser *parser) | /* register_asymmetric_key_parser - Register a asymmetric key blob parser @parser: The parser to register */
int register_asymmetric_key_parser(struct asymmetric_key_parser *parser) | {
struct asymmetric_key_parser *cursor;
int ret;
down_write(&asymmetric_key_parsers_sem);
list_for_each_entry(cursor, &asymmetric_key_parsers, link) {
if (strcmp(cursor->name, parser->name) == 0) {
pr_err("Asymmetric key parser '%s' already registered\n",
parser->name);
ret = -EEXIST;
goto out;
}
}
list_add_tail(&parser->link, &asymmetric_key_parsers);
pr_notice("Asymmetric key parser '%s' registered\n", parser->name);
ret = 0;
out:
up_write(&asymmetric_key_parsers_sem);
return ret;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Fills each USART_ClockInitStruct member with its default value. */ | void USART_ClockStructInit(USART_ClockInitTypeDef *USART_ClockInitStruct) | /* Fills each USART_ClockInitStruct member with its default value. */
void USART_ClockStructInit(USART_ClockInitTypeDef *USART_ClockInitStruct) | {
USART_ClockInitStruct->USART_Clock = USART_Clock_Disable;
USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low;
USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge;
USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Set the fields of structure stc_sdioc_data_config_t to default values. */ | int32_t SDIOC_DataStructInit(stc_sdioc_data_config_t *pstcDataConfig) | /* Set the fields of structure stc_sdioc_data_config_t to default values. */
int32_t SDIOC_DataStructInit(stc_sdioc_data_config_t *pstcDataConfig) | {
int32_t i32Ret = LL_OK;
if (NULL == pstcDataConfig) {
i32Ret = LL_ERR_INVD_PARAM;
} else {
pstcDataConfig->u16BlockSize = 512U;
pstcDataConfig->u16BlockCount = 0U;
pstcDataConfig->u16TransDir = SDIOC_TRANS_DIR_TO_CARD;
pstcDataConfig->u16AutoCmd12 = SDIOC_AUTO_SEND_CMD12_DISABLE;
pstcDataConfig->u16TransMode = SDIOC_TRANS_MD_SINGLE;
pstcDataConfig->u16DataTimeout = SDIOC_DATA_TIMEOUT_CLK_2E13;
}
return i32Ret;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Init interrupts callback for the specified UART Port. */ | void xUARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback) | /* Init interrupts callback for the specified UART Port. */
void xUARTIntCallbackInit(unsigned long ulBase, xtEventCallback xtUARTCallback) | {
UARTIntCallbackInit(ulBase, xtUARTCallback);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* The caller must have a ref on the inode. */ | int sync_inode(struct inode *inode, struct writeback_control *wbc) | /* The caller must have a ref on the inode. */
int sync_inode(struct inode *inode, struct writeback_control *wbc) | {
int ret;
spin_lock(&inode_lock);
ret = writeback_single_inode(inode, wbc);
spin_unlock(&inode_lock);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Writes data to the specified GPIO data port. */ | void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF) | /* Writes data to the specified GPIO data port. */
void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF) | {
uint32_t temp = 0x00;
uint32_t temp_2 = 0x00;
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
assert_param(IS_GPIO_AF(GPIO_AF));
temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Clears the status bits in this endpoint in host mode. */ | void USBHostEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags) | /* Clears the status bits in this endpoint in host mode. */
void USBHostEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint, uint32_t ui32Flags) | {
ASSERT(ui32Base == USB0_BASE);
ASSERT((ui32Endpoint == USB_EP_0) || (ui32Endpoint == USB_EP_1) ||
(ui32Endpoint == USB_EP_2) || (ui32Endpoint == USB_EP_3) ||
(ui32Endpoint == USB_EP_4) || (ui32Endpoint == USB_EP_5) ||
(ui32Endpoint == USB_EP_6) || (ui32Endpoint == USB_EP_7));
if(ui32Endpoint == USB_EP_0)
{
HWREGB(ui32Base + USB_O_CSRL0) &= ~ui32Flags;
}
else
{
HWREGB(ui32Base + USB_O_TXCSRL1 + EP_OFFSET(ui32Endpoint)) &=
~ui32Flags;
HWREGB(ui32Base + USB_O_RXCSRL1 + EP_OFFSET(ui32Endpoint)) &=
~(ui32Flags >> USB_RX_EPSTATUS_SHIFT);
}
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* This function sets up the SYNC setting of a frame sync used by the VTC core. */ | void XVtc_SetFSync(XVtc *InstancePtr, u16 FrameSyncIndex, u16 VertStart, u16 HoriStart) | /* This function sets up the SYNC setting of a frame sync used by the VTC core. */
void XVtc_SetFSync(XVtc *InstancePtr, u16 FrameSyncIndex, u16 VertStart, u16 HoriStart) | {
u32 RegValue;
u32 RegAddress;
Xil_AssertVoid(InstancePtr != NULL);
Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
Xil_AssertVoid(FrameSyncIndex <= 15);
Xil_AssertVoid(VertStart <= 4095);
Xil_AssertVoid(HoriStart <= 4095);
RegValue = HoriStart & XVTC_FSXX_HSTART_MASK;
RegValue |= (VertStart << XVTC_FSXX_VSTART_SHIFT) &
XVTC_FSXX_VSTART_MASK;
RegAddress = XVTC_FS00_OFFSET + FrameSyncIndex * XVTC_REG_ADDRGAP;
XVtc_WriteReg(InstancePtr->Config.BaseAddress, RegAddress, RegValue);
} | ua1arn/hftrx | C++ | null | 69 |
/* #define DESELECT() do { \ if(old_spi_delay != card_spi_delay) \ spi_set_delay(old_spi_delay); \ spi_cs_off(SPI_CS_SDC); \ } while(0) */ | static uint8 wait_ready(void) | /* #define DESELECT() do { \ if(old_spi_delay != card_spi_delay) \ spi_set_delay(old_spi_delay); \ spi_cs_off(SPI_CS_SDC); \ } while(0) */
static uint8 wait_ready(void) | {
res = spi_sr_byte(0xFF);
i++;
} while ((res != 0xFF) && i < MAX_RETRIES);
return res;
} | DC-SWAT/DreamShell | C++ | null | 404 |
/* Write current date/time or alarm date/time to RTC Module. This function is to configure current date/time or alarm date/time. */ | void xRTCTimeWrite(xtTime *pxtTime, unsigned long ulTimeAlarm) | /* Write current date/time or alarm date/time to RTC Module. This function is to configure current date/time or alarm date/time. */
void xRTCTimeWrite(xtTime *pxtTime, unsigned long ulTimeAlarm) | {
xASSERT(pxtTime != 0);
xASSERT((ulTimeAlarm == xRTC_TIME_CURRENT) || (ulTimeAlarm == xRTC_TIME_ALARM));
switch(ulTimeAlarm)
{
case xRTC_TIME_CURRENT:
{
break;
}
case xRTC_TIME_ALARM:
{
break;
}
default:
{
while(1);
}
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function immediately shuts down a DMA channel's hardware, aborting any I/O that may be in progress, potentially leaving I/O hardware in an undefined state. It is unwise to call this function if there is ANY chance the hardware is still processing a command. */ | static int mxs_dma_disable(int channel) | /* This function immediately shuts down a DMA channel's hardware, aborting any I/O that may be in progress, potentially leaving I/O hardware in an undefined state. It is unwise to call this function if there is ANY chance the hardware is still processing a command. */
static int mxs_dma_disable(int channel) | {
struct mxs_dma_chan *pchan;
struct mxs_apbh_regs *apbh_regs =
(struct mxs_apbh_regs *)MXS_APBH_BASE;
int ret;
ret = mxs_dma_validate_chan(channel);
if (ret)
return ret;
pchan = mxs_dma_channels + channel;
if (!(pchan->flags & MXS_DMA_FLAGS_BUSY))
return -EINVAL;
writel(1 << (channel + APBH_CTRL0_CLKGATE_CHANNEL_OFFSET),
&apbh_regs->hw_apbh_ctrl0_set);
pchan->flags &= ~MXS_DMA_FLAGS_BUSY;
pchan->active_num = 0;
pchan->pending_num = 0;
list_splice_init(&pchan->active, &pchan->done);
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This enforces a rate limit: not more than @rs->ratelimit_burst callbacks in every @rs->ratelimit_jiffies */ | int ___ratelimit(struct ratelimit_state *rs, const char *func) | /* This enforces a rate limit: not more than @rs->ratelimit_burst callbacks in every @rs->ratelimit_jiffies */
int ___ratelimit(struct ratelimit_state *rs, const char *func) | {
unsigned long flags;
int ret;
if (!rs->interval)
return 1;
if (!spin_trylock_irqsave(&rs->lock, flags))
return 1;
if (!rs->begin)
rs->begin = jiffies;
if (time_is_before_jiffies(rs->begin + rs->interval)) {
if (rs->missed)
printk(KERN_WARNING "%s: %d callbacks suppressed\n",
func, rs->missed);
rs->begin = 0;
rs->printed = 0;
rs->missed = 0;
}
if (rs->burst && rs->burst > rs->printed) {
rs->printed++;
ret = 1;
} else {
rs->missed++;
ret = 0;
}
spin_unlock_irqrestore(&rs->lock, flags);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Find the waveform temperature range index for a given temperature in °C. If no range in the waveform data fits the given temperature, return the closest one. Returns -1 if the waveform does not contain any temperature range. */ | int waveform_temp_range_index(const EpdWaveform *waveform, int temperature) | /* Find the waveform temperature range index for a given temperature in °C. If no range in the waveform data fits the given temperature, return the closest one. Returns -1 if the waveform does not contain any temperature range. */
int waveform_temp_range_index(const EpdWaveform *waveform, int temperature) | {
return -1;
}
while (idx < waveform->num_temp_ranges - 1
&& waveform->temp_intervals[idx].min < temperature) {
idx++;
}
return idx;
} | arendst/Tasmota | C++ | GNU General Public License v3.0 | 21,318 |
/* Sets the tim Capture Compare 5 Register value. */ | void TIM_SetCompare5(TIM_TypeDef *tim, u32 compare) | /* Sets the tim Capture Compare 5 Register value. */
void TIM_SetCompare5(TIM_TypeDef *tim, u32 compare) | {
WRITE_REG(tim->CCR5, (u16)compare);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* With relative atime, only update atime if the previous atime is earlier than either the ctime or mtime or if at least a day has passed since the last atime update. */ | static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, struct timespec now) | /* With relative atime, only update atime if the previous atime is earlier than either the ctime or mtime or if at least a day has passed since the last atime update. */
static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, struct timespec now) | {
if (!(mnt->mnt_flags & MNT_RELATIME))
return 1;
if (timespec_compare(&inode->i_mtime, &inode->i_atime) >= 0)
return 1;
if (timespec_compare(&inode->i_ctime, &inode->i_atime) >= 0)
return 1;
if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
return 1;
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns: TRUE if the mount point is user mountable. */ | gboolean g_unix_mount_point_is_user_mountable(GUnixMountPoint *mount_point) | /* Returns: TRUE if the mount point is user mountable. */
gboolean g_unix_mount_point_is_user_mountable(GUnixMountPoint *mount_point) | {
g_return_val_if_fail (mount_point != NULL, FALSE);
return mount_point->is_user_mountable;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* disable the SD I/O mode specific operation(SD I/O only) */ | void sdio_operation_disable(void) | /* disable the SD I/O mode specific operation(SD I/O only) */
void sdio_operation_disable(void) | {
SDIO_DATACTL &= ~SDIO_DATACTL_IOEN;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get the 1BIT ECC error bit of the specified section. */ | uint32_t EXMC_NFC_Get1BitEccErrBitLocation(uint32_t u32Section) | /* Get the 1BIT ECC error bit of the specified section. */
uint32_t EXMC_NFC_Get1BitEccErrBitLocation(uint32_t u32Section) | {
MODIFY_REG32(CM_NFC->BACR, NFC_BACR_SCS, ((((uint32_t)u8SpareSizeForUserData) << NFC_BACR_SCS_POS) & NFC_BACR_SCS));
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* In TDX a serial of TdIoWrite8 is invoked to write data to the I/O port. */ | VOID EFIAPI IoWriteFifo8(IN UINTN Port, IN UINTN Count, IN VOID *Buffer) | /* In TDX a serial of TdIoWrite8 is invoked to write data to the I/O port. */
VOID EFIAPI IoWriteFifo8(IN UINTN Port, IN UINTN Count, IN VOID *Buffer) | {
UINT8 *Buffer8;
Buffer8 = (UINT8 *)Buffer;
while (Count-- > 0) {
IoWrite8 (Port, *Buffer8++);
}
} | tianocore/edk2 | C++ | Other | 4,240 |
/* We need to calculate how long before the voltage starts to drop or increase It returns with the loop count. Each loop takes several readings (532us) */ | static int wait_for_voltage_change(int vdd_last) | /* We need to calculate how long before the voltage starts to drop or increase It returns with the loop count. Each loop takes several readings (532us) */
static int wait_for_voltage_change(int vdd_last) | {
int timeout, vdd_current;
vdd_current = read_voltage();
for (timeout = 0; abs(vdd_last - vdd_current) <= 4 &&
timeout < 100; timeout++) {
vdd_current = read_voltage();
}
if (timeout >= 100) {
printf("VID: Voltage adjustment timeout\n");
return -1;
}
return timeout;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Erases the flash memory. Note that this function also checks that no data is erased outside the flash memory region, so the bootloader can never be erased. */ | blt_bool FlashErase(blt_addr addr, blt_int32u len) | /* Erases the flash memory. Note that this function also checks that no data is erased outside the flash memory region, so the bootloader can never be erased. */
blt_bool FlashErase(blt_addr addr, blt_int32u len) | {
blt_bool result = BLT_TRUE;
blt_int8u first_sector = FLASH_INVALID_SECTOR;
blt_int8u last_sector = FLASH_INVALID_SECTOR;
if ((len - 1) > (FLASH_END_ADDRESS - addr))
{
result = BLT_FALSE;
}
if (result == BLT_TRUE)
{
first_sector = FlashGetSector(addr);
last_sector = FlashGetSector(addr+len-1);
if ((first_sector == FLASH_INVALID_SECTOR) ||
(last_sector == FLASH_INVALID_SECTOR))
{
result = BLT_FALSE;
}
}
if (result == BLT_TRUE)
{
result = FlashEraseSectors(first_sector, last_sector);
}
return result;
} | feaser/openblt | C++ | GNU General Public License v3.0 | 601 |
/* The ASL is stopped and empty except for the dummy qset. */ | void asl_clean_up(struct whc *whc) | /* The ASL is stopped and empty except for the dummy qset. */
void asl_clean_up(struct whc *whc) | {
struct whc_qset *qset;
if (!list_empty(&whc->async_list)) {
qset = list_first_entry(&whc->async_list, struct whc_qset, list_node);
list_del(&qset->list_node);
qset_free(whc, qset);
}
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Sets the source or destination address for an integrated USB DMA transfer on a specified channel. */ | void USBDMAChannelAddressSet(uint32_t ui32Base, uint32_t ui32Channel, void *pvAddress) | /* Sets the source or destination address for an integrated USB DMA transfer on a specified channel. */
void USBDMAChannelAddressSet(uint32_t ui32Base, uint32_t ui32Channel, void *pvAddress) | {
ASSERT(ui32Base == USB0_BASE);
ASSERT(ui32Channel < 8);
HWREG(ui32Base + USB_O_DMAADDR0 + (0x10 * ui32Channel)) =
(uint32_t)pvAddress;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Enables or disables AES encrypt/decrypt function of DMA channel3. */ | void DMA_AESCmd(uint32_t NewState) | /* Enables or disables AES encrypt/decrypt function of DMA channel3. */
void DMA_AESCmd(uint32_t NewState) | {
assert_parameters(IS_FUNCTIONAL_STATE(NewState));
if (NewState == ENABLE)
DMA->C3CTL |= DMA_CCTL_AESEN;
else
DMA->C3CTL &= ~DMA_CCTL_AESEN;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Check whether the specified I2S interrupt flag is set or not. */ | flag_status_t ald_i2s_get_mask_flag_status(ald_i2s_handle_t *hperh, ald_i2s_flag_t flag) | /* Check whether the specified I2S interrupt flag is set or not. */
flag_status_t ald_i2s_get_mask_flag_status(ald_i2s_handle_t *hperh, ald_i2s_flag_t flag) | {
assert_param(IS_I2S(hperh->perh));
assert_param(IS_I2S_IF(flag));
if (hperh->perh->IFM & flag)
return SET;
return RESET;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* If this fails to write a tree block, it returns -1, but continues fixing up the blocks in ram so the tree is consistent. */ | static int fixup_low_keys(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, int level) | /* If this fails to write a tree block, it returns -1, but continues fixing up the blocks in ram so the tree is consistent. */
static int fixup_low_keys(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, struct btrfs_disk_key *key, int level) | {
int i;
int ret = 0;
struct extent_buffer *t;
for (i = level; i < BTRFS_MAX_LEVEL; i++) {
int tslot = path->slots[i];
if (!path->nodes[i])
break;
t = path->nodes[i];
btrfs_set_node_key(t, key, tslot);
btrfs_mark_buffer_dirty(path->nodes[i]);
if (tslot != 0)
break;
}
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Perform lazy FPU context switching by simply granting or denying access to FP regs based on FPU ownership before leaving the last exception level in case of exceptions, or during a thread context switch with the exception level of the new thread being 0. If current thread doesn't own the FP regs then it will trap on its first access and then the actual FPU context switching will occur. */ | static void fpu_access_update(unsigned int exc_update_level) | /* Perform lazy FPU context switching by simply granting or denying access to FP regs based on FPU ownership before leaving the last exception level in case of exceptions, or during a thread context switch with the exception level of the new thread being 0. If current thread doesn't own the FP regs then it will trap on its first access and then the actual FPU context switching will occur. */
static void fpu_access_update(unsigned int exc_update_level) | {
__ASSERT(read_daif() & DAIF_IRQ_BIT, "must be called with IRQs disabled");
uint64_t cpacr = read_cpacr_el1();
if (arch_exception_depth() == exc_update_level) {
if (atomic_ptr_get(&_current_cpu->arch.fpu_owner) == _current) {
write_cpacr_el1(cpacr | CPACR_EL1_FPEN_NOTRAP);
} else {
write_cpacr_el1(cpacr & ~CPACR_EL1_FPEN_NOTRAP);
}
} else {
write_cpacr_el1(cpacr & ~CPACR_EL1_FPEN_NOTRAP);
}
barrier_isync_fence_full();
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function builds a HOB for the stack. It can only be invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. If there is no additional space for HOB creation, then ASSERT(). */ | VOID EFIAPI BuildStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length) | /* This function builds a HOB for the stack. It can only be invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase. If there is no additional space for HOB creation, then ASSERT(). */
VOID EFIAPI BuildStackHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length) | {
EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
ASSERT (
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
ASSERT (Hob != NULL);
if (Hob == NULL) {
return;
}
CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
Hob->AllocDescriptor.MemoryLength = Length;
Hob->AllocDescriptor.MemoryType = EfiBootServicesData;
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Waits for a Flash operation to complete or a TIMEOUT to occur. */ | FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) | /* Waits for a Flash operation to complete or a TIMEOUT to occur. */
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) | {
FLASH_Status status = FLASH_COMPLETE;
status = FLASH_GetBank1Status();
while((status == FLASH_BUSY) && (Timeout != 0x00))
{
status = FLASH_GetBank1Status();
Timeout--;
}
if(Timeout == 0x00)
{
status = FLASH_TIMEOUT;
}
return status;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* ADC Enable Analog Watchdog for a Selected Channel.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned. */ | void adc_enable_analog_watchdog_on_selected_channel(uint32_t adc, uint8_t channel) | /* ADC Enable Analog Watchdog for a Selected Channel.
The analog watchdog allows the monitoring of an analog signal between two threshold levels. The thresholds must be preset. Comparison is done before data alignment takes place, so the thresholds are left-aligned. */
void adc_enable_analog_watchdog_on_selected_channel(uint32_t adc, uint8_t channel) | {
ADC_CFGR1(adc) = (ADC_CFGR1(adc) & ~ADC_CFGR1_AWD1CH) |
ADC_CFGR1_AWD1CH_VAL(channel);
ADC_CFGR1(adc) |= ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* Read ADT7301 temperature value and handle data in decimal. */ | short ADT7301TemperReadDec(void) | /* Read ADT7301 temperature value and handle data in decimal. */
short ADT7301TemperReadDec(void) | {
short sTempValue;
sTempValue = ADT7301TemperRead();
if ((0x2000 & sTempValue) == 0x2000)
{
sTempValue = (sTempValue - 16384)/32;
}
else
{
sTempValue = sTempValue/32;
}
return sTempValue;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Return values: 0: Failed 1: Succeeded or doesn't apply (not SUBMDL_ES1887) */ | int ess_dsp_init(sb_devc *devc, struct address_info *hw_config) | /* Return values: 0: Failed 1: Succeeded or doesn't apply (not SUBMDL_ES1887) */
int ess_dsp_init(sb_devc *devc, struct address_info *hw_config) | {
if (devc->model != MDL_ESS) {
printk (KERN_INFO "ess_dsp_init for non ESS chip\n");
return 1;
}
if (devc->submodel == SUBMDL_ES1887) {
if (hw_config->dma2 != -1) {
devc->dma16 = hw_config->dma2;
}
if (devc->dma8 != devc->dma16 && devc->dma16 != -1) {
devc->duplex = 1;
}
}
if (!ess_set_dma_hw (devc)) {
free_irq(devc->irq, devc);
return 0;
}
return 1;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Open 485 mode on the specified UART.
The */ | void UART485Config(unsigned long ulBase, unsigned long ulBaud, unsigned long ul485Config, unsigned long ulUARTConfig) | /* Open 485 mode on the specified UART.
The */
void UART485Config(unsigned long ulBase, unsigned long ulBaud, unsigned long ul485Config, unsigned long ulUARTConfig) | {
xASSERT(UARTBaseValid(ulBase));
xUARTConfigSet(ulBase, ulBaud, ulUARTConfig);
UARTEnable485(ulBase);
if(ul485Config & UART_ALT_CSR_RS485_NMM)
{
xHWREG(ulBase + UART_FCR) |= UART_FCR_RX_DIS;
}
xHWREG(ulBase + UART_ALT_CSR) &= 0xFFFFFFFF;
xHWREG(ulBase + UART_ALT_CSR) |= ul485Config;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Get the horizontal offset from the full / physical display */ | lv_coord_t lv_disp_get_offset_x(lv_disp_t *disp) | /* Get the horizontal offset from the full / physical display */
lv_coord_t lv_disp_get_offset_x(lv_disp_t *disp) | {
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) {
return 0;
}
else {
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
return disp->driver->offset_y;
case LV_DISP_ROT_180:
return lv_disp_get_physical_hor_res(disp) - disp->driver->offset_x;
case LV_DISP_ROT_270:
return lv_disp_get_physical_hor_res(disp) - disp->driver->offset_y;
default:
return disp->driver->offset_x;
}
}
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Called from generic code to get the misc flags (i.e. processor mode) for an event_id. */ | unsigned long perf_misc_flags(struct pt_regs *regs) | /* Called from generic code to get the misc flags (i.e. processor mode) for an event_id. */
unsigned long perf_misc_flags(struct pt_regs *regs) | {
u32 flags = perf_get_misc_flags(regs);
if (flags)
return flags;
return user_mode(regs) ? PERF_RECORD_MISC_USER :
PERF_RECORD_MISC_KERNEL;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* RETURN VALUE length of string found, including \0 (if present) */ | static gint my_tvb_strsize(tvbuff_t *tvb, int offset) | /* RETURN VALUE length of string found, including \0 (if present) */
static gint my_tvb_strsize(tvbuff_t *tvb, int offset) | {
gint len = tvb_strnlen(tvb, offset, -1);
if (len == -1) {
len = tvb_reported_length_remaining(tvb, offset);
} else {
len++;
}
return len;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Sets or resets the analogue monitoring on VDDA Power source. */ | FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG) | /* Sets or resets the analogue monitoring on VDDA Power source. */
FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG) | {
FLASH_Status status = FLASH_COMPLETE;
assert_param(IS_OB_VDDA_ANALOG(OB_VDDA_ANALOG));
status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);
if(status == FLASH_COMPLETE)
{
FLASH->CR |= FLASH_CR_OPTPG;
OB->USER = OB_VDDA_ANALOG | 0xDF;
status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);
if(status != FLASH_TIMEOUT)
{
FLASH->CR &= ~FLASH_CR_OPTPG;
}
}
return status;
} | avem-labs/Avem | C++ | MIT License | 1,752 |
/* Check whether the specified SPI interrupt has occurred or not. */ | uint8_t SPI_ReadIntFlag(SPI_T *spi, SPI_INT_T flag) | /* Check whether the specified SPI interrupt has occurred or not. */
uint8_t SPI_ReadIntFlag(SPI_T *spi, SPI_INT_T flag) | {
uint32_t intEnable;
uint32_t intStatus;
intEnable = (uint32_t)(spi->CTRL2 & (flag >> 8));
intStatus = (uint32_t)(spi->STS & flag);
if (intEnable && intStatus)
{
return SET;
}
return RESET;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Call a callback on each element of the cache. */ | void nl_cache_foreach(struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg) | /* Call a callback on each element of the cache. */
void nl_cache_foreach(struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg) | {
nl_cache_foreach_filter(cache, NULL, cb, arg);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Returns: the contents of the @attribute value as a byte string, or NULL otherwise. */ | const char* g_file_info_get_attribute_byte_string(GFileInfo *info, const char *attribute) | /* Returns: the contents of the @attribute value as a byte string, or NULL otherwise. */
const char* g_file_info_get_attribute_byte_string(GFileInfo *info, const char *attribute) | {
GFileAttributeValue *value;
g_return_val_if_fail (G_IS_FILE_INFO (info), NULL);
g_return_val_if_fail (attribute != NULL && *attribute != '\0', NULL);
value = g_file_info_find_value_by_name (info, attribute);
return _g_file_attribute_value_get_byte_string (value);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base SMC peripheral base address. return SMC configuration error code. */ | status_t SMC_SetPowerModeWait(SMC_Type *base) | /* param base SMC peripheral base address. return SMC configuration error code. */
status_t SMC_SetPowerModeWait(SMC_Type *base) | {
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
__DSB();
__WFI();
__ISB();
return kStatus_Success;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Write one element into the buffer.
This function will write one element into the array index specified by the write pointer and increment the write index. */ | bool tu_fifo_write(tu_fifo_t *f, const void *data) | /* Write one element into the buffer.
This function will write one element into the array index specified by the write pointer and increment the write index. */
bool tu_fifo_write(tu_fifo_t *f, const void *data) | {
_ff_lock(f->mutex_wr);
bool ret;
uint16_t const wr_idx = f->wr_idx;
if ( tu_fifo_full(f) && !f->overwritable )
{
ret = false;
}else
{
uint16_t wr_ptr = idx2ptr(f->depth, wr_idx);
_ff_push(f, data, wr_ptr);
f->wr_idx = advance_index(f->depth, wr_idx, 1);
ret = true;
}
_ff_unlock(f->mutex_wr);
return ret;
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Enable/Start the RTC oscillator.
Starts the RTC oscillator. */ | void am_hal_rtc_osc_enable(void) | /* Enable/Start the RTC oscillator.
Starts the RTC oscillator. */
void am_hal_rtc_osc_enable(void) | {
AM_REG(RTC, RTCCTL) &= ~AM_REG_RTC_RTCCTL_RSTOP(1);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* __audit_mq_open - record audit data for a POSIX MQ open @oflag: open flag @mode: mode bits @attr: queue attributes */ | void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr) | /* __audit_mq_open - record audit data for a POSIX MQ open @oflag: open flag @mode: mode bits @attr: queue attributes */
void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr) | {
struct audit_context *context = current->audit_context;
if (attr)
memcpy(&context->mq_open.attr, attr, sizeof(struct mq_attr));
else
memset(&context->mq_open.attr, 0, sizeof(struct mq_attr));
context->mq_open.oflag = oflag;
context->mq_open.mode = mode;
context->type = AUDIT_MQ_OPEN;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Get the LPS22HH temperature data ready bit value. */ | int32_t LPS22HH_TEMP_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status) | /* Get the LPS22HH temperature data ready bit value. */
int32_t LPS22HH_TEMP_Get_DRDY_Status(LPS22HH_Object_t *pObj, uint8_t *Status) | {
if (lps22hh_temp_flag_data_ready_get(&(pObj->Ctx), Status) != LPS22HH_OK)
{
return LPS22HH_ERROR;
}
return LPS22HH_OK;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Returns a static string describing the device in question */ | static const char* aac_info(struct Scsi_Host *shost) | /* Returns a static string describing the device in question */
static const char* aac_info(struct Scsi_Host *shost) | {
struct aac_dev *dev = (struct aac_dev *)shost->hostdata;
return aac_drivers[dev->cardtype].name;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Converts the supplied touch screen location (screenPtr) to a pixel location on the display (displayPtr) using the supplied matrix. The screen orientation is also taken into account when converting the touch screen co-ordinate to a pixel location on the LCD. */ | int getDisplayPoint(tsPoint_t *displayPtr, tsPoint_t *screenPtr, tsMatrix_t *matrixPtr) | /* Converts the supplied touch screen location (screenPtr) to a pixel location on the display (displayPtr) using the supplied matrix. The screen orientation is also taken into account when converting the touch screen co-ordinate to a pixel location on the LCD. */
int getDisplayPoint(tsPoint_t *displayPtr, tsPoint_t *screenPtr, tsMatrix_t *matrixPtr) | {
int retValue = TS_ERROR_NONE ;
if( matrixPtr->Divider != 0 )
{
displayPtr->x = ( (matrixPtr->An * screenPtr->x) +
(matrixPtr->Bn * screenPtr->y) +
matrixPtr->Cn
) / matrixPtr->Divider ;
displayPtr->y = ( (matrixPtr->Dn * screenPtr->x) +
(matrixPtr->En * screenPtr->y) +
matrixPtr->Fn
) / matrixPtr->Divider ;
}
else
{
return -1;
}
lcdOrientation_t orientation;
orientation = lcdGetOrientation();
if (orientation == LCD_ORIENTATION_LANDSCAPE)
{
uint32_t oldx, oldy;
oldx = displayPtr->x;
oldy = displayPtr->y;
displayPtr->x = oldy;
displayPtr->y = lcdGetHeight() - oldx;
}
return( retValue ) ;
} | microbuilder/LPC1343CodeBase | C++ | Other | 73 |
/* Update the instruction parsing context for displacement bytes. */ | STATIC VOID UpdateForDisplacement(IN OUT CC_INSTRUCTION_DATA *InstructionData, IN UINTN Size) | /* Update the instruction parsing context for displacement bytes. */
STATIC VOID UpdateForDisplacement(IN OUT CC_INSTRUCTION_DATA *InstructionData, IN UINTN Size) | {
InstructionData->DisplacementSize = Size;
InstructionData->Immediate += Size;
InstructionData->End += Size;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Function for enabling event on pin (if not yet enabled) or disabling the event if no other user requires it. */ | static void pin_event_enable(uint32_t pin, bool enable) | /* Function for enabling event on pin (if not yet enabled) or disabling the event if no other user requires it. */
static void pin_event_enable(uint32_t pin, bool enable) | {
uint32_t i;
uint32_t pin_mask = 1UL << pin;
bool enabled = false;
for (i = 0; i < m_user_count; i++)
{
if (mp_users[i].enabled && (mp_users[i].pins_mask & pin_mask))
{
enabled = true;
break;
}
}
if (!enabled)
{
if (enable)
{
m_last_pins_state = nrf_gpio_pins_read();
nrf_drv_gpiote_in_event_enable(pin, true);
}
else
{
nrf_drv_gpiote_in_event_disable(pin);
}
}
} | labapart/polymcu | C++ | null | 201 |
/* Post a RECV work request in anticipation of some future receipt of data on the control channel. */ | static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx) | /* Post a RECV work request in anticipation of some future receipt of data on the control channel. */
static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx) | {
struct ibv_recv_wr *bad_wr;
struct ibv_sge sge = {
.addr = (uint64_t)(rdma->wr_data[idx].control),
.length = RDMA_CONTROL_MAX_BUFFER,
.lkey = rdma->wr_data[idx].control_mr->lkey,
};
struct ibv_recv_wr recv_wr = {
.wr_id = RDMA_WRID_RECV_CONTROL + idx,
.sg_list = &sge,
.num_sge = 1,
};
if (ibv_post_recv(rdma->qp, &recv_wr, &bad_wr)) {
return -1;
}
return 0;
} | ve3wwg/teensy3_qemu | C | Other | 15 |
/* pdcspath_attr_show - Generic read function call wrapper. @kobj: The kobject to get info from. @attr: The attribute looked upon. @buf: The output buffer. */ | static ssize_t pdcspath_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) | /* pdcspath_attr_show - Generic read function call wrapper. @kobj: The kobject to get info from. @attr: The attribute looked upon. @buf: The output buffer. */
static ssize_t pdcspath_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) | {
struct pdcspath_entry *entry = to_pdcspath_entry(kobj);
struct pdcspath_attribute *pdcs_attr = to_pdcspath_attribute(attr);
ssize_t ret = 0;
if (pdcs_attr->show)
ret = pdcs_attr->show(entry, buf);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function validates the chip ID of device */ | static int drv_baro_bosch_bmp380_validate_id(i2c_dev_t *drv, uint8_t id_value) | /* This function validates the chip ID of device */
static int drv_baro_bosch_bmp380_validate_id(i2c_dev_t *drv, uint8_t id_value) | {
int ret = 0;
uint8_t value = 0;
if (drv == NULL) {
return -1;
}
ret = sensor_i2c_read(drv, BMP380_CHIP_ID_ADDR, &value, I2C_DATA_LEN, I2C_OP_RETRIES);
if (unlikely(ret) != 0) {
return ret;
}
if (id_value != value) {
return -1;
}
return 0;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Scale a signed value in range -0x8000..0x7fff for the given field */ | static int pidff_rescale_signed(int i, struct hid_field *field) | /* Scale a signed value in range -0x8000..0x7fff for the given field */
static int pidff_rescale_signed(int i, struct hid_field *field) | {
return i == 0 ? 0 : i >
0 ? i * field->logical_maximum / 0x7fff : i *
field->logical_minimum / -0x8000;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Note: mulhdu(a, b) (multiply high double unsigned) returns the high 64 bits of a * b, i.e. (a * b) >> 64, where a and b are 64-bit unsigned numbers. */ | unsigned long long sched_clock(void) | /* Note: mulhdu(a, b) (multiply high double unsigned) returns the high 64 bits of a * b, i.e. (a * b) >> 64, where a and b are 64-bit unsigned numbers. */
unsigned long long sched_clock(void) | {
if (__USE_RTC())
return get_rtc();
return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Clears the specified interrupt(s) for the specified PWM generator block. */ | void PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints) | /* Clears the specified interrupt(s) for the specified PWM generator block. */
void PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints) | {
ASSERT(ui32Base == PWM0_BASE);
ASSERT(_PWMGenValid(ui32Gen));
ASSERT((ui32Ints &
~(PWM_INT_CNT_ZERO | PWM_INT_CNT_LOAD | PWM_INT_CNT_AU |
PWM_INT_CNT_AD | PWM_INT_CNT_BU | PWM_INT_CNT_BD)) == 0);
HWREG(PWM_GEN_BADDR(ui32Base, ui32Gen) + PWM_O_X_ISC) = ui32Ints;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get contents of register REGNO in task TASK. */ | static long get_reg(struct task_struct *task, int regno) | /* Get contents of register REGNO in task TASK. */
static long get_reg(struct task_struct *task, int regno) | {
unsigned char *reg_ptr;
struct pt_regs *regs =
(struct pt_regs *)((unsigned long)task_stack_page(task) +
(THREAD_SIZE - sizeof(struct pt_regs)));
reg_ptr = (char *)regs;
switch (regno) {
case PT_USP:
return task->thread.usp;
default:
if (regno <= 216)
return *(long *)(reg_ptr + regno);
}
printk(KERN_WARNING "Request to get for unknown register %d\n", regno);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Get a record name as a printable string */ | static const char* get_record_name(char *buf, int len, const struct bootstage_record *rec) | /* Get a record name as a printable string */
static const char* get_record_name(char *buf, int len, const struct bootstage_record *rec) | {
if (rec->name)
return rec->name;
else if (rec->id >= BOOTSTAGE_ID_USER)
snprintf(buf, len, "user_%d", rec->id - BOOTSTAGE_ID_USER);
else
snprintf(buf, len, "id=%d", rec->id);
return buf;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Retrieves the device type information of the SCSI Controller. */ | EFI_STATUS EFIAPI ScsiGetDeviceType(IN EFI_SCSI_IO_PROTOCOL *This, OUT UINT8 *DeviceType) | /* Retrieves the device type information of the SCSI Controller. */
EFI_STATUS EFIAPI ScsiGetDeviceType(IN EFI_SCSI_IO_PROTOCOL *This, OUT UINT8 *DeviceType) | {
SCSI_IO_DEV *ScsiIoDevice;
if (DeviceType == NULL) {
return EFI_INVALID_PARAMETER;
}
ScsiIoDevice = SCSI_IO_DEV_FROM_THIS (This);
*DeviceType = ScsiIoDevice->ScsiDeviceType;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function is used to set the clock to the passed frequency. */ | s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq) | /* This function is used to set the clock to the passed frequency. */
s32 XSdPs_SetClock(XSdPs *InstancePtr, u32 SelFreq) | {
u16 ClockReg;
s32 Status;
XSdPs_WriteReg16(InstancePtr->Config.BaseAddress,
XSDPS_CLK_CTRL_OFFSET, 0U);
if (SelFreq == 0U) {
Status = XST_SUCCESS;
goto RETURN_PATH ;
}
ClockReg = XSdPs_CalcClock(InstancePtr, SelFreq);
Status = XSdPs_EnableClock(InstancePtr, ClockReg);
if (Status != XST_SUCCESS) {
Status = XST_FAILURE;
}
RETURN_PATH:
return Status;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function will set usb device string description. */ | rt_err_t rt_usbd_device_set_string(udevice_t device, const char **ustring) | /* This function will set usb device string description. */
rt_err_t rt_usbd_device_set_string(udevice_t device, const char **ustring) | {
RT_ASSERT(device != RT_NULL);
RT_ASSERT(ustring != RT_NULL);
device->str = ustring;
return RT_EOK;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* We must make maximum error ≤ tolerance, so compute the ∆ needed: */ | int _cairo_pen_vertices_needed(double tolerance, double radius, const cairo_matrix_t *matrix) | /* We must make maximum error ≤ tolerance, so compute the ∆ needed: */
int _cairo_pen_vertices_needed(double tolerance, double radius, const cairo_matrix_t *matrix) | {
double major_axis = _cairo_matrix_transformed_circle_major_axis (matrix,
radius);
int num_vertices;
if (tolerance >= 4*major_axis) {
num_vertices = 1;
} else if (tolerance >= major_axis) {
num_vertices = 4;
} else {
num_vertices = ceil (2*M_PI / acos (1 - tolerance / major_axis));
if (num_vertices % 2)
num_vertices++;
if (num_vertices < 4)
num_vertices = 4;
}
return num_vertices;
} | xboot/xboot | C++ | MIT License | 779 |
/* Converts a generic text device path node to device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextGenericPath(UINT8 Type, CHAR16 *TextDeviceNode) | /* Converts a generic text device path node to device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextGenericPath(UINT8 Type, CHAR16 *TextDeviceNode) | {
EFI_DEVICE_PATH_PROTOCOL *Node;
CHAR16 *SubtypeStr;
CHAR16 *DataStr;
UINTN DataLength;
SubtypeStr = GetNextParamStr (&TextDeviceNode);
DataStr = GetNextParamStr (&TextDeviceNode);
if (DataStr == NULL) {
DataLength = 0;
} else {
DataLength = StrLen (DataStr) / 2;
}
Node = CreateDeviceNode (
Type,
(UINT8) Strtoi (SubtypeStr),
(UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
);
StrHexToBytes (DataStr, DataLength * 2, (UINT8 *) (Node + 1), DataLength);
return Node;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns the USB Host Speed from the Low Level Driver. */ | USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) | /* Returns the USB Host Speed from the Low Level Driver. */
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) | {
USBH_SpeedTypeDef speed = USBH_SPEED_LOW;
switch (HAL_HCD_GetCurrentSpeed(phost->pData))
{
case 0:
speed = USBH_SPEED_HIGH;
break;
case 1:
speed = USBH_SPEED_FULL;
break;
case 2:
speed = USBH_SPEED_LOW;
break;
default:
speed = USBH_SPEED_HIGH;
break;
}
return speed;
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Send an asynchronous activation request after a given interval. */ | static void variax_activate_delayed(struct usb_line6_variax *variax, int seconds) | /* Send an asynchronous activation request after a given interval. */
static void variax_activate_delayed(struct usb_line6_variax *variax, int seconds) | {
variax->activate_timer.expires = jiffies + seconds * HZ;
variax->activate_timer.function = variax_activate_timeout;
variax->activate_timer.data = (unsigned long)variax;
add_timer(&variax->activate_timer);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This path is taken when writing to already allocated clusters. */ | static void qed_aio_write_inplace(QEDAIOCB *acb, uint64_t offset, size_t len) | /* This path is taken when writing to already allocated clusters. */
static void qed_aio_write_inplace(QEDAIOCB *acb, uint64_t offset, size_t len) | {
if (acb->flags & QED_AIOCB_ZERO) {
struct iovec *iov = acb->qiov->iov;
if (!iov->iov_base) {
iov->iov_base = qemu_blockalign(acb->common.bs, iov->iov_len);
memset(iov->iov_base, 0, iov->iov_len);
}
}
acb->cur_cluster = offset;
qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
qed_aio_write_main(acb, 0);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Connect all ESAI pins, and this will make the ESAI out of personal reset state. */ | static int32_t esai_connect_pins(audio_ctrl_p ctrl) | /* Connect all ESAI pins, and this will make the ESAI out of personal reset state. */
static int32_t esai_connect_pins(audio_ctrl_p ctrl) | {
uint32_t instance = ctrl->instance;
UNUSED_VARIABLE(instance);
HW_ESAI_PCRC_WR(ESAI_GPIO_ESAI);
HW_ESAI_PRRC_WR(ESAI_GPIO_ESAI);
return 0;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Close down a STRIP channel. This means flushing out any pending queues, and then restoring the TTY line discipline to what it was before it got hooked to STRIP (which usually is TTY again). */ | static void strip_close(struct tty_struct *tty) | /* Close down a STRIP channel. This means flushing out any pending queues, and then restoring the TTY line discipline to what it was before it got hooked to STRIP (which usually is TTY again). */
static void strip_close(struct tty_struct *tty) | {
struct strip *strip_info = tty->disc_data;
if (!strip_info || strip_info->magic != STRIP_MAGIC)
return;
unregister_netdev(strip_info->dev);
tty->disc_data = NULL;
strip_info->tty = NULL;
printk(KERN_INFO "STRIP: device \"%s\" closed down\n",
strip_info->dev->name);
strip_free(strip_info);
tty->disc_data = NULL;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.