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
/* TIM_PWM MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim_pwm)
/* TIM_PWM MSP Initialization This function configures the hardware resources used in this example. */ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim_pwm)
{ if(htim_pwm->Instance==TIM1) { __HAL_RCC_TIM1_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function returns %1 if @offs was in the last write to the LEB whose data is in @buf, otherwise %0 is returned. The determination is made by checking for subsequent empty space starting from the next min_io_size boundary (or a bit less than the common header size if min_io_size is one). */
static int is_last_write(const struct ubifs_info *c, void *buf, int offs)
/* This function returns %1 if @offs was in the last write to the LEB whose data is in @buf, otherwise %0 is returned. The determination is made by checking for subsequent empty space starting from the next min_io_size boundary (or a bit less than the common header size if min_io_size is one). */ static int is_last_write(const struct ubifs_info *c, void *buf, int offs)
{ int empty_offs; int check_len; uint8_t *p; if (c->min_io_size == 1) { check_len = c->leb_size - offs; p = buf + check_len; for (; check_len > 0; check_len--) if (*--p != 0xff) break; if (check_len > UBIFS_MAX_NODE_SZ) return 0; return 1; } empty_offs = ALIGN(offs + 1, c->min_io_size); check_len = c->leb_size - empty_offs; p = buf + empty_offs - offs; for (; check_len > 0; check_len--) if (*p++ != 0xff) return 0; return 1; }
EmcraftSystems/u-boot
C++
Other
181
/* We have received an interrupt while doing DMA transmissions. It shouldn't happen. Scream loudly if it does. */
static void z8530_dma_tx(struct z8530_channel *chan)
/* We have received an interrupt while doing DMA transmissions. It shouldn't happen. Scream loudly if it does. */ static void z8530_dma_tx(struct z8530_channel *chan)
{ if(!chan->dma_tx) { printk(KERN_WARNING "Hey who turned the DMA off?\n"); z8530_tx(chan); return; } printk(KERN_ERR "DMA tx - bogus event!\n"); z8530_tx(chan); }
robutest/uclinux
C++
GPL-2.0
60
/* This internal function only deal with Unicode character which maps to a valid hexadecimal ASII character, i.e. '0' to '9', 'a' to 'f' or 'A' to 'F'. For other ASCII character, the value returned does not make sense. */
UINTN EFIAPI InternalAsciiHexCharToUintn(IN CHAR8 Char)
/* This internal function only deal with Unicode character which maps to a valid hexadecimal ASII character, i.e. '0' to '9', 'a' to 'f' or 'A' to 'F'. For other ASCII character, the value returned does not make sense. */ UINTN EFIAPI InternalAsciiHexCharToUintn(IN CHAR8 Char)
{ if (InternalIsDecimalDigitCharacter (Char)) { return Char - '0'; } return (10 + AsciiCharToUpper (Char) - 'A'); }
tianocore/edk2
C++
Other
4,240
/* This file is part of the Simba project. */
static q20_11_t frequency_to_phase_increment(float frequency, size_t waveform_length, int sample_rate)
/* This file is part of the Simba project. */ static q20_11_t frequency_to_phase_increment(float frequency, size_t waveform_length, int sample_rate)
{ return FLOAT_TO_Q20_11(((frequency * waveform_length) / sample_rate)); }
eerimoq/simba
C++
Other
337
/* Erases the flash sectors encompassed by parameters passed into function. This function erases the appropriate number of flash sectors based on the desired start address and length. */
status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
/* Erases the flash sectors encompassed by parameters passed into function. This function erases the appropriate number of flash sectors based on the desired start address and length. */ status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key)
{ if (get_rom_api_version() == 0u) { function_command_option_t runCmdFuncOption; runCmdFuncOption.commandAddr = 0x1300413bU; return runCmdFuncOption.eraseCommand(config, start, lengthInBytes, key); } else { return VERSION1_FLASH_API_TREE->flash_erase(config, start, lengthInBytes, key); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
/* Allocates the number bytes specified by AllocationSize of a certain pool type and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */ VOID* InternalAllocatePool(IN EFI_MEMORY_TYPE MemoryType, IN UINTN AllocationSize)
{ EFI_STATUS Status; VOID *Memory; Memory = NULL; Status = gMmst->MmAllocatePool (MemoryType, AllocationSize, &Memory); if (EFI_ERROR (Status)) { Memory = NULL; } return Memory; }
tianocore/edk2
C++
Other
4,240
/* Releases a level 2 page table Releases a level 2 page table, marking it as no longer in use. From that point on, it can be re-used for mappings in another 1 MB virtual address range. This function is called whenever it is determined during an unmap call at run-time that the page table entry count in the respective page table has reached 0. */
static void arm_mmu_release_l2_table(struct arm_mmu_l2_page_table *l2_page_table)
/* Releases a level 2 page table Releases a level 2 page table, marking it as no longer in use. From that point on, it can be re-used for mappings in another 1 MB virtual address range. This function is called whenever it is determined during an unmap call at run-time that the page table entry count in the respective page table has reached 0. */ static void arm_mmu_release_l2_table(struct arm_mmu_l2_page_table *l2_page_table)
{ uint32_t l2_page_table_index = ARM_MMU_L2_PT_INDEX(l2_page_table); l2_page_tables_status[l2_page_table_index].l1_index = 0; if (arm_mmu_l2_tables_free == 0) { arm_mmu_l2_next_free_table = l2_page_table_index; } ++arm_mmu_l2_tables_free; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Function for processing data written by the peer to the DFU Packet Characteristic. */
static void on_dfu_pkt_write(ble_dfu_t *p_dfu, ble_dfu_evt_t *p_evt)
/* Function for processing data written by the peer to the DFU Packet Characteristic. */ static void on_dfu_pkt_write(ble_dfu_t *p_dfu, ble_dfu_evt_t *p_evt)
{ switch (m_pkt_type) { case PKT_TYPE_START: start_data_process(p_dfu, p_evt); break; case PKT_TYPE_INIT: init_data_process(p_dfu, p_evt); break; case PKT_TYPE_FIRMWARE_DATA: app_data_process(p_dfu, p_evt); break; default: break; } }
labapart/polymcu
C++
null
201
/* Checks if a bus off or bus heavy situation occurred. */
static bool PCanUsbIsBusError(void)
/* Checks if a bus off or bus heavy situation occurred. */ static bool PCanUsbIsBusError(void)
{ bool result = false; TPCANStatus status; status = PCanUsbLibFuncGetStatus(pCanUsbChannelLookup[pCanUsbSettings.channel]); if ((status == PCAN_ERROR_BUSOFF) || (status == PCAN_ERROR_BUSHEAVY)) { result = true; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Convert text to the binary representation of a device path. */
EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDevicePath(IN CONST CHAR16 *TextDevicePath)
/* Convert text to the binary representation of a device path. */ EFI_DEVICE_PATH_PROTOCOL* EFIAPI ConvertTextToDevicePath(IN CONST CHAR16 *TextDevicePath)
{ if (mDevicePathLibDevicePathFromText == NULL) { mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid); } if (mDevicePathLibDevicePathFromText != NULL) { return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath); } else { return NULL; } }
tianocore/edk2
C++
Other
4,240
/* On rev. C we need to set the pause threshold */
static void mcs7830_rev_C_fixup(struct usbnet *dev)
/* On rev. C we need to set the pause threshold */ static void mcs7830_rev_C_fixup(struct usbnet *dev)
{ u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT; int retry; for (retry = 0; retry < 2; retry++) { if (mcs7830_get_rev(dev) == 2) { dev_info(&dev->udev->dev, "applying rev.C fixup\n"); mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD, 1, &pause_threshold); } msleep(1); } }
robutest/uclinux
C++
GPL-2.0
60
/* tree_destroy - destroy an RB-tree. @root: the root of the tree to destroy */
static void tree_destroy(struct rb_root *root)
/* tree_destroy - destroy an RB-tree. @root: the root of the tree to destroy */ static void tree_destroy(struct rb_root *root)
{ struct rb_node *rb; struct ubi_wl_entry *e; rb = root->rb_node; while (rb) { if (rb->rb_left) rb = rb->rb_left; else if (rb->rb_right) rb = rb->rb_right; else { e = rb_entry(rb, struct ubi_wl_entry, u.rb); rb = rb_parent(rb); if (rb) { if (rb->rb_left == &e->u.rb) rb->rb_left = NULL; else rb->rb_right = NULL; } kmem_cache_free(ubi_wl_entry_slab, e); } } }
robutest/uclinux
C++
GPL-2.0
60
/* converts an integer to a "floating point byte", represented as (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if eeeee != 0 and (xxx) otherwise. */
int luaO_int2fb(unsigned int x)
/* converts an integer to a "floating point byte", represented as (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if eeeee != 0 and (xxx) otherwise. */ int luaO_int2fb(unsigned int x)
{ x = (x+1) >> 1; e++; } return ((e+1) << 3) | (cast_int(x) - 8); }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* This function will initial FM3 Easy Kit board. */
void rt_hw_board_init(void)
/* This function will initial FM3 Easy Kit board. */ void rt_hw_board_init(void)
{ SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); rt_hw_serial_init(); rt_console_set_device(RT_CONSOLE_DEVICE_NAME); rt_hw_nand_init(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns 0 on success, -errno in error cases. */
int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, const void *buf, int count)
/* Returns 0 on success, -errno in error cases. */ int bdrv_pwrite_sync(BlockDriverState *bs, int64_t offset, const void *buf, int count)
{ int ret; ret = bdrv_pwrite(bs, offset, buf, count); if (ret < 0) { return ret; } if (bs->enable_write_cache) { bdrv_flush(bs); } return 0; }
ve3wwg/teensy3_qemu
C
Other
15
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_EnableEP(U32 EPNum)
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_EnableEP(U32 EPNum)
{ EP_Status(EPNum, EP_TX_NAK | EP_RX_VALID); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Initialize a new lock from an existing file_lock structure. */
void __locks_copy_lock(struct file_lock *new, const struct file_lock *fl)
/* Initialize a new lock from an existing file_lock structure. */ void __locks_copy_lock(struct file_lock *new, const struct file_lock *fl)
{ new->fl_owner = fl->fl_owner; new->fl_pid = fl->fl_pid; new->fl_file = NULL; new->fl_flags = fl->fl_flags; new->fl_type = fl->fl_type; new->fl_start = fl->fl_start; new->fl_end = fl->fl_end; new->fl_ops = NULL; new->fl_lmops = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Look up the serial structure. If it is found and it hasn't been disconnected, return with its disc_mutex held and its refcount incremented. Otherwise return NULL. */
struct usb_serial* usb_serial_get_by_index(unsigned index)
/* Look up the serial structure. If it is found and it hasn't been disconnected, return with its disc_mutex held and its refcount incremented. Otherwise return NULL. */ struct usb_serial* usb_serial_get_by_index(unsigned index)
{ struct usb_serial *serial; mutex_lock(&table_lock); serial = serial_table[index]; if (serial) { mutex_lock(&serial->disc_mutex); if (serial->disconnected) { mutex_unlock(&serial->disc_mutex); serial = NULL; } else { kref_get(&serial->kref); } } mutex_unlock(&table_lock); return serial; }
robutest/uclinux
C++
GPL-2.0
60
/* Finally, some KGDB code :-) Weak aliases for breakpoint management, can be overriden by architectures when needed: */
int __weak kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
/* Finally, some KGDB code :-) Weak aliases for breakpoint management, can be overriden by architectures when needed: */ int __weak kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
{ int err; err = probe_kernel_read(saved_instr, (char *)addr, BREAK_INSTR_SIZE); if (err) return err; return probe_kernel_write((char *)addr, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function validates platform interrupt flags for type 4 structure. */
STATIC VOID EFIAPI ValidatePlatInterrupt(IN UINT8 *Ptr, IN VOID *Context)
/* This function validates platform interrupt flags for type 4 structure. */ STATIC VOID EFIAPI ValidatePlatInterrupt(IN UINT8 *Ptr, IN VOID *Context)
{ if ((*PccSubspaceType == EFI_ACPI_6_4_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC) && ((*PccGlobalFlags & EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT) != EFI_ACPI_6_4_PCCT_FLAGS_PLATFORM_INTERRUPT)) { IncrementErrorCount (); Print ( L"\nError: Global Platform interrupt flag must be set to 1" \ L" if a PCC type 4 structure is present in PCCT." ); } }
tianocore/edk2
C++
Other
4,240
/* Register a function as FLASH transfer completion callback. */
int32_t flash_register_callback(struct flash_descriptor *flash, const enum flash_cb_type type, flash_cb_t func)
/* Register a function as FLASH transfer completion callback. */ int32_t flash_register_callback(struct flash_descriptor *flash, const enum flash_cb_type type, flash_cb_t func)
{ ASSERT(flash); switch (type) { case FLASH_CB_READY: flash->callbacks.cb_ready = func; break; case FLASH_CB_ERROR: flash->callbacks.cb_error = func; break; default: return ERR_INVALID_ARG; } _flash_set_irq_state(&flash->dev, (enum _flash_cb_type)type, NULL != func); return ERR_NONE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ext4_idx_store_pblock: stores a large physical block number into an index struct, breaking it into parts */
static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
/* ext4_idx_store_pblock: stores a large physical block number into an index struct, breaking it into parts */ static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
{ ix->ei_leaf_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff)); ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); }
robutest/uclinux
C++
GPL-2.0
60
/* See if a message has bee received by a FIFO. */
int32_t can_ctrl_is_fifo_rdy(struct can_ctrl_dev *dev, uint8_t fifo_nr, bool *status)
/* See if a message has bee received by a FIFO. */ int32_t can_ctrl_is_fifo_rdy(struct can_ctrl_dev *dev, uint8_t fifo_nr, bool *status)
{ int32_t ret; uint32_t temp; ret = can_ctrl_sfr_word_read(dev, CAN_CTRL_REG_FIFOSTA(fifo_nr), &temp); if(ret != 0) return ret; if(FIFOSTA_TFNRFNIF_MASK & temp) *status = true; else *status = false; return ret; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Creates and initializes a new block including its memory allocation on the heap. A block consists of the actual memory to hold the block data and is preceded by an element of size_t, where the size of the block is written to: memPtr -> -------- */
static void * TbxMemPoolBlockCreate(size_t size)
/* Creates and initializes a new block including its memory allocation on the heap. A block consists of the actual memory to hold the block data and is preceded by an element of size_t, where the size of the block is written to: memPtr -> -------- */ static void * TbxMemPoolBlockCreate(size_t size)
{ void * result = NULL; void * blockMemPtr; TBX_ASSERT(size > 0U); if (size > 0U) { blockMemPtr = TbxHeapAllocate(sizeof(size_t) + size); if (blockMemPtr != NULL) { result = blockMemPtr; size_t * blockSizeArray = blockMemPtr; blockSizeArray[0U] = size; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Returns 0 if current has the requested access, error code otherwise */
static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
/* Returns 0 if current has the requested access, error code otherwise */ static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
{ int may; switch (cmd) { case IPC_STAT: case MSG_STAT: may = MAY_READ; break; case IPC_SET: case IPC_RMID: may = MAY_READWRITE; break; case IPC_INFO: case MSG_INFO: return 0; default: return -EINVAL; } return smk_curacc_msq(msq, may); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Dumps the current css2 stylesheet to a file. */
void cr_stylesheet_dump(CRStyleSheet *a_this, FILE *a_fp)
/* Dumps the current css2 stylesheet to a file. */ void cr_stylesheet_dump(CRStyleSheet *a_this, FILE *a_fp)
{ gchar *str = NULL ; g_return_if_fail (a_this); str = cr_stylesheet_to_string (a_this) ; if (str) { fprintf (a_fp, "%s", str) ; g_free (str) ; str = NULL ; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* sweep a list until a live object (or end of list) */
static GCObject** sweeptolive(lua_State *L, GCObject **p)
/* sweep a list until a live object (or end of list) */ static GCObject** sweeptolive(lua_State *L, GCObject **p)
{ p = sweeplist(L, p, 1, NULL); } while (p == old); return p; }
Nicholas3388/LuaNode
C++
Other
1,055
/* Initializes the tim Time Base Unit peripheral according to the specified parameters in the init_struct. */
void TIM_TimeBaseInit(TIM_TypeDef *tim, TIM_TimeBaseInitTypeDef *init_struct)
/* Initializes the tim Time Base Unit peripheral according to the specified parameters in the init_struct. */ void TIM_TimeBaseInit(TIM_TypeDef *tim, TIM_TimeBaseInitTypeDef *init_struct)
{ MODIFY_REG(tim->CR1, TIM_CR1_CKD, init_struct->TIM_ClockDivision); if ((tim == TIM1) || (tim == TIM2) || (tim == TIM3) || (tim == TIM4) || (tim == TIM5) || (tim == TIM8)) MODIFY_REG(tim->CR1, TIM_CR1_CMS | TIM_CR1_DIR, init_struct->TIM_CounterMode); if ((tim == TIM1) || (tim == TIM8) ) MODIFY_REG(tim->RCR, TIM_RCR_REP, init_struct->TIM_RepetitionCounter); WRITE_REG(tim->ARR, init_struct->TIM_Period); WRITE_REG(tim->PSC, init_struct->TIM_Prescaler); WRITE_REG(tim->EGR, TIM_PSCReloadMode_Immediate); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This fucntion returns 1 when there is Error Attention in the Host Attention Register and returns 0 otherwise. */
static int lpfc_sli_eratt_read(struct lpfc_hba *phba)
/* This fucntion returns 1 when there is Error Attention in the Host Attention Register and returns 0 otherwise. */ static int lpfc_sli_eratt_read(struct lpfc_hba *phba)
{ uint32_t ha_copy; ha_copy = readl(phba->HAregaddr); if (ha_copy & HA_ERATT) { lpfc_sli_read_hs(phba); if ((HS_FFER1 & phba->work_hs) && ((HS_FFER2 | HS_FFER3 | HS_FFER4 | HS_FFER5 | HS_FFER6 | HS_FFER7) & phba->work_hs)) { phba->hba_flag |= DEFER_ERATT; writel(0, phba->HCregaddr); readl(phba->HCregaddr); } phba->work_ha |= HA_ERATT; phba->hba_flag |= HBA_ERATT_HANDLED; return 1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function will return the length of a string, which terminate will null character. */
rt_size_t rt_strlen(const char *s)
/* This function will return the length of a string, which terminate will null character. */ rt_size_t rt_strlen(const char *s)
{ const char *sc = RT_NULL; for (sc = s; *sc != '\0'; ++sc) ; return sc - s; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Clear API string cache. (Entries cannot be empty, so fill them with a non-collectable string.) */
void luaS_clearcache(global_State *g)
/* Clear API string cache. (Entries cannot be empty, so fill them with a non-collectable string.) */ void luaS_clearcache(global_State *g)
{ if (iswhite(g->strcache[i][j])) g->strcache[i][j] = g->memerrmsg; } }
Nicholas3388/LuaNode
C++
Other
1,055
/* CRC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
/* CRC MSP Initialization This function configures the hardware resources used in this example. */ void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
{ if(hcrc->Instance==CRC) { __HAL_RCC_CRC_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* nfs_set_page_tag_locked - Tag a request as locked @req: */
int nfs_set_page_tag_locked(struct nfs_page *req)
/* nfs_set_page_tag_locked - Tag a request as locked @req: */ int nfs_set_page_tag_locked(struct nfs_page *req)
{ if (!nfs_lock_request_dontget(req)) return 0; if (req->wb_page != NULL) radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get number of queued messages in a Message Queue. */
uint32_t osMessageQueueGetCount(osMessageQueueId_t mq_id)
/* Get number of queued messages in a Message Queue. */ uint32_t osMessageQueueGetCount(osMessageQueueId_t mq_id)
{ count = svcRtxMessageQueueGetCount(mq_id); } else { count = __svcMessageQueueGetCount(mq_id); } return count; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Deinitializes the Alternate Functions (remap, event control and EXTI configuration) registers to their default reset values. */
void GPIO_AFIODeInit()
/* Deinitializes the Alternate Functions (remap, event control and EXTI configuration) registers to their default reset values. */ void GPIO_AFIODeInit()
{ GPIOA->AFRL = 0xFFFFFFFF; GPIOA->AFRH = 0xF00FFFFF; GPIOB->AFRL = 0xFFFFFFFF; GPIOB->AFRH = 0xFFFFFFFF; GPIOC->AFRL = 0xFFFFFFFF; GPIOC->AFRH = 0xFFFFFFFF; GPIOD->AFRL = 0xFFFFFFFF; GPIOD->AFRH = 0xFFFFFFFF; GPIOE->AFRL = 0xFFFFFFFF; GPIOE->AFRH = 0xFFFFFFFF; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function reads the last device id the IOMMU has to handle from the PCI capability header for this IOMMU */
static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr)
/* This function reads the last device id the IOMMU has to handle from the PCI capability header for this IOMMU */ static int __init find_last_devid_on_pci(int bus, int dev, int fn, int cap_ptr)
{ u32 cap; cap = read_pci_config(bus, dev, fn, cap_ptr+MMIO_RANGE_OFFSET); update_last_devid(calc_devid(MMIO_GET_BUS(cap), MMIO_GET_LD(cap))); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets the number of samples in the transmit FIFO. */
unsigned long I2STxFIFOLevelGet(unsigned long ulBase)
/* Gets the number of samples in the transmit FIFO. */ unsigned long I2STxFIFOLevelGet(unsigned long ulBase)
{ ASSERT(ulBase == I2S0_BASE); return(HWREG(ulBase + I2S_O_TXLEV)); }
watterott/WebRadio
C++
null
71
/* param base SRC peripheral base address. param Mask value of status flags to be cleared, see to #_src_reset_status_flags. */
void SRC_ClearResetStatusFlags(SRC_Type *base, uint32_t flags)
/* param base SRC peripheral base address. param Mask value of status flags to be cleared, see to #_src_reset_status_flags. */ void SRC_ClearResetStatusFlags(SRC_Type *base, uint32_t flags)
{ uint32_t tmp32 = base->SRSR; if (0U != (SRC_SRSR_TSR_MASK & flags)) { tmp32 &= ~SRC_SRSR_TSR_MASK; } if (0U != (SRC_SRSR_W1C_BITS_MASK & flags)) { tmp32 |= (SRC_SRSR_W1C_BITS_MASK & flags); } base->SRSR = tmp32; }
eclipse-threadx/getting-started
C++
Other
310
/* Atomically swap in the new signal mask, and wait for a signal. */
SYSCALL_DEFINE3(sigsuspend, int, history0, int, history1, old_sigset_t, mask)
/* Atomically swap in the new signal mask, and wait for a signal. */ SYSCALL_DEFINE3(sigsuspend, int, history0, int, history1, old_sigset_t, mask)
{ mask &= _BLOCKABLE; spin_lock_irq(&current->sighand->siglock); current->saved_sigmask = current->blocked; siginitset(&current->blocked, mask); recalc_sigpending(); spin_unlock_irq(&current->sighand->siglock); set_current_state(TASK_INTERRUPTIBLE); schedule(); set_thread_flag(TIF_RESTORE_SIGMASK); return -ERESTARTNOHAND; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Update the "BSD Compress" dictionary on the receiver for incompressible data by pretending to compress the incoming data. */
static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto)
/* Update the "BSD Compress" dictionary on the receiver for incompressible data by pretending to compress the incoming data. */ static void bsd_incomp(void *state, struct sk_buff *skb_in, int proto)
{ bsd_compress (state, skb_in, NULL, proto); }
robutest/uclinux
C++
GPL-2.0
60
/* Destroy an MTD device which was created for a map device. Make sure the MTD device is already unregistered before calling this */
void map_destroy(struct mtd_info *mtd)
/* Destroy an MTD device which was created for a map device. Make sure the MTD device is already unregistered before calling this */ void map_destroy(struct mtd_info *mtd)
{ struct map_info *map = mtd->priv; if (map->fldrv->destroy) map->fldrv->destroy(mtd); module_put(map->fldrv->module); kfree(mtd); }
robutest/uclinux
C++
GPL-2.0
60
/* param tcd Point to the TCD structure. param mask The mask of interrupt source to be set. Users need to use the defined edma_interrupt_enable_t type. */
void EDMA_TcdEnableInterrupts(edma_tcd_t *tcd, uint32_t mask)
/* param tcd Point to the TCD structure. param mask The mask of interrupt source to be set. Users need to use the defined edma_interrupt_enable_t type. */ void EDMA_TcdEnableInterrupts(edma_tcd_t *tcd, uint32_t mask)
{ assert(tcd != NULL); if (0U != (mask & (uint32_t)kEDMA_MajorInterruptEnable)) { tcd->CSR |= DMA_CSR_INTMAJOR_MASK; } if (0U != (mask & (uint32_t)kEDMA_HalfInterruptEnable)) { tcd->CSR |= DMA_CSR_INTHALF_MASK; } }
eclipse-threadx/getting-started
C++
Other
310
/* This is the callback that is written to the Loaded Image protocol instance on the image handle. It uninstalls all registered handlers and frees all entry stub memory. */
EFI_STATUS EFIAPI PlUnloadDebugSupportDriver(IN EFI_HANDLE ImageHandle)
/* This is the callback that is written to the Loaded Image protocol instance on the image handle. It uninstalls all registered handlers and frees all entry stub memory. */ EFI_STATUS EFIAPI PlUnloadDebugSupportDriver(IN EFI_HANDLE ImageHandle)
{ EFI_EXCEPTION_TYPE ExceptionType; for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) { ManageIdtEntryTable (NULL, ExceptionType); if (IdtEntryTable[ExceptionType].StubEntry != NULL) { FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry); } } FreePool (IdtEntryTable); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Deinitializes the SPIx peripheral registers to their default reset values (Affects also the I2Ss). */
void SPI_I2S_DeInit(SPI_TypeDef *SPIx)
/* Deinitializes the SPIx peripheral registers to their default reset values (Affects also the I2Ss). */ void SPI_I2S_DeInit(SPI_TypeDef *SPIx)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); switch (*(uint32_t*)&SPIx) { case SPI1_BASE: RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE); RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE); break; case SPI2_BASE: RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE); break; case SPI3_BASE: RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE); break; default: break; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Resolve abstract address object to a name using getnameinfo(). */
int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen)
/* Resolve abstract address object to a name using getnameinfo(). */ int nl_addr_resolve(struct nl_addr *addr, char *host, size_t hostlen)
{ int err; struct sockaddr_in6 buf; socklen_t salen = sizeof(buf); err = nl_addr_fill_sockaddr(addr, (struct sockaddr *) &buf, &salen); if (err < 0) return err; err = getnameinfo((struct sockaddr *) &buf, salen, host, hostlen, NULL, 0, NI_NAMEREQD); if (err < 0) return nl_syserr2nlerr(err); return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* All interrupt signals become available on INT1 pin.. */
int32_t lsm6dsl_all_on_int1_set(stmdev_ctx_t *ctx, uint8_t val)
/* All interrupt signals become available on INT1 pin.. */ int32_t lsm6dsl_all_on_int1_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dsl_ctrl4_c_t ctrl4_c; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t*)&ctrl4_c, 1); if(ret == 0){ ctrl4_c.int2_on_int1 = val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL4_C, (uint8_t*)&ctrl4_c, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Save IDT entry for INT1 and update it. */
VOID SaveAndUpdateIdtEntry1(IN IA32_DESCRIPTOR *IdtDescriptor, OUT IA32_IDT_GATE_DESCRIPTOR *SavedIdtEntry)
/* Save IDT entry for INT1 and update it. */ VOID SaveAndUpdateIdtEntry1(IN IA32_DESCRIPTOR *IdtDescriptor, OUT IA32_IDT_GATE_DESCRIPTOR *SavedIdtEntry)
{ IA32_IDT_GATE_DESCRIPTOR *IdtEntry; UINT16 CodeSegment; UINTN InterruptHandler; IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor->Base; CopyMem (SavedIdtEntry, &IdtEntry[1], sizeof (IA32_IDT_GATE_DESCRIPTOR)); CodeSegment = AsmReadCs (); InterruptHandler = (UINTN)&AsmInterruptHandle; IdtEntry[1].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; IdtEntry[1].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16); IdtEntry[1].Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32); IdtEntry[1].Bits.Selector = CodeSegment; IdtEntry[1].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32; }
tianocore/edk2
C++
Other
4,240
/* this function will write some specified length data to file system. */
int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
/* this function will write some specified length data to file system. */ int dfs_file_write(struct dfs_fd *fd, const void *buf, size_t len)
{ if (fd == NULL) return -EINVAL; if (fd->fops->write == NULL) return -ENOSYS; return fd->fops->write(fd, buf, len); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Pipes with no buffer or size 0 should return 0 bytes available. If either of those conditions is true, then k_pipe_read_avail and k_pipe_write_avail should return 0. */
ZTEST(pipe_api, test_pipe_avail_no_buffer)
/* Pipes with no buffer or size 0 should return 0 bytes available. If either of those conditions is true, then k_pipe_read_avail and k_pipe_write_avail should return 0. */ ZTEST(pipe_api, test_pipe_avail_no_buffer)
{ size_t r_avail; size_t w_avail; r_avail = k_pipe_read_avail(&bufferless); zassert_equal(r_avail, 0, "read: expected: 0 actual: %u", r_avail); w_avail = k_pipe_write_avail(&bufferless); zassert_equal(w_avail, 0, "write: expected: 0 actual: %u", w_avail); r_avail = k_pipe_read_avail(&bufferless1); zassert_equal(r_avail, 0, "read: expected: 0 actual: %u", r_avail); w_avail = k_pipe_write_avail(&bufferless1); zassert_equal(w_avail, 0, "write: expected: 0 actual: %u", w_avail); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Send a master receive request when the bus is idle.(Read Step1) For this function returns immediately, it is always using in the interrupt hander. */
void xI2CMasterReadRequestS1(unsigned long ulBase, unsigned char ucSlaveAddr, xtBoolean bEndTransmition)
/* Send a master receive request when the bus is idle.(Read Step1) For this function returns immediately, it is always using in the interrupt hander. */ void xI2CMasterReadRequestS1(unsigned long ulBase, unsigned char ucSlaveAddr, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); xHWREG(ulBase + I2C_O_CON) |= I2C_CON_AA; ulStatus = I2CStartSend(ulBase); if(!((ulStatus == I2C_I2STAT_M_TX_START) || (ulStatus == I2C_I2STAT_M_TX_RESTART))) { I2CStopSend(ulBase); return ; } ulStatus = I2CByteSend(ulBase, (ucSlaveAddr << 1) | 1) ; if(!(ulStatus == I2C_I2STAT_M_RX_SLAR_ACK)) { I2CStopSend(ulBase); return ; } if(bEndTransmition) { xHWREG(ulBase + I2C_O_CON) &= ~I2C_CON_AA; I2CStopSend(ulBase); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Writes an HMAC key to the digest registers in the SHA/MD5 module. */
void SHAMD5HMACKeySet(uint32_t ui32Base, uint32_t *pui32Src)
/* Writes an HMAC key to the digest registers in the SHA/MD5 module. */ void SHAMD5HMACKeySet(uint32_t ui32Base, uint32_t *pui32Src)
{ uint32_t ui32Idx; ASSERT(ui32Base == SHAMD5_BASE); for (ui32Idx = 0; ui32Idx < 64; ui32Idx += 4) { HWREG(ui32Base + SHAMD5_O_ODIGEST_A + ui32Idx) = *pui32Src++; } HWREG(ui32Base + SHAMD5_O_MODE) |= (SHAMD5_MODE_HMAC_OUTER_HASH | SHAMD5_MODE_HMAC_KEY_PROC | SHAMD5_MODE_CLOSE_HASH); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Report the maximum number of pinned breakpoints a task have in this cpu */
static unsigned int max_task_bp_pinned(int cpu)
/* Report the maximum number of pinned breakpoints a task have in this cpu */ static unsigned int max_task_bp_pinned(int cpu)
{ int i; unsigned int *tsk_pinned = per_cpu(nr_task_bp_pinned, cpu); for (i = HBP_NUM -1; i >= 0; i--) { if (tsk_pinned[i] > 0) return i + 1; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Gets interrupt status for the specified GPIO port. */
uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked)
/* Gets interrupt status for the specified GPIO port. */ uint32_t GPIOIntStatus(uint32_t ui32Port, bool bMasked)
{ ASSERT(_GPIOBaseValid(ui32Port)); if (bMasked) { return (HWREG(ui32Port + GPIO_O_MIS)); } else { return (HWREG(ui32Port + GPIO_O_RIS)); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads and returns the current value of DS. This function is only available on IA-32 and x64. */
UINT16 EFIAPI AsmReadDs(VOID)
/* Reads and returns the current value of DS. This function is only available on IA-32 and x64. */ UINT16 EFIAPI AsmReadDs(VOID)
{ __asm { xor eax, eax mov ax, ds } }
tianocore/edk2
C++
Other
4,240
/* This file is part of the Simba project. */
int mock_write_hash_map_init(struct hash_map_bucket_t *buckets_p, size_t buckets_max, struct hash_map_entry_t *entries_p, size_t entries_max, hash_function_t hash, int res)
/* This file is part of the Simba project. */ int mock_write_hash_map_init(struct hash_map_bucket_t *buckets_p, size_t buckets_max, struct hash_map_entry_t *entries_p, size_t entries_max, hash_function_t hash, int res)
{ harness_mock_write("hash_map_init(buckets_p)", buckets_p, sizeof(*buckets_p)); harness_mock_write("hash_map_init(buckets_max)", &buckets_max, sizeof(buckets_max)); harness_mock_write("hash_map_init(entries_p)", entries_p, sizeof(*entries_p)); harness_mock_write("hash_map_init(entries_max)", &entries_max, sizeof(entries_max)); harness_mock_write("hash_map_init(hash)", &hash, sizeof(hash)); harness_mock_write("hash_map_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): */
int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
/* Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): */ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
{ int i, err = 0; if (!dev || !dev->wakeup.flags.valid) return -EINVAL; mutex_lock(&acpi_device_lock); if (dev->wakeup.prepare_count++) goto out; for (i = 0; i < dev->wakeup.resources.count; i++) { int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev); if (ret) { printk(KERN_ERR PREFIX "Transition power state\n"); dev->wakeup.flags.valid = 0; err = -ENODEV; goto err_out; } } err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); err_out: if (err) dev->wakeup.prepare_count = 0; out: mutex_unlock(&acpi_device_lock); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Return the AG of the filestream the file or directory belongs to, or NULLAGNUMBER otherwise. */
xfs_agnumber_t xfs_filestream_lookup_ag(xfs_inode_t *ip)
/* Return the AG of the filestream the file or directory belongs to, or NULLAGNUMBER otherwise. */ xfs_agnumber_t xfs_filestream_lookup_ag(xfs_inode_t *ip)
{ xfs_mru_cache_t *cache; fstrm_item_t *item; xfs_agnumber_t ag; int ref; if (!(ip->i_d.di_mode & (S_IFREG | S_IFDIR))) { ASSERT(0); return NULLAGNUMBER; } cache = ip->i_mount->m_filestream; item = xfs_mru_cache_lookup(cache, ip->i_ino); if (!item) { TRACE_LOOKUP(ip->i_mount, ip, NULL, NULLAGNUMBER, 0); return NULLAGNUMBER; } ASSERT(ip == item->ip); ag = item->ag; ref = xfs_filestream_peek_ag(ip->i_mount, ag); xfs_mru_cache_done(cache); TRACE_LOOKUP(ip->i_mount, ip, item->pip, ag, ref); return ag; }
robutest/uclinux
C++
GPL-2.0
60
/* Read the flash id present at bank #banknum */
static unsigned int smi_read_id(flash_info_t *info, int banknum)
/* Read the flash id present at bank #banknum */ static unsigned int smi_read_id(flash_info_t *info, int banknum)
{ unsigned int value; writel(readl(&smicntl->smi_cr1) | SW_MODE, &smicntl->smi_cr1); writel(READ_ID, &smicntl->smi_tr); writel((banknum << BANKSEL_SHIFT) | SEND | TX_LEN_1 | RX_LEN_3, &smicntl->smi_cr2); smi_wait_xfer_finish(XFER_FINISH_TOUT); value = (readl(&smicntl->smi_rr) & 0x00FFFFFF); writel(readl(&smicntl->smi_sr) & ~TFF, &smicntl->smi_sr); writel(readl(&smicntl->smi_cr1) & ~SW_MODE, &smicntl->smi_cr1); return value; }
EmcraftSystems/u-boot
C++
Other
181
/* SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig */
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
/* SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig */ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{ return SDL_WinRTRunApp(SDL_main, NULL); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* param base FlexIO I2S base pointer param bitWidth How many bits in a audio word, usually /32 bits. param rxData Pointer to the data to be read. param size Bytes to be read. */
void FLEXIO_I2S_ReadBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size)
/* param base FlexIO I2S base pointer param bitWidth How many bits in a audio word, usually /32 bits. param rxData Pointer to the data to be read. param size Bytes to be read. */ void FLEXIO_I2S_ReadBlocking(FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size)
{ uint32_t i = 0; uint8_t bytesPerWord = bitWidth / 8U; for (i = 0; i < size / bytesPerWord; i++) { while (!(FLEXIO_GetShifterStatusFlags(base->flexioBase) & (1U << base->rxShifterIndex))) { } FLEXIO_I2S_ReadNonBlocking(base, bitWidth, rxData, bytesPerWord); rxData += bytesPerWord; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base I2C base pointer. param handle pointer to i2c_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */
status_t I2C_MasterTransferGetCount(I2C_Type *base, i2c_master_handle_t *handle, size_t *count)
/* param base I2C base pointer. param handle pointer to i2c_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count. */ status_t I2C_MasterTransferGetCount(I2C_Type *base, i2c_master_handle_t *handle, size_t *count)
{ assert(NULL != handle); if (NULL == count) { return kStatus_InvalidArgument; } *count = handle->transferSize - handle->transfer.dataSize; return kStatus_Success; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* mpi_msg_free_get- get the free message buffer for transfer inbound queue. @circularQ: the inbound queue we want to transfer to HBA. @messageSize: the message size of this transfer, normally it is 64 bytes @messagePtr: the pointer to message. */
static int mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr)
/* mpi_msg_free_get- get the free message buffer for transfer inbound queue. @circularQ: the inbound queue we want to transfer to HBA. @messageSize: the message size of this transfer, normally it is 64 bytes @messagePtr: the pointer to message. */ static int mpi_msg_free_get(struct inbound_queue_table *circularQ, u16 messageSize, void **messagePtr)
{ u32 offset, consumer_index; struct mpi_msg_hdr *msgHeader; u8 bcCount = 1; if (messageSize > 64) { *messagePtr = NULL; return -1; } consumer_index = pm8001_read_32(circularQ->ci_virt); circularQ->consumer_index = cpu_to_le32(consumer_index); if (((circularQ->producer_idx + bcCount) % 256) == circularQ->consumer_index) { *messagePtr = NULL; return -1; } offset = circularQ->producer_idx * 64; circularQ->producer_idx = (circularQ->producer_idx + bcCount) % 256; msgHeader = (struct mpi_msg_hdr *)(circularQ->base_virt + offset); *messagePtr = ((void *)msgHeader) + sizeof(struct mpi_msg_hdr); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* param base PWM peripheral base address param subModule PWM submodule to configure param mask The status flags to clear. This is a logical OR of members of the enumeration ::pwm_status_flags_t */
void PWM_ClearStatusFlags(PWM_Type *base, pwm_submodule_t subModule, uint32_t mask)
/* param base PWM peripheral base address param subModule PWM submodule to configure param mask The status flags to clear. This is a logical OR of members of the enumeration ::pwm_status_flags_t */ void PWM_ClearStatusFlags(PWM_Type *base, pwm_submodule_t subModule, uint32_t mask)
{ uint16_t reg; base->SM[subModule].STS = (mask & 0xFFFFU); reg = base->FSTS; reg &= ~(PWM_FSTS_FFLAG_MASK); reg |= ((mask >> 16U) & PWM_FSTS_FFLAG_MASK); base->FSTS = reg; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads a number of bytes to a page in the internal Flash. */
int32_t flash_read(struct flash_descriptor *flash, uint32_t src_addr, uint8_t *buffer, uint32_t length)
/* Reads a number of bytes to a page in the internal Flash. */ int32_t flash_read(struct flash_descriptor *flash, uint32_t src_addr, uint8_t *buffer, uint32_t length)
{ ASSERT(flash && buffer && length); uint32_t page_size = _flash_get_page_size(&flash->dev); uint32_t total_pages = _flash_get_total_pages(&flash->dev); if ((src_addr > page_size * total_pages) || (src_addr + length > page_size * total_pages)) { return ERR_BAD_ADDRESS; } _flash_read(&flash->dev, src_addr, buffer, length); return ERR_NONE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* After the caller of jbd2_journal_get_descriptor_buffer() has finished modifying the buffer's contents they really should run flush_dcache_page(bh->b_page). But we don't bother doing that, so there will be coherency problems with mmaps of blockdevs which hold live JBD-controlled filesystems. */
struct journal_head* jbd2_journal_get_descriptor_buffer(journal_t *journal)
/* After the caller of jbd2_journal_get_descriptor_buffer() has finished modifying the buffer's contents they really should run flush_dcache_page(bh->b_page). But we don't bother doing that, so there will be coherency problems with mmaps of blockdevs which hold live JBD-controlled filesystems. */ struct journal_head* jbd2_journal_get_descriptor_buffer(journal_t *journal)
{ struct buffer_head *bh; unsigned long long blocknr; int err; err = jbd2_journal_next_log_block(journal, &blocknr); if (err) return NULL; bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); if (!bh) return NULL; lock_buffer(bh); memset(bh->b_data, 0, journal->j_blocksize); set_buffer_uptodate(bh); unlock_buffer(bh); BUFFER_TRACE(bh, "return this buffer"); return jbd2_journal_add_journal_head(bh); }
robutest/uclinux
C++
GPL-2.0
60
/* Check if a color format has alpha channel or not */
bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
/* Check if a color format has alpha channel or not */ bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
{ bool has_alpha = false; switch(cf) { case LV_IMG_CF_TRUE_COLOR_ALPHA: case LV_IMG_CF_RAW_ALPHA: case LV_IMG_CF_ALPHA_1BIT: case LV_IMG_CF_ALPHA_2BIT: case LV_IMG_CF_ALPHA_4BIT: case LV_IMG_CF_ALPHA_8BIT: has_alpha = true; break; default: has_alpha = false; break; } return has_alpha; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function will copy the object pointer of the specified type, with the maximum size specified by maxlen. */
int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
/* This function will copy the object pointer of the specified type, with the maximum size specified by maxlen. */ int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
{ int index = 0; rt_base_t level; struct rt_object *object; struct rt_list_node *node = RT_NULL; struct rt_object_information *information = RT_NULL; if (maxlen <= 0) return 0; information = rt_object_get_information(type); if (information == RT_NULL) return 0; level = rt_spin_lock_irqsave(&(information->spinlock)); rt_list_for_each(node, &(information->object_list)) { object = rt_list_entry(node, struct rt_object, list); pointers[index] = object; index ++; if (index >= maxlen) break; } rt_spin_unlock_irqrestore(&(information->spinlock), level); return index; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns NULL if bs is not found in active's image chain, or if active == bs. */
BlockDriverState* bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs)
/* Returns NULL if bs is not found in active's image chain, or if active == bs. */ BlockDriverState* bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs)
{ BlockDriverState *overlay = NULL; BlockDriverState *intermediate; assert(active != NULL); assert(bs != NULL); if (active == bs) { return NULL; } intermediate = active; while (intermediate->backing_hd) { if (intermediate->backing_hd == bs) { overlay = intermediate; break; } intermediate = intermediate->backing_hd; } return overlay; }
ve3wwg/teensy3_qemu
C
Other
15
/* Returns true if the finding pci_device_id structure matched or false if there is no match. */
static bool pci_match_one_id(const struct pci_device_id *id, const struct pci_device_id *find)
/* Returns true if the finding pci_device_id structure matched or false if there is no match. */ static bool pci_match_one_id(const struct pci_device_id *id, const struct pci_device_id *find)
{ if ((id->vendor == PCI_ANY_ID || id->vendor == find->vendor) && (id->device == PCI_ANY_ID || id->device == find->device) && (id->subvendor == PCI_ANY_ID || id->subvendor == find->subvendor) && (id->subdevice == PCI_ANY_ID || id->subdevice == find->subdevice) && !((id->class ^ find->class) & id->class_mask)) return true; return false; }
4ms/stm32mp1-baremetal
C++
Other
137
/* If any reserved bits in Address are set, then ASSERT(). */
UINT8 EFIAPI PciSegmentOr8(IN UINT64 Address, IN UINT8 OrData)
/* If any reserved bits in Address are set, then ASSERT(). */ UINT8 EFIAPI PciSegmentOr8(IN UINT64 Address, IN UINT8 OrData)
{ return PciWrite8 (PCI_SEGMENT_TO_PCI_ADDRESS (Address), (UINT8)(PciSegmentRead8 (Address) | OrData)); }
tianocore/edk2
C++
Other
4,240
/* Caller gets one enabled AP to execute a caller-provided function. */
EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
/* Caller gets one enabled AP to execute a caller-provided function. */ EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
{ return MpServices.Ppi->StartupThisAP (MpServices.Ppi, Procedure, ProcessorNumber, TimeoutInMicroSeconds, ProcedureArgument); }
tianocore/edk2
C++
Other
4,240
/* IDL typedef struct { IDL long element_57; IDL TYPE_11 *element_58; IDL } TYPE_10; */
static int dissect_browser_TYPE_11_array(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
/* IDL typedef struct { IDL long element_57; IDL TYPE_11 *element_58; IDL } TYPE_10; */ static int dissect_browser_TYPE_11_array(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)
{ offset = dissect_ndr_ucarray(tvb, offset, pinfo, tree, di, drep, dissect_browser_TYPE_11); return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Sends a Half Word through the SPI interface and return the Half Word received from the SPI bus. */
uint16_t sFLASH_SendHalfWord(uint16_t HalfWord)
/* Sends a Half Word through the SPI interface and return the Half Word received from the SPI bus. */ uint16_t sFLASH_SendHalfWord(uint16_t HalfWord)
{ while (SPI_I2S_GetFlagStatus(sFLASH_SPI, SPI_I2S_FLAG_TXE) == RESET); SPI_I2S_SendData(sFLASH_SPI, HalfWord); while (SPI_I2S_GetFlagStatus(sFLASH_SPI, SPI_I2S_FLAG_RXNE) == RESET); return SPI_I2S_ReceiveData(sFLASH_SPI); }
avem-labs/Avem
C++
MIT License
1,752
/* Return with the pointer of the previous node before 'n_act' */
void* _lv_ll_get_prev(const lv_ll_t *ll_p, const void *n_act)
/* Return with the pointer of the previous node before 'n_act' */ void* _lv_ll_get_prev(const lv_ll_t *ll_p, const void *n_act)
{ const lv_ll_node_t * n_act_d = n_act; n_act_d += LL_PREV_P_OFFSET(ll_p); return *((lv_ll_node_t **)n_act_d); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Enables the USB controller to respond to LPM suspend requests. */
void USBDevLPMEnable(uint32_t ui32Base)
/* Enables the USB controller to respond to LPM suspend requests. */ void USBDevLPMEnable(uint32_t ui32Base)
{ ASSERT(ui32Base == USB0_BASE); HWREGB(ui32Base + USB_O_LPMCNTRL) |= USB_LPMCNTRL_EN_LPMEXT | USB_LPMCNTRL_TXLPM; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function may be used by machine-type compatibility functions to enable or disable feature bits on specific CPU models. */
void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w, uint32_t feat_add, uint32_t feat_remove)
/* This function may be used by machine-type compatibility functions to enable or disable feature bits on specific CPU models. */ void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w, uint32_t feat_add, uint32_t feat_remove)
{ X86CPUDefinition *def; int i; for (i = 0; i < ARRAY_SIZE(builtin_x86_defs); i++) { def = &builtin_x86_defs[i]; if (!cpu_model || !strcmp(cpu_model, def->name)) { def->features[w] |= feat_add; def->features[w] &= ~feat_remove; } } }
ve3wwg/teensy3_qemu
C++
Other
15
/* This function allow to do concurrent enumerations without the need to lock over the whole session, because the caller keep the context of the search. On the other hand, it might fail and return NULL if the entry is removed. - Jean II */
void* hashbin_find_next(hashbin_t *hashbin, long hashv, const char *name, void **pnext)
/* This function allow to do concurrent enumerations without the need to lock over the whole session, because the caller keep the context of the search. On the other hand, it might fail and return NULL if the entry is removed. - Jean II */ void* hashbin_find_next(hashbin_t *hashbin, long hashv, const char *name, void **pnext)
{ unsigned long flags = 0; irda_queue_t* entry; spin_lock_irqsave(&hashbin->hb_spinlock, flags); entry = (irda_queue_t* ) hashbin_find( hashbin, hashv, name ); if(entry) { hashbin->hb_current = entry; *pnext = hashbin_get_next( hashbin ); } else *pnext = NULL; spin_unlock_irqrestore(&hashbin->hb_spinlock, flags); return entry; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clock out 80 cycles (10 bytes) before GO_IDLE command. */
static void go_idle_clockout(int slot)
/* Clock out 80 cycles (10 bytes) before GO_IDLE command. */ static void go_idle_clockout(int slot)
{ uint8_t data[12]; memset(data, 0xff, sizeof(data)); spi_transaction_t t = { .length = 10*8, .tx_buffer = data, .rx_buffer = data, }; spi_device_transmit(spi_handle(slot), &t); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* add-request adds a request to the linked list. queue lock is held and interrupts disabled, as we muck with the request queue list. */
static void add_request(struct request_queue *q, struct request *req)
/* add-request adds a request to the linked list. queue lock is held and interrupts disabled, as we muck with the request queue list. */ static void add_request(struct request_queue *q, struct request *req)
{ drive_stat_acct(req, 1); __elv_add_request(q, req, ELEVATOR_INSERT_SORT, 0); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clean up the dynamic opcode at label and form specified by both LabelId. */
VOID CleanUpPage(IN UINT16 LabelId, IN SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData)
/* Clean up the dynamic opcode at label and form specified by both LabelId. */ VOID CleanUpPage(IN UINT16 LabelId, IN SECUREBOOT_CONFIG_PRIVATE_DATA *PrivateData)
{ RefreshUpdateData (); mStartLabel->Number = LabelId; HiiUpdateForm ( PrivateData->HiiHandle, &gSecureBootConfigFormSetGuid, LabelId, mStartOpCodeHandle, mEndOpCodeHandle ); }
tianocore/edk2
C++
Other
4,240
/* Configure the command through generic packet header register. */
static void gen_write_cmd(unsigned long gen_hdr)
/* Configure the command through generic packet header register. */ static void gen_write_cmd(unsigned long gen_hdr)
{ while (HW_MIPI_DSI_CMD_PKT_STATUS.B.GEN_CMD_FULL) ; HW_MIPI_DSI_GEN_HDR_WR(gen_hdr); while ((!HW_MIPI_DSI_CMD_PKT_STATUS.B.GEN_CMD_EMPTY) && (!HW_MIPI_DSI_CMD_PKT_STATUS.B.GEN_PLD_W_EMPTY)) ; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Save Tcg2 PCR Banks request request to variable space. */
EFI_STATUS SaveTcg2PCRBanksRequest(IN UINTN PCRBankIndex, IN BOOLEAN Enable)
/* Save Tcg2 PCR Banks request request to variable space. */ EFI_STATUS SaveTcg2PCRBanksRequest(IN UINTN PCRBankIndex, IN BOOLEAN Enable)
{ UINT32 ReturnCode; EFI_STATUS Status; if (Enable) { mTcg2ConfigPrivateDate->PCRBanksDesired |= (0x1 << PCRBankIndex); } else { mTcg2ConfigPrivateDate->PCRBanksDesired &= ~(0x1 << PCRBankIndex); } ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS, mTcg2ConfigPrivateDate->PCRBanksDesired); if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) { Status = EFI_SUCCESS; } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) { Status = EFI_OUT_OF_RESOURCES; } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) { Status = EFI_UNSUPPORTED; } else { Status = EFI_DEVICE_ERROR; } return Status; }
tianocore/edk2
C++
Other
4,240
/* Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
/* Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void)
{ CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* s2io_ethtool_sset - Sets different link parameters. @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. @info: pointer to the structure with parameters given by ethtool to set link information. Description: The function sets different link parameters provided by the user onto the NIC. Return value: 0 on success. */
static int s2io_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info)
/* s2io_ethtool_sset - Sets different link parameters. @sp : private member of the device structure, which is a pointer to the * s2io_nic structure. @info: pointer to the structure with parameters given by ethtool to set link information. Description: The function sets different link parameters provided by the user onto the NIC. Return value: 0 on success. */ static int s2io_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info)
{ struct s2io_nic *sp = netdev_priv(dev); if ((info->autoneg == AUTONEG_ENABLE) || (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL)) return -EINVAL; else { s2io_close(sp->dev); s2io_open(sp->dev); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Reset the 82586 on the 3c523. Also very board dependent. */
static void elmc_do_reset586(int ioaddr, int ints)
/* Reset the 82586 on the 3c523. Also very board dependent. */ static void elmc_do_reset586(int ioaddr, int ints)
{ outb(0x3 | ELMC_CTRL_LBK, ioaddr + ELMC_CTRL); DELAY_16(); outb(ELMC_CTRL_RST | ELMC_CTRL_LBK | 0x3, ioaddr + ELMC_CTRL); elmc_do_attn586(ioaddr, ints); }
robutest/uclinux
C++
GPL-2.0
60
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */
void pdm_unregister_callback(struct pdm_instance *const dev_inst, enum pdm_callback_type type)
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */ void pdm_unregister_callback(struct pdm_instance *const dev_inst, enum pdm_callback_type type)
{ Assert(dev_inst); if (type < PDM_CALLBACK_N) { dev_inst->callbacks[type] = NULL; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Combine the results of the list() operation from every xattr_handler in the list. */
ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
/* Combine the results of the list() operation from every xattr_handler in the list. */ ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
{ struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; unsigned int size = 0; if (!buffer) { for_each_xattr_handler(handlers, handler) { size += handler->list(dentry, NULL, 0, NULL, 0, handler->flags); } } else { char *buf = buffer; for_each_xattr_handler(handlers, handler) { size = handler->list(dentry, buf, buffer_size, NULL, 0, handler->flags); if (size > buffer_size) return -ERANGE; buf += size; buffer_size -= size; } size = buf - buffer; } return size; }
robutest/uclinux
C++
GPL-2.0
60
/* Rough approximation of a delay function with microsecond resolution. Used during initial clock setup as the Timers are not configured yet. */
static void cgu_WaitUS(volatile uint32_t us)
/* Rough approximation of a delay function with microsecond resolution. Used during initial clock setup as the Timers are not configured yet. */ static void cgu_WaitUS(volatile uint32_t us)
{ us *= (SystemCoreClock / 1000000) / 3; while (us--); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Check if Slave resume interrupt is enabled @rmtoll IER SRIE LL_SWPMI_IsEnabledIT_SR. */
uint32_t LL_SWPMI_IsEnabledIT_SR(SWPMI_TypeDef *SWPMIx)
/* Check if Slave resume interrupt is enabled @rmtoll IER SRIE LL_SWPMI_IsEnabledIT_SR. */ uint32_t LL_SWPMI_IsEnabledIT_SR(SWPMI_TypeDef *SWPMIx)
{ return ((READ_BIT(SWPMIx->IER, SWPMI_IER_SRIE) == (SWPMI_IER_SRIE)) ? 1UL : 0UL); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Take a bigint and convert it into a byte sequence. This is useful after a decrypt operation. */
void ICACHE_FLASH_ATTR bi_export(BI_CTX *ctx, bigint *x, uint8_t *data, int size)
/* Take a bigint and convert it into a byte sequence. This is useful after a decrypt operation. */ void ICACHE_FLASH_ATTR bi_export(BI_CTX *ctx, bigint *x, uint8_t *data, int size)
{ int i, j, k = size-1; check(x); memset(data, 0, size); for (i = 0; i < x->size; i++) { for (j = 0; j < COMP_BYTE_SIZE; j++) { comp mask = 0xff << (j*8); int num = (x->comps[i] & mask) >> (j*8); data[k--] = num; if (k < 0) { goto buf_done; } } } buf_done: bi_free(ctx, x); }
eerimoq/simba
C++
Other
337
/* USBH_SetInterface The command sets the Interface value to the connected device. */
USBH_Status USBH_SetInterface(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t ep_num, uint8_t altSetting)
/* USBH_SetInterface The command sets the Interface value to the connected device. */ USBH_Status USBH_SetInterface(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t ep_num, uint8_t altSetting)
{ phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_INTERFACE | \ USB_REQ_TYPE_STANDARD; phost->Control.setup.b.bRequest = USB_REQ_SET_INTERFACE; phost->Control.setup.b.wValue.w = altSetting; phost->Control.setup.b.wIndex.w = ep_num; phost->Control.setup.b.wLength.w = 0; return USBH_CtlReq(pdev, phost, 0 , 0 ); }
MaJerle/stm32f429
C++
null
2,036
/* configure the peripheral clock prescaler in USART IrDA low-power mode */
void usart_prescaler_config(uint32_t usart_periph, uint8_t psc)
/* configure the peripheral clock prescaler in USART IrDA low-power mode */ void usart_prescaler_config(uint32_t usart_periph, uint8_t psc)
{ USART_GP(usart_periph) &= ~(USART_GP_PSC); USART_GP(usart_periph) |= (uint32_t)psc; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Create a new list item and initialize its fields. */
dep_list* dl_create(char *path, ino_t inode)
/* Create a new list item and initialize its fields. */ dep_list* dl_create(char *path, ino_t inode)
{ dep_list *dl = calloc (1, sizeof (dep_list)); if (dl == NULL) { perror_msg ("Failed to create a new dep-list item"); return NULL; } dl->path = path; dl->inode = inode; return dl; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* returns 1 if the end block is EXT2_RESERVE_WINDOW_NOT_ALLOCATED. */
static int rsv_is_empty(struct ext2_reserve_window *rsv)
/* returns 1 if the end block is EXT2_RESERVE_WINDOW_NOT_ALLOCATED. */ static int rsv_is_empty(struct ext2_reserve_window *rsv)
{ return (rsv->_rsv_end == EXT2_RESERVE_WINDOW_NOT_ALLOCATED); }
robutest/uclinux
C++
GPL-2.0
60
/* Evaluate the LPC filter coefficients from the reflection coefficients. Does the inverse of the eval_refl() function. */
static void eval_coefs(int *coefs, const int *refl)
/* Evaluate the LPC filter coefficients from the reflection coefficients. Does the inverse of the eval_refl() function. */ static void eval_coefs(int *coefs, const int *refl)
{ int buffer[10]; int *b1 = buffer; int *b2 = coefs; int i, j; for (i=0; i < 10; i++) { b1[i] = refl[i] << 4; for (j=0; j < i; j++) b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j]; FFSWAP(int *, b1, b2); } for (i=0; i < 10; i++) coefs[i] >>= 4; }
DC-SWAT/DreamShell
C++
null
404
/* Set a pairing policy. Set a pairing policy to be applied when receiving a pairing request event. The default policy is to always accept pairing and always accept bonding */
ADI_BLER_RESULT adi_radio_SetPairingPolicy(const uint8_t nAccept, const uint8_t nBond)
/* Set a pairing policy. Set a pairing policy to be applied when receiving a pairing request event. The default policy is to always accept pairing and always accept bonding */ ADI_BLER_RESULT adi_radio_SetPairingPolicy(const uint8_t nAccept, const uint8_t nBond)
{ ADI_BLER_RESULT bleResult; ADI_BLE_LOGEVENT(LOGID_CMD_BLESMP_SET_PAIRING_POLICY); ADI_BLE_RADIO_CMD_START(CMD_BLESMP_SET_PAIRING_POLICY); memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN], &nAccept, 1u); memcpy(&pBLERadio->cmdPkt[ADI_RADIO_CMD_HEADER_LEN + 1], &nBond, 1u); bleResult = bler_process_cmd(CMD_BLESMP_SET_PAIRING_POLICY, 2u, NULL, 0u); if(bleResult == ADI_BLER_SUCCESS){ bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,ADI_BLER_CMD_TIMEOUT); } ADI_BLE_RADIO_CMD_END(); return (bleResult); }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* The @regs identifier is provided by a successful call to sa1100_request_dma(). */
void sa1100_reset_dma(dma_regs_t *regs)
/* The @regs identifier is provided by a successful call to sa1100_request_dma(). */ void sa1100_reset_dma(dma_regs_t *regs)
{ int i; for (i = 0; i < SA1100_DMA_CHANNELS; i++) if (regs == (dma_regs_t *)&DDAR(i)) break; if (i >= SA1100_DMA_CHANNELS) { printk(KERN_ERR "%s: bad DMA identifier\n", __func__); return; } regs->ClrDCSR = (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB | DCSR_IE | DCSR_ERROR | DCSR_RUN); regs->DDAR = dma_chan[i].device; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The function reads the requested number of blocks from the device. All the blocks are read, or an error is returned. If there is no media in the device, the function returns EFI_NO_MEDIA. */
EFI_STATUS EFIAPI AhciBlockIoReadBlocks(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
/* The function reads the requested number of blocks from the device. All the blocks are read, or an error is returned. If there is no media in the device, the function returns EFI_NO_MEDIA. */ EFI_STATUS EFIAPI AhciBlockIoReadBlocks(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
{ PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private; PEI_AHCI_ATA_DEVICE_DATA *DeviceData; if (This == NULL) { return EFI_INVALID_PARAMETER; } Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO (This); DeviceData = SearchDeviceByIndex (Private, DeviceIndex); if (DeviceData == NULL) { return EFI_NOT_FOUND; } return AhciRead (DeviceData, Buffer, StartLBA, BufferSize); }
tianocore/edk2
C++
Other
4,240
/* Write byte to SDIO register. Writes byte to SDIO register */
int sdio_write_byte(struct sdio_func *func, uint32_t reg, uint8_t write_val)
/* Write byte to SDIO register. Writes byte to SDIO register */ int sdio_write_byte(struct sdio_func *func, uint32_t reg, uint8_t write_val)
{ int ret; if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { LOG_WRN("Card does not support SDIO commands"); return -ENOTSUP; } ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); if (ret) { LOG_WRN("Could not get SD card mutex"); return -EBUSY; } ret = sdio_io_rw_direct(func->card, SDIO_IO_WRITE, func->num, reg, write_val, NULL); k_mutex_unlock(&func->card->lock); return ret; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573