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 |
|---|---|---|---|---|---|---|---|
/* Checks whether the ETHERNET software reset bit is set or not. */ | FlagStatus ETH_GetSoftwareResetStatus(void) | /* Checks whether the ETHERNET software reset bit is set or not. */
FlagStatus ETH_GetSoftwareResetStatus(void) | {
FlagStatus bitstatus = RESET;
if ((ETH->DMABUSMOD & ETH_DMABUSMOD_SWR) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Call GPIO driver to read state of pins. Return boolean true if both lines HIGH else return boolean false */ | static bool check_lines_high(const struct device *dev) | /* Call GPIO driver to read state of pins. Return boolean true if both lines HIGH else return boolean false */
static bool check_lines_high(const struct device *dev) | {
const struct i2c_xec_config *config =
(const struct i2c_xec_config *const)(dev->config);
gpio_port_value_t sda = 0, scl = 0;
if (gpio_port_get_raw(config->sda_gpio.port, &sda)) {
LOG_ERR("gpio_port_get_raw for %s SDA failed", dev->name);
return false;
}
if (config->sda_gpio.port == config->scl_gpio.port) {... | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* We enter here if we get an unrecoverable exception, that is, one that happened at a point where the RI (recoverable interrupt) bit in the MSR is 0. This indicates that SRR0/1 are live, and that we therefore lost state by taking this exception. */ | void unrecoverable_exception(struct pt_regs *regs) | /* We enter here if we get an unrecoverable exception, that is, one that happened at a point where the RI (recoverable interrupt) bit in the MSR is 0. This indicates that SRR0/1 are live, and that we therefore lost state by taking this exception. */
void unrecoverable_exception(struct pt_regs *regs) | {
printk(KERN_EMERG "Unrecoverable exception %lx at %lx\n",
regs->trap, regs->nip);
die("Unrecoverable exception", regs, SIGABRT);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* appends uint16_t in a packet, incrementing the index */ | static uint8_t _mdns_append_u16(uint8_t *packet, uint16_t *index, uint16_t value) | /* appends uint16_t in a packet, incrementing the index */
static uint8_t _mdns_append_u16(uint8_t *packet, uint16_t *index, uint16_t value) | {
if ((*index + 1) >= MDNS_MAX_PACKET_SIZE) {
return 0;
}
_mdns_append_u8(packet, index, (value >> 8) & 0xFF);
_mdns_append_u8(packet, index, value & 0xFF);
return 2;
} | retro-esp32/RetroESP32 | C++ | Creative Commons Attribution Share Alike 4.0 International | 581 |
/* The function performs as few config space accesses as possible (without attempting 64-bit wide accesses). */ | RETURN_STATUS EFIAPI PciCapRead(IN PCI_CAP_DEV *PciDevice, IN PCI_CAP *Cap, IN UINT16 SourceOffsetInCap, OUT VOID *DestinationBuffer, IN UINT16 Size) | /* The function performs as few config space accesses as possible (without attempting 64-bit wide accesses). */
RETURN_STATUS EFIAPI PciCapRead(IN PCI_CAP_DEV *PciDevice, IN PCI_CAP *Cap, IN UINT16 SourceOffsetInCap, OUT VOID *DestinationBuffer, IN UINT16 Size) | {
if (SourceOffsetInCap + Size > Cap->MaxSizeHint) {
return RETURN_BAD_BUFFER_SIZE;
}
return PciDevice->ReadConfig (
PciDevice,
Cap->Offset + SourceOffsetInCap,
DestinationBuffer,
Size
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function will let current thread yield processor, and scheduler will choose a highest thread to run. After yield processor, the current thread is still in READY state. */ | rt_err_t rt_thread_yield(void) | /* This function will let current thread yield processor, and scheduler will choose a highest thread to run. After yield processor, the current thread is still in READY state. */
rt_err_t rt_thread_yield(void) | {
struct rt_thread *thread;
rt_base_t lock;
thread = rt_thread_self();
lock = rt_hw_interrupt_disable();
thread->remaining_tick = thread->init_tick;
thread->stat |= RT_THREAD_STAT_YIELD;
rt_schedule();
rt_hw_interrupt_enable(lock);
return RT_EOK;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* This file is part of the Simba project. */ | int mock_write_ping_module_init(int res) | /* This file is part of the Simba project. */
int mock_write_ping_module_init(int res) | {
harness_mock_write("ping_module_init()",
NULL,
0);
harness_mock_write("ping_module_init(): return (res)",
&res,
sizeof(res));
return (0);
} | eerimoq/simba | C++ | Other | 337 |
/* Called when we remove a chunk of metadata from an inode. We don't bother reverting things to an inlined array in the case of a remove which moves us back under the limit. */ | void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci, struct buffer_head *bh) | /* Called when we remove a chunk of metadata from an inode. We don't bother reverting things to an inlined array in the case of a remove which moves us back under the limit. */
void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci, struct buffer_head *bh) | {
sector_t block = bh->b_blocknr;
ocfs2_remove_block_from_cache(ci, block);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* DMA Channel Enable Transfers from Memory.
The data direction is set to read from memory. */ | void dma_set_read_from_memory(uint32_t dma, uint8_t channel) | /* DMA Channel Enable Transfers from Memory.
The data direction is set to read from memory. */
void dma_set_read_from_memory(uint32_t dma, uint8_t channel) | {
DMA_CCR(dma, channel) |= DMA_CCR_DIR;
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* check for SRAM protection enabled.
Use this function to determine if SRAM protection is enabled. */ | bool am_hal_flash_wipe_sram_enable_check(void) | /* check for SRAM protection enabled.
Use this function to determine if SRAM protection is enabled. */
bool am_hal_flash_wipe_sram_enable_check(void) | {
if ( customer_info_signature_erased() )
{
return false;
}
if ( !am_hal_flash_customer_info_signature_check() )
{
return false;
}
return AM_REGVAL(AM_HAL_FLASH_INFO_SECURITY_ADDR) &
AM_HAL_FLASH_INFO_SECURITY_SRAMWIPE_M ? false : true;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Message: MediaTransmissionFailureMessage Opcode: 0x002a Type: MediaControl Direction: dev2pbx VarLength: no */ | static void handle_MediaTransmissionFailureMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | /* Message: MediaTransmissionFailureMessage Opcode: 0x002a Type: MediaControl Direction: dev2pbx VarLength: no */
static void handle_MediaTransmissionFailureMessage(ptvcursor_t *cursor, packet_info *pinfo _U_) | {
ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN);
ptvcursor_add(cursor, hf_skinny_passThruPartyID, 4, ENC_LITTLE_ENDIAN);
dissect_skinny_ipv4or6(cursor, hf_skinny_remoteIpAddr_ipv4, hf_skinny_remoteIpAddr_ipv6, pinfo);
ptvcursor_add(cursor, hf_skinny_remotePortNumber, 4, ENC_LITTLE_ENDIAN);... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Returns: a string describing the last module error */ | const gchar* g_module_error(void) | /* Returns: a string describing the last module error */
const gchar* g_module_error(void) | {
return g_private_get (&module_error_private);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This is called when we want to synchronize with interrupts. We may for example tell a device to stop sending interrupts: but to make sure there are no interrupts that are executing on another CPU we need to call this function. */ | void unexpected_irq(int irq, void *dev_id, struct pt_regs *regs) | /* This is called when we want to synchronize with interrupts. We may for example tell a device to stop sending interrupts: but to make sure there are no interrupts that are executing on another CPU we need to call this function. */
void unexpected_irq(int irq, void *dev_id, struct pt_regs *regs) | {
int i;
struct irqaction * action;
unsigned int cpu_irq;
cpu_irq = irq & (NR_IRQS - 1);
action = sparc_irq[cpu_irq].action;
printk("IO device interrupt, irq = %d\n", irq);
printk("PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc,
regs->npc, regs->u_regs[14]);
if (action) {
printk("Exp... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Call a function (C or Lua) through C. 'inc' can be 1 (increment number of recursive invocations in the C stack) or nyci (the same plus increment number of non-yieldable calls). */ | l_sinline void ccall(lua_State *L, StkId func, int nResults, int inc) | /* Call a function (C or Lua) through C. 'inc' can be 1 (increment number of recursive invocations in the C stack) or nyci (the same plus increment number of non-yieldable calls). */
l_sinline void ccall(lua_State *L, StkId func, int nResults, int inc) | {
ci->callstatus = CIST_FRESH;
luaV_execute(L, ci);
}
L->nCcalls -= inc;
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* "Logical" counter registers. These will read/write 16-bits or 32-bits depending on the current size of the counter. Counters 4 - 7 are always 16-bit. */ | u32 cbe_read_ctr(u32 cpu, u32 ctr) | /* "Logical" counter registers. These will read/write 16-bits or 32-bits depending on the current size of the counter. Counters 4 - 7 are always 16-bit. */
u32 cbe_read_ctr(u32 cpu, u32 ctr) | {
u32 val;
u32 phys_ctr = ctr & (NR_PHYS_CTRS - 1);
val = cbe_read_phys_ctr(cpu, phys_ctr);
if (cbe_get_ctr_size(cpu, phys_ctr) == 16)
val = (ctr < NR_PHYS_CTRS) ? (val >> 16) : (val & 0xffff);
return val;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* brief DMA instance 1, channel 1 IRQ handler. */ | void EDMA_1_CH1_DriverIRQHandler(void) | /* brief DMA instance 1, channel 1 IRQ handler. */
void EDMA_1_CH1_DriverIRQHandler(void) | {
EDMA_DriverIRQHandler(1U, 1U);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Returns positive 8 bit value from device if successful or a negative value on error */ | static int max7301_read(struct spi_device *spi, unsigned int reg) | /* Returns positive 8 bit value from device if successful or a negative value on error */
static int max7301_read(struct spi_device *spi, unsigned int reg) | {
int ret;
u16 word;
word = 0x8000 | (reg << 8);
ret = spi_write(spi, (const u8 *)&word, sizeof(word));
if (ret)
return ret;
ret = spi_read(spi, (u8 *)&word, sizeof(word));
if (ret)
return ret;
return word & 0xff;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This PDC function places the soft power button under software or hardware control. Under software control the OS may control to when to allow to shut down the system. Under hardware control pressing the power button powers off the system immediately. */ | int pdc_soft_power_button(int sw_control) | /* This PDC function places the soft power button under software or hardware control. Under software control the OS may control to when to allow to shut down the system. Under hardware control pressing the power button powers off the system immediately. */
int pdc_soft_power_button(int sw_control) | {
int retval;
unsigned long flags;
spin_lock_irqsave(&pdc_lock, flags);
retval = mem_pdc_call(PDC_SOFT_POWER, PDC_SOFT_POWER_ENABLE, __pa(pdc_result), sw_control);
spin_unlock_irqrestore(&pdc_lock, flags);
return retval;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* find the upstream PCIe-to-PCI bridge of a PCI device if the device is PCIE, return NULL if the device isn't connected to a PCIe bridge (that is its parent is a legacy PCI bridge and the bridge is directly connected to bus 0), return its parent */ | struct pci_dev* pci_find_upstream_pcie_bridge(struct pci_dev *pdev) | /* find the upstream PCIe-to-PCI bridge of a PCI device if the device is PCIE, return NULL if the device isn't connected to a PCIe bridge (that is its parent is a legacy PCI bridge and the bridge is directly connected to bus 0), return its parent */
struct pci_dev* pci_find_upstream_pcie_bridge(struct pci_dev *pdev) | {
struct pci_dev *tmp = NULL;
if (pci_is_pcie(pdev))
return NULL;
while (1) {
if (pci_is_root_bus(pdev->bus))
break;
pdev = pdev->bus->self;
if (!pci_is_pcie(pdev)) {
tmp = pdev;
continue;
}
if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) {
WARN_ON_ONCE(1);
return NULL;
}
return pdev;
... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns non-zero if the value is changed, zero if not changed. */ | void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, unsigned int k, struct snd_interval *c) | /* Returns non-zero if the value is changed, zero if not changed. */
void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, unsigned int k, struct snd_interval *c) | {
unsigned int r;
if (a->empty || b->empty) {
snd_interval_none(c);
return;
}
c->empty = 0;
c->min = muldiv32(a->min, b->min, k, &r);
c->openmin = (r || a->openmin || b->openmin);
c->max = muldiv32(a->max, b->max, k, &r);
if (r) {
c->max++;
c->openmax = 1;
} else
c->openmax = (a->openmax || b->openma... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is a helper function for the wtk_frame_handler() function. It is called when a pointer RELEASE event is sent to the container window. This function completes the move operation if the RELEASE event was inside the parent window's boundaries. */ | static void wtk_handle_frame_release(struct wtk_frame *frame, struct win_pointer_event const *event) | /* This function is a helper function for the wtk_frame_handler() function. It is called when a pointer RELEASE event is sent to the container window. This function completes the move operation if the RELEASE event was inside the parent window's boundaries. */
static void wtk_handle_frame_release(struct wtk_frame *fram... | {
bool is_inside;
switch (frame->state) {
case WTK_FRAME_MOVING:
wtk_stop_drag(&(event->last_pos));
win_grab_pointer(NULL);
frame->state = WTK_FRAME_NORMAL;
is_inside = win_is_inside_window(win_get_parent(frame->
container), &(event->pos));
if (is_inside) {
struct win_area area = *win_get_area(frame... | memfault/zero-to-main | C++ | null | 200 |
/* If 32-bit MMIO register operations are not supported, 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 ra... | UINT32 EFIAPI MmioBitFieldOr32(IN UINTN Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT32 OrData) | /* If 32-bit MMIO register operations are not supported, 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 ra... | {
return MmioWrite32 (
Address,
BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)
);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Get the CRC32 check result with the expected value. */ | en_flag_status_t CRC_CRC32_GetCheckResult(uint32_t u32ExpectValue) | /* Get the CRC32 check result with the expected value. */
en_flag_status_t CRC_CRC32_GetCheckResult(uint32_t u32ExpectValue) | {
__IO uint32_t u32Count = CRC_CALC_CLK_COUNT;
en_flag_status_t enStatus;
uint32_t u32Expect_Value = u32ExpectValue;
u32Expect_Value = CRC_ConvertCrcValue(u32Expect_Value);
(void)CRC_WriteData32(&u32Expect_Value, 1UL);
while (u32Count-- != 0UL) {
__NOP();
}
enStatus = CRC_GetResu... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* After getting one control group, jump to the next block (fromaddress += 8192). */ | static int sddr09_read21(struct us_data *us, unsigned long fromaddress, int count, int controlshift, unsigned char *buf, int use_sg) | /* After getting one control group, jump to the next block (fromaddress += 8192). */
static int sddr09_read21(struct us_data *us, unsigned long fromaddress, int count, int controlshift, unsigned char *buf, int use_sg) | {
int bulklen = (count << controlshift);
return sddr09_readX(us, 1, fromaddress, count, bulklen,
buf, use_sg);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Enables or disables the Internal High Speed oscillator (HSI). HSI can not be stopped if it is used directly or through the PLL as system clock. */ | void RCC_HSICmd(FunctionalState NewState) | /* Enables or disables the Internal High Speed oscillator (HSI). HSI can not be stopped if it is used directly or through the PLL as system clock. */
void RCC_HSICmd(FunctionalState NewState) | {
assert_param(IS_FUNCTIONAL_STATE(NewState));
if(NewState==ENABLE)
{
RCC->CR |= 0x01;
}
else
{
RCC->CR &= 0xfffffffe;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Initializes results holder. This is called automatically by the enable function */ | inv_error_t inv_init_results_holder(void) | /* Initializes results holder. This is called automatically by the enable function */
inv_error_t inv_init_results_holder(void) | {
memset(&rh, 0, sizeof(rh));
rh.mag_scale[0] = 1L<<30;
rh.mag_scale[1] = 1L<<30;
rh.mag_scale[2] = 1L<<30;
rh.compass_correction[0] = 1L<<30;
rh.gam_quat[0] = 1L<<30;
rh.nav_quat[0] = 1L<<30;
rh.quat_confidence_interval = (float)M_PI;
return INV_SUCCESS;
} | Luos-io/luos_engine | C++ | MIT License | 496 |
/* This API is used to get the tap quiet in the register 0x2A bit 7. */ | BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_tap_quiet(u8 *tap_quiet_u8) | /* This API is used to get the tap quiet in the register 0x2A bit 7. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_get_tap_quiet(u8 *tap_quiet_u8) | {
u8 data_u8 = BMA2x2_INIT_VALUE;
BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR;
if (p_bma2x2 == BMA2x2_NULL)
{
return E_BMA2x2_NULL_PTR;
}
else
{
com_rslt = p_bma2x2->BMA2x2_BUS_READ_FUNC
(p_bma2x2->dev_addr,
BMA2x2_TAP_QUIET_DURN_REG, &... | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* The strpbrk function locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2. */ | char* strpbrk(const char *s1, const char *s2) | /* The strpbrk function locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2. */
char* strpbrk(const char *s1, const char *s2) | {
UINT8 bitmap[(((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];
UINT8 bit;
int index;
BuildBitmap (bitmap, s2, sizeof (bitmap) / sizeof (UINT64));
for ( ; *s1 != '\0'; ++s1) {
index = WHICH8 (*s1);
bit = WHICH_BIT (*s1);
if ((bitmap[index] & bit) != 0) {
return (char *)s1;
... | tianocore/edk2 | C++ | Other | 4,240 |
/* The function will check if long mode waking vector is supported. */ | BOOLEAN IsLongModeWakingVectorSupport(IN EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs) | /* The function will check if long mode waking vector is supported. */
BOOLEAN IsLongModeWakingVectorSupport(IN EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs) | {
if ((Facs == NULL) ||
(Facs->Signature != EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE))
{
return FALSE;
}
if ((Facs->Version == EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) &&
((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) != 0))
{
if (sizeof (UINTN) == sizeof (... | tianocore/edk2 | C++ | Other | 4,240 |
/* early init function before main
This function is executed right before main function. For RISC-V gnu toolchain, _init function might not be called by __libc_init_array function, so we defined a new function to do initialization */ | void _premain_init(void) | /* early init function before main
This function is executed right before main function. For RISC-V gnu toolchain, _init function might not be called by __libc_init_array function, so we defined a new function to do initialization */
void _premain_init(void) | {
Exception_Init();
ECLIC_Init();
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Returns: the number of elements in the #GSList */ | guint g_slist_length(GSList *list) | /* Returns: the number of elements in the #GSList */
guint g_slist_length(GSList *list) | {
guint length;
length = 0;
while (list)
{
length++;
list = list->next;
}
return length;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* vers_1 5.0, "Brain Boxes", "2-Port RS232 card", "r6" manfid 0x0160, 0x0104 This card appears to have a 14.7456MHz clock. */ | static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_port *port) | /* vers_1 5.0, "Brain Boxes", "2-Port RS232 card", "r6" manfid 0x0160, 0x0104 This card appears to have a 14.7456MHz clock. */
static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_port *port) | {
port->uartclk = 14745600;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Writes more than one byte to the HT24Cxx with a single WRITE cycle. */ | void HT24CxxPageWrite(unsigned char *pucBuffer, unsigned short usWriteAddr, unsigned char ucNumByteToWrite) | /* Writes more than one byte to the HT24Cxx with a single WRITE cycle. */
void HT24CxxPageWrite(unsigned char *pucBuffer, unsigned short usWriteAddr, unsigned char ucNumByteToWrite) | {
xI2CMasterWriteS1(HT24Cxx_PIN_I2C_PORT, HT24Cxx_ADDRESS,
(unsigned char)((usWriteAddr & 0x00FF)),
xfalse);
while(ucNumByteToWrite--)
{
if(ucNumByteToWrite == 0)
{
xI2CMasterWriteS2(HT24Cxx_PIN_I2C_PORT, *pucBuffer, xtrue);
} e... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* Returns the most recent received data by the I2Cx peripheral. */ | uint8_t I2C_ReceiveData(I2C_TypeDef *I2Cx) | /* Returns the most recent received data by the I2Cx peripheral. */
uint8_t I2C_ReceiveData(I2C_TypeDef *I2Cx) | {
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
return (uint8_t)I2Cx->RXDR;
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* Check the existance of pending descriptor.
dmac_isr () { ... if (dmacHw_descriptorPending (handle)) { dmacHw_initiateTransfer (handle); } } */ | uint32_t dmacHw_descriptorPending(dmacHw_HANDLE_t handle, void *pDescriptor) | /* Check the existance of pending descriptor.
dmac_isr () { ... if (dmacHw_descriptorPending (handle)) { dmacHw_initiateTransfer (handle); } } */
uint32_t dmacHw_descriptorPending(dmacHw_HANDLE_t handle, void *pDescriptor) | {
dmacHw_CBLK_t *pCblk = dmacHw_HANDLE_TO_CBLK(handle);
dmacHw_DESC_RING_t *pRing = dmacHw_GET_DESC_RING(pDescriptor);
if (!CHANNEL_BUSY(pCblk->module, pCblk->channel)) {
if (pRing->pEnd) {
return 1;
}
}
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. */ | LIBC_ROM_TEXT_SECTION _LONG_CALL_ size_t _strnlen(const char *s, size_t count) | /* This module is a confidential and proprietary property of RealTek and possession or use of this module requires written permission of RealTek. */
LIBC_ROM_TEXT_SECTION _LONG_CALL_ size_t _strnlen(const char *s, size_t count) | {
const char *sc;
for (sc = s; count-- && *sc != '\0'; ++sc)
;
return sc - s;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Initialises the iir_i_t instance.
8-bit Alpha Float equivalent */ | void iir_i_init(iir_i_t *iir, uint8_t alpha) | /* Initialises the iir_i_t instance.
8-bit Alpha Float equivalent */
void iir_i_init(iir_i_t *iir, uint8_t alpha) | {
iir->k = 0;
iir->alpha = alpha;
iir->avg = 0;
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Check if the device instance of the selected address is already registered and return its index. */ | static uint8_t mfxstm32l152_GetInstance(uint16_t DeviceAddr) | /* Check if the device instance of the selected address is already registered and return its index. */
static uint8_t mfxstm32l152_GetInstance(uint16_t DeviceAddr) | {
uint8_t idx;
for(idx = 0; idx < MFXSTM32L152_MAX_INSTANCE ; idx ++)
{
if(mfxstm32l152[idx] == DeviceAddr)
{
return idx;
}
}
return 0xFF;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* mux the pin to the "A" internal peripheral role. */ | int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup) | /* mux the pin to the "A" internal peripheral role. */
int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup) | {
struct at91_port *at91_port = at91_pio_get_port(port);
u32 mask;
if (at91_port && (pin < GPIO_PER_BANK)) {
mask = 1 << pin;
writel(mask, &at91_port->idr);
at91_set_pio_pullup(port, pin, use_pullup);
writel(mask, &at91_port->mux.pio2.asr);
writel(mask, &at91_port->pdr);
}
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* The Timer 3 default IRQ, declared in start up code. */ | void TIMER3IntHandler(void) | /* The Timer 3 default IRQ, declared in start up code. */
void TIMER3IntHandler(void) | {
unsigned long ulBase = TIMER3_BASE;
unsigned long ulTemp0,ulTemp1;
ulTemp0 = (xHWREG(ulBase + TIMER_TISR) & TIMER_TISR_TIF);
xHWREG(ulBase + TIMER_TISR) = ulTemp0;
ulTemp1 = (xHWREG(ulBase + TIMER_TEISR) & TIMER_TISR_TIF);
xHWREG(ulBase + TIMER_TEISR) = ulTemp1;
if (g_pfnTimerHandlerCallba... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* @osdnum: The OSD device to be selected, identified by its sequence number. Return: 0 if OK, -ve on error */ | static int cmd_osd_set_osd_num(unsigned int osdnum) | /* @osdnum: The OSD device to be selected, identified by its sequence number. Return: 0 if OK, -ve on error */
static int cmd_osd_set_osd_num(unsigned int osdnum) | {
struct udevice *osd;
int res;
res = uclass_get_device_by_seq(UCLASS_VIDEO_OSD, osdnum, &osd);
if (res) {
printf("%s: No OSD %u (err = %d)\n", __func__, osdnum, res);
return res;
}
osd_cur = osd;
return 0;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Converts a text device path node to Hardware PCI device path structure. */ | EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPci(CHAR16 *TextDeviceNode) | /* Converts a text device path node to Hardware PCI device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextPci(CHAR16 *TextDeviceNode) | {
CHAR16 *FunctionStr;
CHAR16 *DeviceStr;
PCI_DEVICE_PATH *Pci;
DeviceStr = GetNextParamStr (&TextDeviceNode);
FunctionStr = GetNextParamStr (&TextDeviceNode);
Pci = (PCI_DEVICE_PATH *) CreateDeviceNode (
HARDWARE_DEVICE_PATH,
... | tianocore/edk2 | C++ | Other | 4,240 |
/* Returns 0 if @work was already on a queue, non-zero otherwise. */ | int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) | /* Returns 0 if @work was already on a queue, non-zero otherwise. */
int queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) | {
if (delay == 0)
return queue_work(wq, &dwork->work);
return queue_delayed_work_on(-1, wq, dwork, delay);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Timer Counter Overflow interrupt call back function.
This function is called when an overflow interrupt has occurred on */ | static void sha204h_timer_overflow_interrupt_callback(void) | /* Timer Counter Overflow interrupt call back function.
This function is called when an overflow interrupt has occurred on */
static void sha204h_timer_overflow_interrupt_callback(void) | {
sha204_timer_expired = true;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* nand_block_isbad - Check if block at offset is bad @mtd: MTD device structure @offs: offset relative to mtd start */ | static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) | /* nand_block_isbad - Check if block at offset is bad @mtd: MTD device structure @offs: offset relative to mtd start */
static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) | {
struct nand_chip *chip = mtd_to_nand(mtd);
int chipnr = (int)(offs >> chip->chip_shift);
int ret;
nand_get_device(mtd, FL_READING);
chip->select_chip(mtd, chipnr);
ret = nand_block_checkbad(mtd, offs, 0);
chip->select_chip(mtd, -1);
nand_release_device(mtd);
return ret;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Interrupts not specified by the mask will not be affected */ | void XAxiVdma_IntrClear(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction) | /* Interrupts not specified by the mask will not be affected */
void XAxiVdma_IntrClear(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction) | {
XAxiVdma_Channel *Channel;
Channel = XAxiVdma_GetChannel(InstancePtr, Direction);
if (Channel->IsValid) {
XAxiVdma_ChannelIntrClear(Channel, IntrType);
}
return;
} | ua1arn/hftrx | C++ | null | 69 |
/* Configure the internal OSC32K oscillator clock source.
Configures the 32KHz (nominal) internal RC oscillator with the given configuration settings. */ | void system_clock_source_osc32k_set_config(struct system_clock_source_osc32k_config *const config) | /* Configure the internal OSC32K oscillator clock source.
Configures the 32KHz (nominal) internal RC oscillator with the given configuration settings. */
void system_clock_source_osc32k_set_config(struct system_clock_source_osc32k_config *const config) | {
SYSCTRL_OSC32K_Type temp = SYSCTRL->OSC32K;
temp.bit.EN1K = config->enable_1khz_output;
temp.bit.EN32K = config->enable_32khz_output;
temp.bit.STARTUP = config->startup_time;
temp.bit.ONDEMAND = config->on_demand;
temp.bit.RUNSTDBY = config->run_in_standby;
temp.bit.WRTLOCK = config->write_once;
SYSC... | memfault/zero-to-main | C++ | null | 200 |
/* Calls the given function for each of the symbol/value pairs in the given scope of the #GScanner. The function is passed the symbol and value of each pair, and the given @user_data parameter. */ | void g_scanner_scope_foreach_symbol(GScanner *scanner, guint scope_id, GHFunc func, gpointer user_data) | /* Calls the given function for each of the symbol/value pairs in the given scope of the #GScanner. The function is passed the symbol and value of each pair, and the given @user_data parameter. */
void g_scanner_scope_foreach_symbol(GScanner *scanner, guint scope_id, GHFunc func, gpointer user_data) | {
gpointer d[3];
g_return_if_fail (scanner != NULL);
d[0] = (gpointer) func;
d[1] = user_data;
d[2] = &scope_id;
g_hash_table_foreach (scanner->symbol_table, g_scanner_foreach_internal, d);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* This function is executed in case of error occurrence. */ | static void Error_Handler(void) | /* This function is executed in case of error occurrence. */
static void Error_Handler(void) | {
while (1)
{
BSP_LED_Toggle(LED2);
HAL_Delay(1000);
}
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* If this function returns, it means that the system does not support cold reset. */ | VOID EFIAPI ResetCold(VOID) | /* If this function returns, it means that the system does not support cold reset. */
VOID EFIAPI ResetCold(VOID) | {
mInternalRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Clear an interrupt status for an input GPIO pin. Using this function on a gpio pin which has generated a interrupt. */ | int32_t hal_gpio_clear_irq(gpio_dev_t *gpio) | /* Clear an interrupt status for an input GPIO pin. Using this function on a gpio pin which has generated a interrupt. */
int32_t hal_gpio_clear_irq(gpio_dev_t *gpio) | {
const struct HAL_GPIO_IRQ_CFG_T gpiocfg = {
.irq_enable = false,
.irq_debounce = false,
.irq_polarity = HAL_GPIO_IRQ_POLARITY_LOW_FALLING,
.irq_handler = NULL,
.irq_type = HAL_GPIO_IRQ_TYPE_EDGE_SENSITIVE,
};
hal_gpio_setup_irq(gpio->port, &gpiocfg);
return 0;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Read data from the specified page in AT24CXX. */ | uint32_t at24cxx_read_page(uint32_t u32_page_address, uint32_t u32_page_size, uint8_t *p_rd_buffer) | /* Read data from the specified page in AT24CXX. */
uint32_t at24cxx_read_page(uint32_t u32_page_address, uint32_t u32_page_size, uint8_t *p_rd_buffer) | {
twi_package_t twi_package;
uint32_t start_address = (u32_page_address * u32_page_size) & 0xFFFF;
twi_package.chip = BOARD_AT24C_ADDRESS;
at24c_build_word_address(twi_package.addr, start_address);
twi_package.addr_length = AT24C_MEM_ADDR_LEN;
twi_package.buffer = p_rd_buffer;
twi_package.length = u32_page_size;... | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* This is the shell command handler function pointer callback type. This function handles the command when it is invoked in the shell. */ | SHELL_STATUS EFIAPI TftpCommandHandler(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN EFI_SYSTEM_TABLE *SystemTable, IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN EFI_SHELL_PROTOCOL *Shell) | /* This is the shell command handler function pointer callback type. This function handles the command when it is invoked in the shell. */
SHELL_STATUS EFIAPI TftpCommandHandler(IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, IN EFI_SYSTEM_TABLE *SystemTable, IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN EFI_SHELL... | {
gEfiShellParametersProtocol = ShellParameters;
gEfiShellProtocol = Shell;
return RunTftp (gImageHandle, SystemTable);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Currently, only assabet is known to support this. */ | static int __sa1100_irda_set_power(struct sa1100_irda *si, unsigned int state) | /* Currently, only assabet is known to support this. */
static int __sa1100_irda_set_power(struct sa1100_irda *si, unsigned int state) | {
int ret = 0;
if (si->pdata->set_power)
ret = si->pdata->set_power(si->dev, state);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Create a command transfer TRB to support XHCI command interfaces. */ | URB* XhcCreateCmdTrb(IN USB_XHCI_INSTANCE *Xhc, IN TRB_TEMPLATE *CmdTrb) | /* Create a command transfer TRB to support XHCI command interfaces. */
URB* XhcCreateCmdTrb(IN USB_XHCI_INSTANCE *Xhc, IN TRB_TEMPLATE *CmdTrb) | {
URB *Urb;
Urb = AllocateZeroPool (sizeof (URB));
if (Urb == NULL) {
return NULL;
}
Urb->Signature = XHC_URB_SIG;
Urb->Ring = &Xhc->CmdRing;
XhcSyncTrsRing (Xhc, Urb->Ring);
Urb->TrbNum = 1;
Urb->TrbStart = Urb->Ring->RingEnqueue;
CopyMem (Urb->TrbStart, CmdTrb, sizeof (TRB_TEMPLATE));
Urb... | tianocore/edk2 | C++ | Other | 4,240 |
/* If 16-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 16-bit boundary, then ASSERT(). */ | UINT16 EFIAPI IoOr16(IN UINTN Port, IN UINT16 OrData) | /* If 16-bit I/O port operations are not supported, then ASSERT(). If Port is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI IoOr16(IN UINTN Port, IN UINT16 OrData) | {
return IoWrite16 (Port, (UINT16)(IoRead16 (Port) | OrData));
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Start the PWM of the PWM module.
The */ | void PWMStart(unsigned long ulBase, unsigned long ulChannel) | /* Start the PWM of the PWM module.
The */
void PWMStart(unsigned long ulBase, unsigned long ulChannel) | {
unsigned long ulChannelTemp;
ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4);
xASSERT((ulBase == PWMA_BASE) || (ulBase == PWMB_BASE));
xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3)));
xHWREG(ulBase + PWM_PCR) |= (PWM_PCR_CH0EN << (ulChannelTemp << 3));
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* If the tolerance register is specified, 2 bytes are returned. Otherwise, 1 byte is returned. A negative value indicates an error occurred while reading the register. */ | static s32 ad525x_read(struct i2c_client *client, u8 reg) | /* If the tolerance register is specified, 2 bytes are returned. Otherwise, 1 byte is returned. A negative value indicates an error occurred while reading the register. */
static s32 ad525x_read(struct i2c_client *client, u8 reg) | {
struct dpot_data *data = i2c_get_clientdata(client);
if ((reg & AD525X_REG_TOL) || (data->max_pos > 256))
return i2c_smbus_read_word_data(client, (reg & 0xF8) |
((reg & 0x7) << 1));
else
return i2c_smbus_read_byte_data(client, reg);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* e1000_rlpml_set_vf - Set the maximum receive packet length @hw: pointer to the HW structure @max_size: value to assign to max frame size */ | void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size) | /* e1000_rlpml_set_vf - Set the maximum receive packet length @hw: pointer to the HW structure @max_size: value to assign to max frame size */
void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size) | {
struct e1000_mbx_info *mbx = &hw->mbx;
u32 msgbuf[2];
msgbuf[0] = E1000_VF_SET_LPE;
msgbuf[1] = max_size;
mbx->ops.write_posted(hw, msgbuf, 2);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* The GTK is stored in the last entry in the key table (the previous N_DEVICES entries are for the per-device PTKs). */ | int whc_set_gtk(struct wusbhc *wusbhc, u32 tkid, const void *gtk, size_t key_size) | /* The GTK is stored in the last entry in the key table (the previous N_DEVICES entries are for the per-device PTKs). */
int whc_set_gtk(struct wusbhc *wusbhc, u32 tkid, const void *gtk, size_t key_size) | {
struct whc *whc = wusbhc_to_whc(wusbhc);
int ret;
mutex_lock(&whc->mutex);
ret = whc_set_key(whc, whc->n_devices, tkid, gtk, key_size, true);
mutex_unlock(&whc->mutex);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function allocates memory for extended status code data, caches the report status code service, and registers events. */ | EFI_STATUS EFIAPI ReportStatusCodeLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | /* This function allocates memory for extended status code data, caches the report status code service, and registers events. */
EFI_STATUS EFIAPI ReportStatusCodeLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | {
EFI_STATUS Status;
InternalGetReportStatusCode ();
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
ReportStatusCodeLibVirtualAddressChange,
NULL,
&gEfiEventVirtualAddressChangeGuid,
&mReport... | tianocore/edk2 | C++ | Other | 4,240 |
/* Command response callback function for sd_ble_gatts_service_add BLE command.
Callback for decoding the output parameters and the command response return code. */ | static uint32_t gatts_service_add_rsp_dec(const uint8_t *p_buffer, uint16_t length) | /* Command response callback function for sd_ble_gatts_service_add BLE command.
Callback for decoding the output parameters and the command response return code. */
static uint32_t gatts_service_add_rsp_dec(const uint8_t *p_buffer, uint16_t length) | {
uint32_t result_code;
const uint32_t err_code =
ble_gatts_service_add_rsp_dec(p_buffer,
length,
(uint16_t *)mp_out_params[0],
&result_code);
APP_ERROR_CHECK(err_code);
return resul... | labapart/polymcu | C++ | null | 201 |
/* Note: Must not hold subscriber's server port lock, since tipc_send() will try to take the lock if the message is rejected and returned! */ | static void subscr_send_event(struct subscription *sub, u32 found_lower, u32 found_upper, u32 event, u32 port_ref, u32 node) | /* Note: Must not hold subscriber's server port lock, since tipc_send() will try to take the lock if the message is rejected and returned! */
static void subscr_send_event(struct subscription *sub, u32 found_lower, u32 found_upper, u32 event, u32 port_ref, u32 node) | {
struct iovec msg_sect;
msg_sect.iov_base = (void *)&sub->evt;
msg_sect.iov_len = sizeof(struct tipc_event);
sub->evt.event = htohl(event, sub->swap);
sub->evt.found_lower = htohl(found_lower, sub->swap);
sub->evt.found_upper = htohl(found_upper, sub->swap);
sub->evt.port.ref = htohl(port_ref, sub->swap);
sub-... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Returns 0 on success; or -ve the SET-IE command to the radio controller failed. */ | int uwb_rc_ie_rm(struct uwb_rc *uwb_rc, enum uwb_ie element_id) | /* Returns 0 on success; or -ve the SET-IE command to the radio controller failed. */
int uwb_rc_ie_rm(struct uwb_rc *uwb_rc, enum uwb_ie element_id) | {
int result = 0;
mutex_lock(&uwb_rc->ies_mutex);
uwb_rc_ie_cache_rm(uwb_rc, element_id);
if (uwb_rc->beaconing != -1)
result = uwb_rc_set_ie(uwb_rc, uwb_rc->ies);
mutex_unlock(&uwb_rc->ies_mutex);
return result;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Switch master clock source selection to slow clock. */ | uint32_t pmc_switch_mck_to_sclk(uint32_t ul_pres) | /* Switch master clock source selection to slow clock. */
uint32_t pmc_switch_mck_to_sclk(uint32_t ul_pres) | {
uint32_t ul_timeout;
PMC->PMC_MCKR = (PMC->PMC_MCKR & (~PMC_MCKR_CSS_Msk)) |
PMC_MCKR_CSS_SLOW_CLK;
for (ul_timeout = PMC_TIMEOUT; !(PMC->PMC_SR & PMC_SR_MCKRDY);
--ul_timeout) {
if (ul_timeout == 0) {
return 1;
}
}
PMC->PMC_MCKR = (PMC->PMC_MCKR & (~PMC_MCKR_PRES_Msk)) | ul_pres;
for (ul_timeout =... | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* This function unregisters and destroy all slave MTD objects which are attached to the given master MTD object. */ | int del_mtd_partitions(struct mtd_info *master) | /* This function unregisters and destroy all slave MTD objects which are attached to the given master MTD object. */
int del_mtd_partitions(struct mtd_info *master) | {
struct mtd_part *slave, *next;
list_for_each_entry_safe(slave, next, &mtd_partitions, list)
if (slave->master == master) {
list_del(&slave->list);
if (slave->registered)
del_mtd_device(&slave->mtd);
kfree(slave);
}
return 0;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Load the Sub Second Increment value in to Sub Second increment register */ | void synopGMAC_TS_subsecond_init(synopGMACdevice *gmacdev, u32 sub_sec_inc_value) | /* Load the Sub Second Increment value in to Sub Second increment register */
void synopGMAC_TS_subsecond_init(synopGMACdevice *gmacdev, u32 sub_sec_inc_value) | {
synopGMACWriteReg(gmacdev->MacBase,GmacTSSubSecIncr,(sub_sec_inc_value & GmacSSINCMsk));
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* However, if the two independent 64-bit keys are equal, then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property. */ | static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | /* However, if the two independent 64-bit keys are equal, then the DES3 operation is simply the same as DES. Implementers MUST reject keys that exhibit this property. */
static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) | {
int i, ret;
struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm);
const u8 *temp_key = key;
u32 *flags = &tfm->crt_flags;
if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE)) &&
(*flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
return -EINVAL;
}
for (i = 0; i < 2; i++, tem... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Function for creating an AD structure with default configuration for an EP OOB record.
This function creates an AD structure and initializes its fields with default content for EP OOB record payload. */ | static void ep_oob_specific_adv_data_create(ble_advdata_tk_value_t *const p_tk_value, ble_advdata_t *const p_ep_adv_data) | /* Function for creating an AD structure with default configuration for an EP OOB record.
This function creates an AD structure and initializes its fields with default content for EP OOB record payload. */
static void ep_oob_specific_adv_data_create(ble_advdata_tk_value_t *const p_tk_value, ble_advdata_t *const p_ep_a... | {
common_adv_data_create(p_tk_value, p_ep_adv_data);
p_ep_adv_data->p_sec_mgr_oob_flags = (uint8_t *) &sec_mgr_oob_flags;
} | labapart/polymcu | C++ | null | 201 |
/* Disable the transmission of frames on GMII/MII. GMAC transmit state machine is disabled after completion of transmission of current frame. */ | void synopGMAC_tx_disable(synopGMACdevice *gmacdev) | /* Disable the transmission of frames on GMII/MII. GMAC transmit state machine is disabled after completion of transmission of current frame. */
void synopGMAC_tx_disable(synopGMACdevice *gmacdev) | {
synopGMACClearBits(gmacdev->MacBase, GmacConfig, GmacTx);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / SET CONFIGURATION */ | static int dissect_usb_setup_set_configuration_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_) | /* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / SET CONFIGURATION */
static int dissect_usb_setup_set_configuration_request(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int offset, usb_conv_info_t *usb_conv_info _U_) | {
proto_tree_add_item(tree, hf_usb_bConfigurationValue, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_usb_index, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_usb_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
return o... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* return Mask value for the asserted flags. See "_cmp_status_flags". */ | uint32_t CMP_GetStatusFlags(CMP_Type *base) | /* return Mask value for the asserted flags. See "_cmp_status_flags". */
uint32_t CMP_GetStatusFlags(CMP_Type *base) | {
uint32_t ret32 = 0U;
if (0U != (CMP_SCR_CFR_MASK & base->SCR))
{
ret32 |= (uint32_t)kCMP_OutputRisingEventFlag;
}
if (0U != (CMP_SCR_CFF_MASK & base->SCR))
{
ret32 |= (uint32_t)kCMP_OutputFallingEventFlag;
}
if (0U != (CMP_SCR_COUT_MASK & base->SCR))
{
ret32... | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Sleep, either by using msleep() or if we are suspending, then use mdelay() to sleep. */ | static void dm9000_msleep(board_info_t *db, unsigned int ms) | /* Sleep, either by using msleep() or if we are suspending, then use mdelay() to sleep. */
static void dm9000_msleep(board_info_t *db, unsigned int ms) | {
if (db->in_suspend)
mdelay(ms);
else
msleep(ms);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Kill all bound sockets on a dropped device. */ | static void nr_kill_by_device(struct net_device *dev) | /* Kill all bound sockets on a dropped device. */
static void nr_kill_by_device(struct net_device *dev) | {
struct sock *s;
struct hlist_node *node;
spin_lock_bh(&nr_list_lock);
sk_for_each(s, node, &nr_list)
if (nr_sk(s)->device == dev)
nr_disconnect(s, ENETUNREACH);
spin_unlock_bh(&nr_list_lock);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Swap in a new table, returning the old one for the caller to destroy. */ | struct dm_table* dm_swap_table(struct mapped_device *md, struct dm_table *table) | /* Swap in a new table, returning the old one for the caller to destroy. */
struct dm_table* dm_swap_table(struct mapped_device *md, struct dm_table *table) | {
struct dm_table *map = ERR_PTR(-EINVAL);
struct queue_limits limits;
int r;
mutex_lock(&md->suspend_lock);
if (!dm_suspended_md(md))
goto out;
r = dm_calculate_queue_limits(table, &limits);
if (r) {
map = ERR_PTR(r);
goto out;
}
if (md->map &&
(dm_table_get_type(md->map) != dm_table_get_type(table... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* RTT configuration function.
Configure the RTT to generate a one second tick, which triggers the RTTINC interrupt. */ | void configure_rtt(void) | /* RTT configuration function.
Configure the RTT to generate a one second tick, which triggers the RTTINC interrupt. */
void configure_rtt(void) | {
rtt_sel_source(RTT, false);
rtt_init(RTT, 32768);
NVIC_DisableIRQ(RTT_IRQn);
NVIC_ClearPendingIRQ(RTT_IRQn);
NVIC_SetPriority(RTT_IRQn, 0);
NVIC_EnableIRQ(RTT_IRQn);
rtt_enable_interrupt(RTT, RTT_MR_RTTINCIEN);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Keep track of the last time we synchronized the time with the Phy */ | void phy_sync_ctrl_set_last_phy_sync_time(bs_time_t time) | /* Keep track of the last time we synchronized the time with the Phy */
void phy_sync_ctrl_set_last_phy_sync_time(bs_time_t time) | {
last_resync_time = time;
psc_program_next_event();
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Clear WDG interrupt when WDG init use WDG_IrqInit . */ | void WDG_IrqClear(void) | /* Clear WDG interrupt when WDG init use WDG_IrqInit . */
void WDG_IrqClear(void) | {
WDG_TypeDef* WDG = ((WDG_TypeDef *) WDG_REG_BASE);
u32 temp = WDG->VENDOR;
temp |= WDG_BIT_ISR_CLEAR;
WDG->VENDOR = temp;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Outputs a warning message, via the #GScanner message handler. */ | void g_scanner_warn(GScanner *scanner, const gchar *format,...) | /* Outputs a warning message, via the #GScanner message handler. */
void g_scanner_warn(GScanner *scanner, const gchar *format,...) | {
g_return_if_fail (scanner != NULL);
g_return_if_fail (format != NULL);
if (scanner->msg_handler)
{
va_list args;
gchar *string;
va_start (args, format);
string = g_strdup_vprintf (format, args);
va_end (args);
scanner->msg_handler (scanner, string, FALSE);
g_free (s... | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */ | static float clip3(float x, float y, float z) | /* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. */
static float clip3(float x, float y, float z) | {
return ((z < x) ? x : ((z > y) ? y : z));
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Disable I2C wake up of the specified I2C port.
The */ | void I2CWakeupDisable(unsigned long ulBase) | /* Disable I2C wake up of the specified I2C port.
The */
void I2CWakeupDisable(unsigned long ulBase) | {
xASSERT((ulBase == I2C0_BASE) || ((ulBase == I2C1_BASE)));
xHWREGB(ulBase + I2C_CON1) &= ~I2C_CON1_WUEN;
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* ibmvfc_release_tgt - Free memory allocated for a target @kref: kref struct */ | static void ibmvfc_release_tgt(struct kref *kref) | /* ibmvfc_release_tgt - Free memory allocated for a target @kref: kref struct */
static void ibmvfc_release_tgt(struct kref *kref) | {
struct ibmvfc_target *tgt = container_of(kref, struct ibmvfc_target, kref);
kfree(tgt);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods. */ | NMI_API sint8 m2m_wifi_set_lsn_int(tstrM2mLsnInt *pstrM2mLsnInt) | /* Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods. */
NMI_API sint8 m2m_wifi_set_lsn_int(tstrM2mLsnInt *pstrM2mLsnInt) | {
tstrM2mLsnInt* pstrTmpM2mLsnInt = &guCtrlStruct.strM2mLsnInt;
m2m_memcpy((uint8*)pstrTmpM2mLsnInt, (uint8*)pstrM2mLsnInt, sizeof(tstrM2mLsnInt));
pstrTmpM2mLsnInt->u16LsnInt = NM_BSP_B_L_16(pstrTmpM2mLsnInt->u16LsnInt);
return hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_LSN_INT,
(uint8*)pstrTmpM2mLsnInt, sizeof(ts... | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Writes a pre-processed HMAC key to the digest registers in the SHA/MD5 module. */ | void SHAMD5HMACPPKeySet(uint32_t ui32Base, uint8_t *pui8Src) | /* Writes a pre-processed HMAC key to the digest registers in the SHA/MD5 module. */
void SHAMD5HMACPPKeySet(uint32_t ui32Base, uint8_t *pui8Src) | {
uint32_t ui32Idx;
ASSERT(ui32Base == SHAMD5_BASE);
for(ui32Idx = 0; ui32Idx < 64; ui32Idx += 4)
{
HWREG(ui32Base + SHAMD5_O_ODIGEST_A + ui32Idx) =
*((uint32_t *) (pui8Src + ui32Idx));
}
HWREG(ui32Base + SHAMD5_O_MODE) |= (SHAMD5_MODE_HMAC_OUTE... | micropython/micropython | C++ | Other | 18,334 |
/* Get USI-SPI transfer status.
bit 0 : USI_SPI_ACTIVITY */ | u32 USI_SSI_GetTransStatus(USI_TypeDef *usi_dev) | /* Get USI-SPI transfer status.
bit 0 : USI_SPI_ACTIVITY */
u32 USI_SSI_GetTransStatus(USI_TypeDef *usi_dev) | {
return usi_dev->SPI_TRANS_STATUS;
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Unload the RamDiskDxe driver and its configuration form. */ | EFI_STATUS EFIAPI RamDiskDxeUnload(IN EFI_HANDLE ImageHandle) | /* Unload the RamDiskDxe driver and its configuration form. */
EFI_STATUS EFIAPI RamDiskDxeUnload(IN EFI_HANDLE ImageHandle) | {
EFI_STATUS Status;
RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
Status = gBS->HandleProtocol (
mRamDiskHandle,
&gEfiCallerIdGuid,
(VOID **)&ConfigPrivate
);
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (Co... | tianocore/edk2 | C++ | Other | 4,240 |
/* Command line prompt. Caller must verify that only the enabled board can run this. */ | void CN0429_CmdPrompt(void) | /* Command line prompt. Caller must verify that only the enabled board can run this. */
void CN0429_CmdPrompt(void) | {
static uint8_t count = 0;
if (count == 0) {
UART_TX("Welcome to CN0429!" _EOS);
UART_TX("Type <help> to see available commands..." _EOS);
count++;
}
} | analogdevicesinc/EVAL-ADICUP3029 | C++ | Other | 36 |
/* reset GPIO port
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */ | void gpio_deinit(uint32_t port) | /* reset GPIO port
, V1.0.0, firmware for GD32F1x0(x=3,5) , V2.0.0, firmware for GD32F1x0(x=3,5,7,9) , V3.0.0, firmware update for GD32F1x0(x=3,5,7,9) */
void gpio_deinit(uint32_t port) | {
if(GPIOA == port){
rcu_periph_reset_enable(RCU_GPIOARST);
rcu_periph_reset_disable(RCU_GPIOARST);
}else if(GPIOB == port){
rcu_periph_reset_enable(RCU_GPIOBRST);
rcu_periph_reset_disable(RCU_GPIOBRST);
}else if(GPIOC == port){
rcu_periph_reset_enable(RCU_GPIOCRST);
... | liuxuming/trochili | C++ | Apache License 2.0 | 132 |
/* UART MSP De-Initialization This function freeze the hardware resources used in this example. */ | void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) | /* UART MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart) | {
if(huart->Instance==USART1)
{
__HAL_RCC_USART1_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
}
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Finds the protocol instance for the requested handle and protocol. Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. */ | PROTOCOL_INTERFACE* MmFindProtocolInterface(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface) | /* Finds the protocol instance for the requested handle and protocol. Note: This function doesn't do parameters checking, it's caller's responsibility to pass in valid parameters. */
PROTOCOL_INTERFACE* MmFindProtocolInterface(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface) | {
PROTOCOL_INTERFACE *Prot;
PROTOCOL_ENTRY *ProtEntry;
LIST_ENTRY *Link;
Prot = NULL;
ProtEntry = MmFindProtocolEntry (Protocol, FALSE);
if (ProtEntry != NULL) {
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
Prot = CR (Link, PROTO... | tianocore/edk2 | C++ | Other | 4,240 |
/* Initialize the memory slab using k_mem_slab_init() and allocates/frees blocks.
Initialize 3 memory blocks of block size 8 bytes using */ | ZTEST(mslab_api, test_mslab_kinit) | /* Initialize the memory slab using k_mem_slab_init() and allocates/frees blocks.
Initialize 3 memory blocks of block size 8 bytes using */
ZTEST(mslab_api, test_mslab_kinit) | {
zassert_equal(k_mem_slab_init(&mslab, tslab, BLK_SIZE + 1, BLK_NUM),
-EINVAL, NULL);
k_mem_slab_init(&mslab, tslab, BLK_SIZE, BLK_NUM);
zassert_equal(k_mem_slab_num_used_get(&mslab), 0);
zassert_equal(k_mem_slab_num_free_get(&mslab), BLK_NUM);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Enable PIO output write for synchronous data output. */ | void pio_enable_output_write(Pio *p_pio, const uint32_t ul_mask) | /* Enable PIO output write for synchronous data output. */
void pio_enable_output_write(Pio *p_pio, const uint32_t ul_mask) | {
p_pio->PIO_OWER = ul_mask;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Used for looking up and old ciphering counter value in the counter_map tree. */ | static gboolean rlc_find_old_counter(gpointer key, gpointer value, gpointer data) | /* Used for looking up and old ciphering counter value in the counter_map tree. */
static gboolean rlc_find_old_counter(gpointer key, gpointer value, gpointer data) | {
return TRUE;
}
((guint32*)data)[1] = ((guint32*)value)[0];
((guint32*)data)[2] = ((guint32*)value)[1];
return FALSE;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* iwl_print_last_event_logs - Dump the newest # of event log to syslog */ | static void iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity, u32 num_wraps, u32 next_entry, u32 size, u32 mode) | /* iwl_print_last_event_logs - Dump the newest # of event log to syslog */
static void iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity, u32 num_wraps, u32 next_entry, u32 size, u32 mode) | {
if (num_wraps) {
if (next_entry < size) {
iwl_print_event_log(priv,
capacity - (size - next_entry),
size - next_entry, mode);
iwl_print_event_log(priv, 0,
next_entry, mode);
} else
iwl_print_event_log(priv, next_entry - size,
size, mode);
} else {
if (next_entry < size)
i... | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Write a data buffer to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Buffer Step2)
This function is always used in thread mode. */ | unsigned long xI2CMasterWriteBufS2(unsigned long ulBase, unsigned char *pucDataBuf, unsigned long ulLen, xtBoolean bEndTransmition) | /* Write a data buffer to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Buffer Step2)
This function is always used in thread mode. */
unsigned long xI2CMasterWriteBufS2(unsigned long ulBase, unsigned char *pucDataBuf, unsigned long ulLen, xtBoolean bEnd... | {
unsigned long i;
unsigned long ulStatus;
xASSERT((ulBase == I2C0_BASE));
xASSERT(pucDataBuf);
for(i = 0; i < ulLen - 1; i++)
{
ulStatus = I2CByteSend(ulBase, *pucDataBuf++);
if(!(ulStatus == I2C_I2STAT_M_TX_DAT_ACK))
{
I2CStopSend(ulBase);
return... | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function checks whether the given ID is supported or not, using PSCI_FEATURES command.PSCI_FEATURES is supported from version 1.0 onwards. */ | static int psci_features_check(unsigned long function_id) | /* This function checks whether the given ID is supported or not, using PSCI_FEATURES command.PSCI_FEATURES is supported from version 1.0 onwards. */
static int psci_features_check(unsigned long function_id) | {
if (!(PSCI_VERSION_MAJOR(psci_data.ver) >= 1)) {
LOG_ERR("Function ID %lu not supported", function_id);
return -ENOTSUP;
}
return psci_data.invoke_psci_fn(PSCI_FN_NATIVE(1_0, PSCI_FEATURES), function_id, 0, 0);
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* Receive a buffer of
This blocking function will receive a block of */ | enum status_code uart_read_buffer_wait(struct uart_module *const module, uint8_t *rx_data, uint16_t length) | /* Receive a buffer of
This blocking function will receive a block of */
enum status_code uart_read_buffer_wait(struct uart_module *const module, uint8_t *rx_data, uint16_t length) | {
while(length--)
uart_read_wait(module, rx_data++);
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* Add the image execution information table if it is not in system configuration table. */ | VOID EFIAPI OnReadyToBoot(IN EFI_EVENT Event, IN VOID *Context) | /* Add the image execution information table if it is not in system configuration table. */
VOID EFIAPI OnReadyToBoot(IN EFI_EVENT Event, IN VOID *Context) | {
EFI_IMAGE_EXECUTION_INFO_TABLE *ImageExeInfoTable;
UINTN ImageExeInfoTableSize;
EfiGetSystemConfigurationTable (&gEfiImageSecurityDatabaseGuid, (VOID **)&ImageExeInfoTable);
if (ImageExeInfoTable != NULL) {
return;
}
ImageExeInfoTableSize = sizeof (EFI_IMAGE_EXECUTION_INFO_T... | tianocore/edk2 | C++ | Other | 4,240 |
/* Enable time stamp snapshot for IPV4 frames. When enabled, time stamp snapshot is taken for IPV4 frames Reserved when "Advanced Time Stamp" is not selected */ | void synopGMAC_TS_IPV4_enable(synopGMACdevice *gmacdev) | /* Enable time stamp snapshot for IPV4 frames. When enabled, time stamp snapshot is taken for IPV4 frames Reserved when "Advanced Time Stamp" is not selected */
void synopGMAC_TS_IPV4_enable(synopGMACdevice *gmacdev) | {
synopGMACSetBits(gmacdev->MacBase, GmacTSControl, GmacTSIPV4ENA);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* While checking the dmi string infomation, just checking the product serial key should be enough, as this will always have a VMware specific string when running under VMware hypervisor. */ | int vmware_platform(void) | /* While checking the dmi string infomation, just checking the product serial key should be enough, as this will always have a VMware specific string when running under VMware hypervisor. */
int vmware_platform(void) | {
if (cpu_has_hypervisor) {
unsigned int eax, ebx, ecx, edx;
char hyper_vendor_id[13];
cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &ebx, &ecx, &edx);
memcpy(hyper_vendor_id + 0, &ebx, 4);
memcpy(hyper_vendor_id + 4, &ecx, 4);
memcpy(hyper_vendor_id + 8, &edx, 4);
hyper_vendor_id[12] = '\0';
if (!strcmp(hyper_v... | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.