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
/* Get the mode data of the low layer protocol. */
EFI_STATUS SockGetMode(IN SOCKET *Sock, IN OUT VOID *Mode)
/* Get the mode data of the low layer protocol. */ EFI_STATUS SockGetMode(IN SOCKET *Sock, IN OUT VOID *Mode)
{ return Sock->ProtoHandler (Sock, SOCK_MODE, Mode); }
tianocore/edk2
C++
Other
4,240
/* Scheduled procedure to handle blocking stuff for the pushbuttons. Handles all pending events and exits. */
static void shpchp_pushbutton_thread(struct work_struct *work)
/* Scheduled procedure to handle blocking stuff for the pushbuttons. Handles all pending events and exits. */ static void shpchp_pushbutton_thread(struct work_struct *work)
{ struct pushbutton_work_info *info = container_of(work, struct pushbutton_work_info, work); struct slot *p_slot = info->p_slot; mutex_lock(&p_slot->lock); switch (p_slot->state) { case POWEROFF_STATE: mutex_unlock(&p_slot->lock); shpchp_disable_slot(p_slot); mutex_lock(&p_slot->lock); p_slot->state = ST...
robutest/uclinux
C++
GPL-2.0
60
/* Disable an SGE response queue. The caller is responsible for ensuring only one context operation occurs at a time. */
int t3_sge_disable_rspcntxt(struct adapter *adapter, unsigned int id)
/* Disable an SGE response queue. The caller is responsible for ensuring only one context operation occurs at a time. */ int t3_sge_disable_rspcntxt(struct adapter *adapter, unsigned int id)
{ if (t3_read_reg(adapter, A_SG_CONTEXT_CMD) & F_CONTEXT_CMD_BUSY) return -EBUSY; t3_write_reg(adapter, A_SG_CONTEXT_MASK0, V_CQ_SIZE(M_CQ_SIZE)); t3_write_reg(adapter, A_SG_CONTEXT_MASK1, 0); t3_write_reg(adapter, A_SG_CONTEXT_MASK2, 0); t3_write_reg(adapter, A_SG_CONTEXT_MASK3, 0); t3_write_reg(adapter, A_SG_...
robutest/uclinux
C++
GPL-2.0
60
/* Turn the Scroll-Lock LED off when the console is started */
static void con_start(struct tty_struct *tty)
/* Turn the Scroll-Lock LED off when the console is started */ static void con_start(struct tty_struct *tty)
{ int console_num; if (!tty) return; console_num = tty->index; if (!vc_cons_allocated(console_num)) return; clr_vc_kbd_led(kbd_table + console_num, VC_SCROLLOCK); set_leds(); }
robutest/uclinux
C++
GPL-2.0
60
/* Called without mmap_sem, but after all other threads have been killed. */
pte_t* get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl)
/* Called without mmap_sem, but after all other threads have been killed. */ pte_t* get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl)
{ pgd_t * pgd = pgd_offset(mm, addr); pud_t * pud = pud_alloc(mm, pgd, addr); if (pud) { pmd_t * pmd = pmd_alloc(mm, pud, addr); if (pmd) return pte_alloc_map_lock(mm, pmd, addr, ptl); } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Shutdown of an instance of the controller device @dev I2C controller platform device */
static int __devexit i2c_stm32_remove(struct platform_device *dev)
/* Shutdown of an instance of the controller device @dev I2C controller platform device */ static int __devexit i2c_stm32_remove(struct platform_device *dev)
{ struct i2c_stm32 *c = platform_get_drvdata(dev); int ret = 0; i2c_stm32_hw_release(c); platform_set_drvdata(dev, NULL); i2c_del_adapter(&c->adap); free_irq(c->irq, c); free_irq(c->irq + 1, c); iounmap(c->regs); release_mem_region(c->regs_base, c->regs_size); kfree(c); d_printk(1, "dev=%s,ret=%d\n", dev_na...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Closes an endpoint of the low level driver. */
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
/* Closes an endpoint of the low level driver. */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This NULLs the ftrace function and in essence stops tracing. There may be lag */
void clear_ftrace_function(void)
/* This NULLs the ftrace function and in essence stops tracing. There may be lag */ void clear_ftrace_function(void)
{ ftrace_trace_function = ftrace_stub; __ftrace_trace_function = ftrace_stub; ftrace_pid_function = ftrace_stub; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Search connection list of the SAP and finds connection using the remote mac, remote sap, local mac, and local sap. Returns pointer for connection found, NULL otherwise. Caller has to make sure local_bh is disabled. */
static struct sock* __llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, struct llc_addr *laddr)
/* Search connection list of the SAP and finds connection using the remote mac, remote sap, local mac, and local sap. Returns pointer for connection found, NULL otherwise. Caller has to make sure local_bh is disabled. */ static struct sock* __llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, struct l...
{ struct sock *rc; struct hlist_node *node; read_lock(&sap->sk_list.lock); sk_for_each(rc, node, &sap->sk_list.list) { struct llc_sock *llc = llc_sk(rc); if (llc->laddr.lsap == laddr->lsap && llc->daddr.lsap == daddr->lsap && llc_mac_match(llc->laddr.mac, laddr->mac) && llc_mac_match(llc->dadd...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configure the compare data of an ADC digital comparator. */
void xADCCompRegionSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulCompData, unsigned long ulMatchCnt)
/* Configure the compare data of an ADC digital comparator. */ void xADCCompRegionSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulCompData, unsigned long ulMatchCnt)
{ unsigned long ulCompRegAddr; unsigned long ulConfig; xASSERT(ulBase == ADC0_BASE); xASSERT((ulComp >= 0) && (ulComp < 2)); xASSERT(ulCompData < 0x1000); xASSERT(ulMatchCnt < 16); ulMatchCnt = 1; ulCompRegAddr = ulBase + ADC_CMPR0 + (4 * ulComp); ulConfig = ((ulCompData << ADC_CMPRX...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Read the current value on the handle(read value of multiple pins on one handle at the same time) */
int32_t csi_gpio_port_read(gpio_port_handle_t handle, uint32_t mask, uint32_t *value)
/* Read the current value on the handle(read value of multiple pins on one handle at the same time) */ int32_t csi_gpio_port_read(gpio_port_handle_t handle, uint32_t mask, uint32_t *value)
{ if (mask < 0) { return ERR_GPIO(EDRV_PARAMETER); } GPIO_NULL_PARAM_CHK(handle); GPIO_NULL_PARAM_CHK(value); uint32_t port_value = 0; gpio_read(&port_value); *value = (mask & port_value); return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ADC Set a Regular Channel Conversion Sequence. Define a sequence of channels to be converted as a regular group with a length from 1 to 18 channels. If this is called during conversion, the current conversion is reset and conversion begins again with the newly defined group. */
void adc_set_regular_sequence(uint32_t adc, uint8_t length, uint8_t channel[])
/* ADC Set a Regular Channel Conversion Sequence. Define a sequence of channels to be converted as a regular group with a length from 1 to 18 channels. If this is called during conversion, the current conversion is reset and conversion begins again with the newly defined group. */ void adc_set_regular_sequence(uint32_...
{ uint32_t reg32 = 0; uint8_t i = 0; bool stepup = false, stepdn = false; if (length == 0) { ADC_CHSELR(adc) = 0; return; } reg32 |= (1 << channel[0]); for (i = 1; i < length; i++) { reg32 |= (1 << channel[i]); stepup |= channel[i-1] < channel[i]; stepdn |= channel[i-1] > channel[i]; } if (stepup && ...
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* This routine is exported for use by applications that want to produce abbreviated JPEG datastreams. It logically belongs in jcparam.c, but since it is called by jpeg_start_compress, we put it here */
jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress)
/* This routine is exported for use by applications that want to produce abbreviated JPEG datastreams. It logically belongs in jcparam.c, but since it is called by jpeg_start_compress, we put it here */ jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress)
{ int i; JQUANT_TBL* qtbl; JHUFF_TBL* htbl; for (i = 0; i < NUM_QUANT_TBLS; i++) { if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) qtbl->sent_table = suppress; } for (i = 0; i < NUM_HUFF_TBLS; i++) { if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) htbl->se...
nanoframework/nf-interpreter
C++
MIT License
293
/* Insert given timer in given list of active timers. */
static void RAM_CODE timer_list_insert_isr(struct timer_list_t *self_p, struct timer_t *timer_p)
/* Insert given timer in given list of active timers. */ static void RAM_CODE timer_list_insert_isr(struct timer_list_t *self_p, struct timer_t *timer_p)
{ struct timer_t *elem_p; struct timer_t *prev_p; elem_p = self_p->head_p; prev_p = NULL; while (elem_p->delta < timer_p->delta) { timer_p->delta -= elem_p->delta; prev_p = elem_p; elem_p = elem_p->next_p; } if (elem_p != &self_p->tail) { elem_p->delta -= time...
eerimoq/simba
C++
Other
337
/* allocate pages for queue: outer loop allocates whole kernel pages (page aligned) and inner loop divides a kernel page into smaller hca queue pages */
static int alloc_queue_pages(struct ipz_queue *queue, const u32 nr_of_pages)
/* allocate pages for queue: outer loop allocates whole kernel pages (page aligned) and inner loop divides a kernel page into smaller hca queue pages */ static int alloc_queue_pages(struct ipz_queue *queue, const u32 nr_of_pages)
{ int k, f = 0; u8 *kpage; while (f < nr_of_pages) { kpage = (u8 *)get_zeroed_page(GFP_KERNEL); if (!kpage) goto out; for (k = 0; k < PAGES_PER_KPAGE && f < nr_of_pages; k++) { queue->queue_pages[f] = (struct ipz_page *)kpage; kpage += EHCA_PAGESIZE; f++; } } return 1; out: for (f = 0; f < nr_...
robutest/uclinux
C++
GPL-2.0
60
/* param base FLEXSPI peripheral base address. param handle pointer to flexspi_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 FLEXSPI_TransferGetCount(FLEXSPI_Type *base, flexspi_handle_t *handle, size_t *count)
/* param base FLEXSPI peripheral base address. param handle pointer to flexspi_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. */ st...
{ assert(NULL != handle); status_t result = kStatus_Success; if (handle->state == (uint32_t)kFLEXSPI_Idle) { result = kStatus_NoTransferInProgress; } else { *count = handle->transferTotalSize - handle->dataSize; } return result; }
eclipse-threadx/getting-started
C++
Other
310
/* This is the callback from dput() when d_count is going to 0. We use this to unhash dentries with bad inodes. */
static int smb_delete_dentry(struct dentry *)
/* This is the callback from dput() when d_count is going to 0. We use this to unhash dentries with bad inodes. */ static int smb_delete_dentry(struct dentry *)
{ if (dentry->d_inode) { if (is_bad_inode(dentry->d_inode)) { PARANOIA("bad inode, unhashing %s/%s\n", DENTRY_PATH(dentry)); return 1; } } else { } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Copy a flash memory section to a RAM buffer. */
static void mem_flash_read(void *dst, isp_addr_t src, uint16_t nbytes)
/* Copy a flash memory section to a RAM buffer. */ static void mem_flash_read(void *dst, isp_addr_t src, uint16_t nbytes)
{ memcpy(dst, FLASH_API_BASE_ADDRESS + src, nbytes); }
memfault/zero-to-main
C++
null
200
/* iis2dh_handle_interrupt - handle the drdy event read data and call handler if registered any */
static void iis2dh_handle_interrupt(const struct device *dev)
/* iis2dh_handle_interrupt - handle the drdy event read data and call handler if registered any */ static void iis2dh_handle_interrupt(const struct device *dev)
{ const struct iis2dh_device_config *cfg = dev->config; iis2dh_handle_drdy_int(dev); gpio_pin_interrupt_configure_dt(&cfg->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This is the actual size of code+data in the image, as opposed to the amount of space reserved in flash for that image. This code is similar to that used by the real EC code base. */
static int get_image_used(struct ec_state *ec, struct fmap_entry *entry)
/* This is the actual size of code+data in the image, as opposed to the amount of space reserved in flash for that image. This code is similar to that used by the real EC code base. */ static int get_image_used(struct ec_state *ec, struct fmap_entry *entry)
{ int size; for (size = entry->length - 1; size > 0 && ec->flash_data[entry->offset + size] != 0xea; size--) ; return size ? size + 1 : 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This fuction is called, when error recovery was successfull */
static int tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
/* This fuction is called, when error recovery was successfull */ static int tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
{ DBF_EVENT(3, "Error Recovery successful for %s\n", tape_op_verbose[request->op]); return tape_3590_done(device, request); }
robutest/uclinux
C++
GPL-2.0
60
/* returns 0 on success, <0 on failure. Currently, we have no special ioctls. -EOPNOTSUPP is returned, if an unknown ioctl was requested */
static int spider_net_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
/* returns 0 on success, <0 on failure. Currently, we have no special ioctls. -EOPNOTSUPP is returned, if an unknown ioctl was requested */ static int spider_net_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{ switch (cmd) { default: return -EOPNOTSUPP; } }
robutest/uclinux
C++
GPL-2.0
60
/* Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the buffer with zeros, 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* InternalVarCheckAllocateZeroPool(IN UINTN AllocationSize)
/* Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the buffer with zeros, 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 *Memory; Memory = InternalVarCheckAllocatePool (EfiBootServicesData, AllocationSize); if (Memory != NULL) { Memory = ZeroMem (Memory, AllocationSize); } return Memory; }
tianocore/edk2
C++
Other
4,240
/* Output a character in polled mode. If the hardware flow control is enabled then the handshake signal CTS has to be asserted in order to send a character. */
static void uart_xlnx_ps_poll_out(const struct device *dev, unsigned char c)
/* Output a character in polled mode. If the hardware flow control is enabled then the handshake signal CTS has to be asserted in order to send a character. */ static void uart_xlnx_ps_poll_out(const struct device *dev, unsigned char c)
{ uintptr_t reg_base = DEVICE_MMIO_GET(dev); uint32_t reg_val; do { reg_val = sys_read32(reg_base + XUARTPS_SR_OFFSET); } while ((reg_val & XUARTPS_SR_TXEMPTY) == 0); sys_write32((uint32_t)(c & 0xFF), reg_base + XUARTPS_FIFO_OFFSET); do { reg_val = sys_read32(reg_base + XUARTPS_SR_OFFSET); } while ((reg_val ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Get a directory entry from disk for the Ofile. */
STATIC EFI_STATUS FatAccessEntry(IN FAT_OFILE *Parent, IN IO_MODE IoMode, IN UINTN EntryPos, IN OUT VOID *Entry)
/* Get a directory entry from disk for the Ofile. */ STATIC EFI_STATUS FatAccessEntry(IN FAT_OFILE *Parent, IN IO_MODE IoMode, IN UINTN EntryPos, IN OUT VOID *Entry)
{ UINTN Position; UINTN BufferSize; Position = EntryPos * sizeof (FAT_DIRECTORY_ENTRY); if (Position >= Parent->FileSize) { ASSERT (IoMode == ReadData); ((FAT_DIRECTORY_ENTRY *)Entry)->FileName[0] = EMPTY_ENTRY_MARK; ((FAT_DIRECTORY_ENTRY *)Entry)->Attributes = 0; return EFI_SUCCESS; } Bu...
tianocore/edk2
C++
Other
4,240
/* wdrtas_timer_stop stops the watchdog timer by calling the RTAS function set-interval (surveillance) */
static void wdrtas_timer_stop(void)
/* wdrtas_timer_stop stops the watchdog timer by calling the RTAS function set-interval (surveillance) */ static void wdrtas_timer_stop(void)
{ wdrtas_set_interval(0); }
robutest/uclinux
C++
GPL-2.0
60
/* Program a word (16bit) in the flash device. */
int NORFLASH_ProgramWord16(uint32_t addr, uint16_t data)
/* Program a word (16bit) in the flash device. */ int NORFLASH_ProgramWord16(uint32_t addr, uint16_t data)
{ int status; if (!flashInitialized) { status = flashInterrogate(); if (status != NORFLASH_STATUS_OK) return status; } if (!NORFLASH_AddressValid(addr) || !NORFLASH_AddressValid(addr + 1)) { EFM_ASSERT(false); return NORFLASH_INVALID_ADDRESS; } if (addr & 1) return NORFLA...
remotemcu/remcu-chip-sdks
C++
null
436
/* convert a sampling rate into our full speed format (fs/1000 in Q16.16) this will overflow at approx 524 kHz */
static unsigned get_usb_full_speed_rate(unsigned int rate)
/* convert a sampling rate into our full speed format (fs/1000 in Q16.16) this will overflow at approx 524 kHz */ static unsigned get_usb_full_speed_rate(unsigned int rate)
{ return ((rate << 13) + 62) / 125; }
robutest/uclinux
C++
GPL-2.0
60
/* This function will set an usb device descriptor to a device. */
rt_err_t rt_usbd_device_set_descriptor(udevice_t device, udev_desc_t dev_desc)
/* This function will set an usb device descriptor to a device. */ rt_err_t rt_usbd_device_set_descriptor(udevice_t device, udev_desc_t dev_desc)
{ RT_ASSERT(device != RT_NULL); RT_ASSERT(dev_desc != RT_NULL); rt_memcpy((void *)&device->dev_desc, (void *)dev_desc, USB_DESC_LENGTH_DEVICE); return RT_EOK; }
pikasTech/PikaPython
C++
MIT License
1,403
/* SPI0 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */
void SPI0IntHandler(void)
/* SPI0 interrupt handler. Clear the SPI interrupt flag and execute the callback function. */ void SPI0IntHandler(void)
{ unsigned long ulEventFlags; unsigned long ulBase = SPI0_BASE; ulEventFlags = xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_IF; ulEventFlags |= xHWREG(ulBase + SPI_CNTRL2) & SPI_CNTRL2_SLV_START_INTSTS; xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_IF; xHWREG(ulBase + SPI_CNTRL2) |= SPI_CNTRL2_SLV_START_INT...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This file is part of the Simba project. */
int mock_write_xbee_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_xbee_module_init(int res)
{ harness_mock_write("xbee_module_init()", NULL, 0); harness_mock_write("xbee_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* 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)
{ UINT16 Data; __asm__ __volatile__ ( "mov %%ds, %0" :"=a" (Data) ); return Data; }
tianocore/edk2
C++
Other
4,240
/* sep_get_time_handler - time request from user space @sep: sep we are to set the time for */
static int sep_get_time_handler(struct sep_device *sep, unsigned long arg)
/* sep_get_time_handler - time request from user space @sep: sep we are to set the time for */ static int sep_get_time_handler(struct sep_device *sep, unsigned long arg)
{ struct sep_driver_get_time_t command_args; mutex_lock(&sep_mutex); command_args.time_value = sep_set_time(sep); command_args.time_physical_address = (unsigned long)sep_time_address(sep); mutex_unlock(&sep_mutex); if (copy_to_user((void __user *)arg, &command_args, sizeof(struct sep_driver_get_time_t))) re...
robutest/uclinux
C++
GPL-2.0
60
/* The following inlines stuffs a configuration parameter and data value into and out of an unsigned long argument, as used by the generic pin config system. We put the parameter in the lower 8 bits and the argument in the upper 24 bits. */
static pin_config_param_t pinconf_to_config_param(unsigned long config)
/* The following inlines stuffs a configuration parameter and data value into and out of an unsigned long argument, as used by the generic pin config system. We put the parameter in the lower 8 bits and the argument in the upper 24 bits. */ static pin_config_param_t pinconf_to_config_param(unsigned long config)
{ return (pin_config_param_t)(config & 0xffUL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* atl2_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */
static void __devexit atl2_remove(struct pci_dev *pdev)
/* atl2_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory. */ static void __devexit atl2_remove(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct atl2_adapter *adapter = netdev_priv(netdev); set_bit(__ATL2_DOWN, &adapter->flags); del_timer_sync(&adapter->watchdog_timer); del_timer_sync(&adapter->phy_config_timer); flush_scheduled_work(); unregister_netdev(netdev); atl2_force_ps(&adapter->hw); i...
robutest/uclinux
C++
GPL-2.0
60
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */
int32_t lsm6dso_xl_fast_settling_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Enables accelerometer LPF2 and HPF fast-settling mode. The filter sets the second samples after writing this bit. Active only during device exit from power-down mode.. */ int32_t lsm6dso_xl_fast_settling_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dso_ctrl8_xl_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL8_XL, (uint8_t *)&reg, 1); *val = reg.fastsettl_mode_xl; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Disables the selected interrupts sources on a TWI peripheral. */
void TWI_DisableIt(AT91S_TWI *pTwi, unsigned int sources)
/* Disables the selected interrupts sources on a TWI peripheral. */ void TWI_DisableIt(AT91S_TWI *pTwi, unsigned int sources)
{ SANITY_CHECK(pTwi); SANITY_CHECK((sources & 0xFFFFFEF8) == 0); pTwi->TWI_IDR = sources; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Sets a new class name to a CLASS additional selector. */
void cr_additional_sel_set_class_name(CRAdditionalSel *a_this, CRString *a_class_name)
/* Sets a new class name to a CLASS additional selector. */ void cr_additional_sel_set_class_name(CRAdditionalSel *a_this, CRString *a_class_name)
{ g_return_if_fail (a_this && a_this->type == CLASS_ADD_SELECTOR); if (a_this->content.class_name) { cr_string_destroy (a_this->content.class_name); } a_this->content.class_name = a_class_name; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* : details of nonlinear truncation or shared cache invalidation */
unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size, struct zap_details *details)
/* : details of nonlinear truncation or shared cache invalidation */ unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size, struct zap_details *details)
{ struct mm_struct *mm = vma->vm_mm; struct mmu_gather *tlb; unsigned long end = address + size; unsigned long nr_accounted = 0; lru_add_drain(); tlb = tlb_gather_mmu(mm, 0); update_hiwater_rss(mm); end = unmap_vmas(&tlb, vma, address, end, &nr_accounted, details); if (tlb) tlb_finish_mmu(tlb, address, end);...
robutest/uclinux
C++
GPL-2.0
60
/* 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)
{ BSP_LED_On(LED4); while(1) { } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This API reads the data from the given register continuously. */
BMA2x2_RETURN_FUNCTION_TYPE bma2x2_burst_read(u8 addr_u8, u8 *data_u8, u32 len_u32)
/* This API reads the data from the given register continuously. */ BMA2x2_RETURN_FUNCTION_TYPE bma2x2_burst_read(u8 addr_u8, u8 *data_u8, u32 len_u32)
{ BMA2x2_RETURN_FUNCTION_TYPE com_rslt = ERROR; if (p_bma2x2 == BMA2x2_NULL) { return E_BMA2x2_NULL_PTR; } else { com_rslt = p_bma2x2->BMA2x2_BURST_READ_FUNC (p_bma2x2->dev_addr, addr_u8, data_u8, len_u32); } return com_rslt; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* ipath_get_pkey - return the indexed PKEY from the port PKEY table @dd: the infinipath device @index: the PKEY index */
unsigned ipath_get_pkey(struct ipath_devdata *dd, unsigned index)
/* ipath_get_pkey - return the indexed PKEY from the port PKEY table @dd: the infinipath device @index: the PKEY index */ unsigned ipath_get_pkey(struct ipath_devdata *dd, unsigned index)
{ unsigned ret; if (index >= ARRAY_SIZE(dd->ipath_pd[0]->port_pkeys)) ret = 0; else ret = dd->ipath_pd[0]->port_pkeys[index]; return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Sends the CBW packet of the scsi MODE SENSE 6 command This function returns the write-protected mode. Field optional provided only by the LUN with a write protection feature. */
static void uhi_msc_scsi_mode_sense6(uhi_msc_scsi_callback_t callback)
/* Sends the CBW packet of the scsi MODE SENSE 6 command This function returns the write-protected mode. Field optional provided only by the LUN with a write protection feature. */ static void uhi_msc_scsi_mode_sense6(uhi_msc_scsi_callback_t callback)
{ uhi_msc_scsi_callback = callback; uhi_msc_cbw.dCBWDataTransferLength = sizeof(uhi_msc_sense6); uhi_msc_cbw.bmCBWFlags = USB_CBW_DIRECTION_IN; uhi_msc_cbw.bCBWCBLength = 6; memset(uhi_msc_cbw.CDB, 0, sizeof(uhi_msc_cbw.CDB)); uhi_msc_cbw.CDB[0] = SPC_MODE_SENSE6; uhi_msc_cbw.CDB[2] = SCSI_MS_MODE_INFEXP; uhi_m...
remotemcu/remcu-chip-sdks
C++
null
436
/* Stops the output compare signal generation on the designed timer output. */
void HRTIM_SimpleOCStop(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t OCChannel)
/* Stops the output compare signal generation on the designed timer output. */ void HRTIM_SimpleOCStop(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t OCChannel)
{ assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel)); HRTIMx->HRTIM_COMMON.DISR |= OCChannel; __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Linear acceleration output register. The value is expressed as a 16-bit word in two’s complement.. */
int32_t lsm6dso_acceleration_raw_get(stmdev_ctx_t *ctx, int16_t *val)
/* Linear acceleration output register. The value is expressed as a 16-bit word in two’s complement.. */ int32_t lsm6dso_acceleration_raw_get(stmdev_ctx_t *ctx, int16_t *val)
{ uint8_t buff[6]; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_OUTX_L_A, buff, 6); val[0] = (int16_t)buff[1]; val[0] = (val[0] * 256) + (int16_t)buff[0]; val[1] = (int16_t)buff[3]; val[1] = (val[1] * 256) + (int16_t)buff[2]; val[2] = (int16_t)buff[5]; val[2] = (val[2] * 256) + (int16_t)buff[4]; ...
eclipse-threadx/getting-started
C++
Other
310
/* In this context, the devices behind a port multiplier constitute a channel. */
EFI_STATUS EFIAPI IdeInitGetChannelInfo(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, OUT BOOLEAN *Enabled, OUT UINT8 *MaxDevices)
/* In this context, the devices behind a port multiplier constitute a channel. */ EFI_STATUS EFIAPI IdeInitGetChannelInfo(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, OUT BOOLEAN *Enabled, OUT UINT8 *MaxDevices)
{ if (Channel < ICH_IDE_MAX_CHANNEL) { *Enabled = TRUE; *MaxDevices = ICH_IDE_MAX_DEVICES; return EFI_SUCCESS; } *Enabled = FALSE; return EFI_INVALID_PARAMETER; }
tianocore/edk2
C++
Other
4,240
/* Force a net-interface to dial out. This is always called from within userspace (ISDN_IOCTL_NET_DIAL). */
int isdn_net_force_dial(char *name)
/* Force a net-interface to dial out. This is always called from within userspace (ISDN_IOCTL_NET_DIAL). */ int isdn_net_force_dial(char *name)
{ isdn_net_dev *p = isdn_net_findif(name); if (!p) return -ENODEV; return (isdn_net_force_dial_lp(p->local)); }
robutest/uclinux
C++
GPL-2.0
60
/* Determines the FsType_t of a file handle. Determines the FsType_t of the specified file handle and returns it to the caller. */
FsType_t FileSystemType(int32_t handleNumber)
/* Determines the FsType_t of a file handle. Determines the FsType_t of the specified file handle and returns it to the caller. */ FsType_t FileSystemType(int32_t handleNumber)
{ if (handleNumber >= FAT_HANDLE_MIN && handleNumber <= FAT_HANDLE_MAX) { return FS_TYPE_FAT; } else if (handleNumber >= RESOURCE_HANDLE_MIN && handleNumber <= RESOURCE_HANDLE_MAX) { return FS_TYPE_RESOURCE; } else { return FS_TYPE_MAX; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @str: string with prefix @prefix: prefix string Return: string without prefix, or NULL if prefix not found */
static const char* prefix(const char *str, const char *prefix)
/* @str: string with prefix @prefix: prefix string Return: string without prefix, or NULL if prefix not found */ static const char* prefix(const char *str, const char *prefix)
{ size_t n = strlen(prefix); if (!strncmp(prefix, str, n)) return str + n; return NULL; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Get contents of register REGNO in task TASK. */
static long get_reg(struct task_struct *task, int regno)
/* Get contents of register REGNO in task TASK. */ static long get_reg(struct task_struct *task, int regno)
{ struct user_context *user = task->thread.user; if (regno < 0 || regno >= PT__END) return 0; return ((unsigned long *) user)[regno]; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check the WP status in CR0 register. This bit is used to lock or unlock write access to pages marked as read-only. */
STATIC BOOLEAN IsReadOnlyPageWriteProtected(VOID)
/* Check the WP status in CR0 register. This bit is used to lock or unlock write access to pages marked as read-only. */ STATIC BOOLEAN IsReadOnlyPageWriteProtected(VOID)
{ return ((AsmReadCr0 () & BIT16) != 0); }
tianocore/edk2
C++
Other
4,240
/* Circular burst-mode (rounding) read from output registers through the primary interface.. */
int32_t lsm6dsl_rounding_mode_set(stmdev_ctx_t *ctx, lsm6dsl_rounding_t val)
/* Circular burst-mode (rounding) read from output registers through the primary interface.. */ int32_t lsm6dsl_rounding_mode_set(stmdev_ctx_t *ctx, lsm6dsl_rounding_t val)
{ lsm6dsl_ctrl5_c_t ctrl5_c; int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t*)&ctrl5_c, 1); if(ret == 0){ ctrl5_c.rounding = (uint8_t) val; ret = lsm6dsl_write_reg(ctx, LSM6DSL_CTRL5_C, (uint8_t*)&ctrl5_c, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Checks if the given "compat" string matches one of the strings in the device's "compatible" property */
int of_device_is_compatible(const struct device_node *device, const char *compat)
/* Checks if the given "compat" string matches one of the strings in the device's "compatible" property */ int of_device_is_compatible(const struct device_node *device, const char *compat)
{ const char* cp; int cplen, l; cp = of_get_property(device, "compatible", &cplen); if (cp == NULL) return 0; while (cplen > 0) { if (of_compat_cmp(cp, compat, strlen(compat)) == 0) return 1; l = strlen(cp) + 1; cp += l; cplen -= l; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* arch_hibernation_header_save - populate the architecture specific part of a hibernation image header @addr: address to save the data at */
int arch_hibernation_header_save(void *addr, unsigned int max_size)
/* arch_hibernation_header_save - populate the architecture specific part of a hibernation image header @addr: address to save the data at */ int arch_hibernation_header_save(void *addr, unsigned int max_size)
{ struct restore_data_record *rdr = addr; if (max_size < sizeof(struct restore_data_record)) return -EOVERFLOW; rdr->jump_address = restore_jump_address; rdr->cr3 = restore_cr3; rdr->magic = RESTORE_MAGIC; return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function initializes the comparator configuration structure to these default values: code config->enableStopMode = false; config->enableOutputPin = false; config->useUnfilteredOutput = false; config->enableInvertOutput = false; config->hysteresisMode = kLPCMP_HysteresisLevel0; config->powerMode = kLPCMP_LowSpee...
void LPCMP_GetDefaultConfig(lpcmp_config_t *config)
/* This function initializes the comparator configuration structure to these default values: code config->enableStopMode = false; config->enableOutputPin = false; config->useUnfilteredOutput = false; config->enableInvertOutput = false; config->hysteresisMode = kLPCMP_HysteresisLevel0; config->powerMode = kLPCMP_LowSpee...
{ (void)memset(config, 0, sizeof(*config)); config->enableStopMode = false; config->enableOutputPin = false; config->useUnfilteredOutput = false; config->enableInvertOutput = false; config->hysteresisMode = kLPCMP_HysteresisLevel0; config->powerMode = kLPCMP_LowSpeed...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Description: Remove an existing CIPSO DOI definition matching @doi. Returns zero on success and negative values on failure. */
void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info)
/* Description: Remove an existing CIPSO DOI definition matching @doi. Returns zero on success and negative values on failure. */ void netlbl_cfg_cipsov4_del(u32 doi, struct netlbl_audit *audit_info)
{ cipso_v4_doi_remove(doi, audit_info); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function set the QSPI memory in 4-byte address mode. */
static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi)
/* This function set the QSPI memory in 4-byte address mode. */ static uint8_t QSPI_EnterFourBytesAddress(QSPI_HandleTypeDef *hqspi)
{ QSPI_CommandTypeDef s_command; s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE; s_command.Instruction = ENTER_4_BYTE_ADDR_MODE_CMD; s_command.AddressMode = QSPI_ADDRESS_NONE; s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; s_command.DataMode = QSPI_DATA_NONE; s_comman...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Change the bus mode (open drain/push-pull) of a host. */
void mmcsd_set_bus_mode(struct rt_mmcsd_host *host, rt_uint32_t mode)
/* Change the bus mode (open drain/push-pull) of a host. */ void mmcsd_set_bus_mode(struct rt_mmcsd_host *host, rt_uint32_t mode)
{ host->io_cfg.bus_mode = mode; mmcsd_set_iocfg(host); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Update the value of an 32-bit PCI configuration register in a PCI device. If the PCI Configuration register specified by PciAddress is already programmed with a non-zero value, then return the current value. Otherwise update the PCI configuration register specified by PciAddress with the value specified by Value and...
UINT32 SerialPortLibUpdatePciRegister32(UINTN PciAddress, UINT32 Value, UINT32 Mask)
/* Update the value of an 32-bit PCI configuration register in a PCI device. If the PCI Configuration register specified by PciAddress is already programmed with a non-zero value, then return the current value. Otherwise update the PCI configuration register specified by PciAddress with the value specified by Value and...
{ UINT32 CurrentValue; CurrentValue = PciRead32 (PciAddress) & Mask; if (CurrentValue != 0) { return CurrentValue; } return PciWrite32 (PciAddress, Value & Mask); }
tianocore/edk2
C++
Other
4,240
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */ void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIMOUTEN; } else { I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMOUTEN); } }
ajhc/demo-cortex-m3
C++
null
38
/* Specifies if the next DMA transfer will be the last one. */
void I2C_EnableDmaLastSend(I2C_Module *I2Cx, FunctionalState Cmd)
/* Specifies if the next DMA transfer will be the last one. */ void I2C_EnableDmaLastSend(I2C_Module *I2Cx, FunctionalState Cmd)
{ assert_param(IS_I2C_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(Cmd)); if (Cmd != DISABLE) { I2Cx->CTRL2 |= CTRL2_DMALAST_SET; } else { I2Cx->CTRL2 &= CTRL2_DMALAST_RESET; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Check to see if a character is available from GDB. Do not read the character as that is done via */
BOOLEAN EFIAPI GdbIsCharAvailable(VOID)
/* Check to see if a character is available from GDB. Do not read the character as that is done via */ BOOLEAN EFIAPI GdbIsCharAvailable(VOID)
{ UINT8 Data; Data = IoRead8 (gPort + LSR_OFFSET); return ((Data & LSR_RXDA) == LSR_RXDA); }
tianocore/edk2
C++
Other
4,240
/* Returns actual value of the capture register of the designated capture unit. */
uint32_t HRTIM_GetCapturedValue(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t CaptureUnit)
/* Returns actual value of the capture register of the designated capture unit. */ uint32_t HRTIM_GetCapturedValue(HRTIM_TypeDef *HRTIMx, uint32_t TimerIdx, uint32_t CaptureUnit)
{ uint32_t captured_value = 0; assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx)); assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit)); switch (CaptureUnit) { case HRTIM_CAPTUREUNIT_1: { captured_value = HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xR; } break; case HRTIM_CAPTUREUNIT_2: { capt...
remotemcu/remcu-chip-sdks
C++
null
436
/* Determine if a particular character is a digital character */
int isdchar(int c)
/* Determine if a particular character is a digital character */ int isdchar(int c)
{ return ((('0' <= (c)) && ((c) <= '9')) || (c == 'e') || (c == 'E') || (c == '+') || (c == '-') || (c == '.')); }
tianocore/edk2
C++
Other
4,240
/* Lock a given peripheral's control registers until hardware reset. Locks a given peripheral's control registers, to deny write access to the peripheral to prevent accidental changes to the module's configuration. After lock, the only way to unlock is hardware reset. */
__no_inline enum status_code system_peripheral_lock_always(const uint32_t peripheral_id, const uint32_t key)
/* Lock a given peripheral's control registers until hardware reset. Locks a given peripheral's control registers, to deny write access to the peripheral to prevent accidental changes to the module's configuration. After lock, the only way to unlock is hardware reset. */ __no_inline enum status_code system_peripheral_...
{ if (~peripheral_id != key) { Assert(false); return STATUS_ERR_INVALID_ARG; } PAC->WRCTRL.reg = peripheral_id | PAC_WRCTRL_KEY(PAC_WRCTRL_KEY_SETLCK_Val); return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Write a data buffer to the slave, when the master have obtained 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 This function is always used in thread mode. */ unsigned long xI2CMasterWriteBufS2(unsigned long ulBase, unsigned char *pucDataBuf, unsigned long ulLen, xtBoolean bEndTransmition)
{ unsigned long i; unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); xASSERT(pucDataBuf); for(i = 0; i < ulLen - 1; i++) { ulStatus = I2CByteSend(ulBase, *pucDataBuf++); if(!(ulStatus == I2C_I2STAT_M_TX_DAT_ACK)) ...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Changes the state of a network interface from "stopped" to "started". */
EFI_STATUS EmuSnpStart(IN EMU_SNP_PROTOCOL *This)
/* Changes the state of a network interface from "stopped" to "started". */ EFI_STATUS EmuSnpStart(IN EMU_SNP_PROTOCOL *This)
{ EMU_SNP_PRIVATE *Private; Private = EMU_SNP_PRIVATE_DATA_FROM_THIS (This); return EFI_UNSUPPORTED; }
tianocore/edk2
C++
Other
4,240
/* 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)
{ assert(BOOTLOADER_API_TREE_POINTER); return BOOTLOADER_API_TREE_POINTER->flashDriver->flash_erase(config, start, lengthInBytes, key); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Redraw window and its contents, if visible. This function redraws a window, if it is mapped and visible. Use this function to refresh graphics if e.g. a widget's state is changed. */
void win_redraw(struct win_window *win)
/* Redraw window and its contents, if visible. This function redraws a window, if it is mapped and visible. Use this function to refresh graphics if e.g. a widget's state is changed. */ void win_redraw(struct win_window *win)
{ if (win_is_visible(win)) { const struct win_area *dirty_area = &win->attributes.area; win_draw(win, dirty_area); } }
memfault/zero-to-main
C++
null
200
/* Lookup destination by {addr,port} in the given service */
static struct ip_vs_dest* ip_vs_lookup_dest(struct ip_vs_service *svc, const union nf_inet_addr *daddr, __be16 dport)
/* Lookup destination by {addr,port} in the given service */ static struct ip_vs_dest* ip_vs_lookup_dest(struct ip_vs_service *svc, const union nf_inet_addr *daddr, __be16 dport)
{ struct ip_vs_dest *dest; list_for_each_entry(dest, &svc->destinations, n_list) { if ((dest->af == svc->af) && ip_vs_addr_equal(svc->af, &dest->addr, daddr) && (dest->port == dport)) { return dest; } } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function will install a interrupt service routine to a interrupt. */
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, char *name)
/* This function will install a interrupt service routine to a interrupt. */ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, char *name)
{ rt_isr_handler_t old_handler = RT_NULL; if(vector >= 0 && vector < MAX_HANDLERS) { rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2)); *vect_ctl = 0x20 | (vector & 0x1F); old_handler = irq_desc[vector].handler; if (handler != RT_NULL) { irq_desc[...
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */
int main(void)
/* Main program entry point. This routine configures the hardware required by the application, then enters a loop to run the application tasks in sequence. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); while (RunBootloader || TicksSinceLastCommand++ < 0xFF) { MS_Device_USBTask(&Disk_MS_Interface); USB_USBTask(); } _delay_us(1000); USB_Detach(); MagicBootKey = MAGIC_BOOT_KEY; wdt_enable(WDTO_250MS); for (;;); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Look for the bString that has the address equal to the ptr and return its index. Use it to determine the index of the bString and assign it to the interfaces iInterface variable. */
int usb_get_str_descriptor_idx(void *ptr)
/* Look for the bString that has the address equal to the ptr and return its index. Use it to determine the index of the bString and assign it to the interfaces iInterface variable. */ int usb_get_str_descriptor_idx(void *ptr)
{ struct usb_desc_header *head = __usb_descriptor_start; struct usb_string_descriptor *str = ptr; int str_descr_idx = 0; while (head->bLength != 0U) { switch (head->bDescriptorType) { case USB_DESC_STRING: if (head == (struct usb_desc_header *)str) { return str_descr_idx; } str_descr_idx += 1; b...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Get an ISA pressure altitude. Given atmospheric pressure "P" in pascals, this routine returns the associated barometric altitude ("pressure altitude") using International Standard Atmosphere (ISA) pressure model coefficients and equations. */
scalar pressure_altitude(scalar P)
/* Get an ISA pressure altitude. Given atmospheric pressure "P" in pascals, this routine returns the associated barometric altitude ("pressure altitude") using International Standard Atmosphere (ISA) pressure model coefficients and equations. */ scalar pressure_altitude(scalar P)
{ const scalar del ((P - P_bias) / Pb); if (Lb) { return (Hb + ((Tb / Lb) * (pow(del, RL_g0) - 1))); } else { return (Hb + (RT_g0 * log(del))); } }
memfault/zero-to-main
C++
null
200
/* enable/disable the glitch filter. mostly used with IRQ handling. */
int at91_pio3_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
/* enable/disable the glitch filter. mostly used with IRQ handling. */ int at91_pio3_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
{ struct at91_port *at91_port = at91_pio_get_port(port); u32 mask; if (at91_port && (pin < GPIO_PER_BANK)) { mask = 1 << pin; if (is_on) { writel(mask, &at91_port->mux.pio3.ifscdr); writel(mask, &at91_port->ifer); } else { writel(mask, &at91_port->ifdr); } } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Reads the next LED status report from the host from the LED data endpoint, if one has been sent. */
void ReceiveNextReport(void)
/* Reads the next LED status report from the host from the LED data endpoint, if one has been sent. */ void ReceiveNextReport(void)
{ Endpoint_SelectEndpoint(KEYBOARD_OUT_EPADDR); if (Endpoint_IsOUTReceived()) { if (Endpoint_IsReadWriteAllowed()) { uint8_t LEDReport = Endpoint_Read_8(); ProcessLEDReport(LEDReport); } Endpoint_ClearOUT(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Close all devices that were opened as part of multiplexed device. Note that this function is called with mousedev_mix->mutex held. */
static void mixdev_close_devices(void)
/* Close all devices that were opened as part of multiplexed device. Note that this function is called with mousedev_mix->mutex held. */ static void mixdev_close_devices(void)
{ struct mousedev *mousedev; if (--mousedev_mix->open) return; list_for_each_entry(mousedev, &mousedev_mix_list, mixdev_node) { if (mousedev->mixdev_open) { mousedev->mixdev_open = 0; mousedev_close_device(mousedev); } } }
robutest/uclinux
C++
GPL-2.0
60
/* Note the largest count value of 0xffff corresponds to: 0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns which fits in 21 bits, so we'll use unsigned int for time arguments. */
static u16 count_to_lpf_count(unsigned int d)
/* Note the largest count value of 0xffff corresponds to: 0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns which fits in 21 bits, so we'll use unsigned int for time arguments. */ static u16 count_to_lpf_count(unsigned int d)
{ if (d > FILTR_LPF) d = FILTR_LPF; else if (d < 4) d = 0; return (u16) d; }
robutest/uclinux
C++
GPL-2.0
60
/* Detect host devices. By convention, /dev/cdrom is always recognized as a host CDROM. */
static BlockDriver* find_hdev_driver(const char *filename)
/* Detect host devices. By convention, /dev/cdrom is always recognized as a host CDROM. */ static BlockDriver* find_hdev_driver(const char *filename)
{ int score_max = 0, score; BlockDriver *drv = NULL, *d; QLIST_FOREACH(d, &bdrv_drivers, list) { if (d->bdrv_probe_device) { score = d->bdrv_probe_device(filename); if (score > score_max) { score_max = score; drv = d; } } ...
ve3wwg/teensy3_qemu
C
Other
15
/* 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_O_TISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_O_TISR) = ulTemp0; ulTemp1 = (xHWREG(ulBase + TIMER_O_TEISR) & TIMER_TISR_TIF); xHWREG(ulBase + TIMER_O_TEISR) = ulTemp1; if (g_pfnTimerHandl...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Acquires semaphore then reads the PHY register at offset and stores the retrieved information in data. Release the acquired semaphore before exiting. */
s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data)
/* Acquires semaphore then reads the PHY register at offset and stores the retrieved information in data. Release the acquired semaphore before exiting. */ s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data)
{ return __e1000_read_phy_reg_hv(hw, offset, data, false); }
robutest/uclinux
C++
GPL-2.0
60
/* Write arguments. Splice the buffer to be written into the iovec. */
static int nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
/* Write arguments. Splice the buffer to be written into the iovec. */ static int nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
{ struct xdr_buf *sndbuf = &req->rq_snd_buf; u32 offset = (u32)args->offset; u32 count = args->count; p = xdr_encode_fhandle(p, args->fh); *p++ = htonl(offset); *p++ = htonl(offset); *p++ = htonl(count); *p++ = htonl(count); sndbuf->len = xdr_adjust_iovec(sndbuf->head, p); xdr_encode_pages(sndbuf, args->pages...
robutest/uclinux
C++
GPL-2.0
60
/* Check to see if CURLOPT_TIMECONDITION was met by comparing the time of the remote document with the time provided by CURLOPT_TIMEVAL */
bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc)
/* Check to see if CURLOPT_TIMECONDITION was met by comparing the time of the remote document with the time provided by CURLOPT_TIMEVAL */ bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc)
{ if((timeofdoc == 0) || (data->set.timevalue == 0)) return TRUE; switch(data->set.timecondition) { case CURL_TIMECOND_IFMODSINCE: default: if(timeofdoc <= data->set.timevalue) { infof(data, "The requested document is not new enough\n"); data->info.timecond = TRUE; return F...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Check any of the specified flag is set or not. */
en_flag_status_t EFM_GetAnyStatus(uint32_t u32Flag)
/* Check any of the specified flag is set or not. */ en_flag_status_t EFM_GetAnyStatus(uint32_t u32Flag)
{ DDL_ASSERT(IS_EFM_FLAG(u32Flag)); return ((0UL == READ_REG32_BIT(CM_EFM->FSR, u32Flag)) ? RESET : SET); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */
__isl_give isl_morph* isl_morph_alloc(__isl_take isl_basic_set *dom, __isl_take isl_basic_set *ran, __isl_take isl_mat *map, __isl_take isl_mat *inv)
/* Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France */ __isl_give isl_morph* isl_morph_alloc(__isl_take isl_basic_set *dom, __isl_take isl_basic_set *ran, __isl_take isl_mat *map, __isl_take isl_mat *inv)
{ isl_morph *morph; if (!dom || !ran || !map || !inv) goto error; morph = isl_alloc_type(dom->ctx, struct isl_morph); if (!morph) goto error; morph->ref = 1; morph->dom = dom; morph->ran = ran; morph->map = map; morph->inv = inv; return morph; error: isl_basic_set_free(dom); isl_basic_set_free(ran); is...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* You feed the card a command, you wait, it interrupts you get a reply. All well and good. The complication arises because you use commands for filter list changes which come in at bh level from things like IPV6 group stuff. */
static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len)
/* You feed the card a command, you wait, it interrupts you get a reply. All well and good. The complication arises because you use commands for filter list changes which come in at bh level from things like IPV6 group stuff. */ static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len)
{ struct mc32_local *lp = netdev_priv(dev); int ioaddr = dev->base_addr; int ret = 0; down(&lp->cmd_mutex); lp->cmd_nonblocking=0; lp->exec_box->mbox=0; lp->exec_box->mbox=cmd; memcpy((void *)lp->exec_box->data, data, len); barrier(); mc32_ready_poll(dev); outb(1<<6, ioaddr+HOST_CMD); wait_for_completion(&l...
robutest/uclinux
C++
GPL-2.0
60
/* tipc_send2name - send message sections to port name */
int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, unsigned int num_sect, struct iovec const *msg_sect)
/* tipc_send2name - send message sections to port name */ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, unsigned int num_sect, struct iovec const *msg_sect)
{ struct tipc_portid orig; orig.ref = ref; orig.node = tipc_own_addr; return tipc_forward2name(ref, name, domain, num_sect, msg_sect, &orig, TIPC_PORT_IMPORTANCE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */
int main(void)
/* Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop. */ int main(void)
{ SetupHardware(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { CDC_Task(); USB_USBTask(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Pops @cancellable off the cancellable stack (verifying that @cancellable is on the top of the stack). */
void g_cancellable_pop_current(GCancellable *cancellable)
/* Pops @cancellable off the cancellable stack (verifying that @cancellable is on the top of the stack). */ void g_cancellable_pop_current(GCancellable *cancellable)
{ GSList *l; l = g_private_get (&current_cancellable); g_return_if_fail (l != NULL); g_return_if_fail (l->data == cancellable); l = g_slist_delete_link (l, l); g_private_set (&current_cancellable, l); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* brief Initializes the DMIC handle which is used in transactional functions. param base DMIC peripheral base address. param handle Pointer to dmic_dma_handle_t structure. param callback Callback function. param userData User data. param rxDmaHandle User-requested DMA handle for RX DMA transfer. */
status_t DMIC_TransferCreateHandleDMA(DMIC_Type *base, dmic_dma_handle_t *handle, dmic_dma_transfer_callback_t callback, void *userData, dma_handle_t *rxDmaHandle)
/* brief Initializes the DMIC handle which is used in transactional functions. param base DMIC peripheral base address. param handle Pointer to dmic_dma_handle_t structure. param callback Callback function. param userData User data. param rxDmaHandle User-requested DMA handle for RX DMA transfer. */ status_t DMIC_Tran...
{ assert(NULL != base); assert(NULL != handle); assert(NULL != rxDmaHandle); (void)memset(handle, 0, sizeof(*handle)); handle->callback = callback; handle->userData = userData; handle->rxDmaHandle = rxDmaHandle; handle->state = kDMIC_Idle; DMA_SetCallback(rxDmaHandle, DMIC_Tran...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the boards on-board LEDs (LED1 to LED4) The LEDs are connected to the following pins: */
static void leds_init(void)
/* Initialize the boards on-board LEDs (LED1 to LED4) The LEDs are connected to the following pins: */ static void leds_init(void)
{ LED_PORT->FIODIR |= (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN); LED_PORT->FIOCLR = (LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN); }
labapart/polymcu
C++
null
201
/* Setup the base address and interrupt of the Au1xxx ethernet macs based on cpu type and whether the interface is enabled in sys_pinfunc register. The last interface is enabled if SYS_PF_NI2 (bit 4) is 0. */
static int __init au1000_init_module(void)
/* Setup the base address and interrupt of the Au1xxx ethernet macs based on cpu type and whether the interface is enabled in sys_pinfunc register. The last interface is enabled if SYS_PF_NI2 (bit 4) is 0. */ static int __init au1000_init_module(void)
{ int ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4); struct net_device *dev; int i, found_one = 0; num_ifs = NUM_ETH_INTERFACES - ni; for(i = 0; i < num_ifs; i++) { dev = au1000_probe(i); iflist[i].dev = dev; if (dev) found_one++; } if (!found_one) return -ENODEV; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function should not be in .ramcode, because it will be called only once before self-upgrade. */
void envm_init(void)
/* This function should not be in .ramcode, because it will be called only once before self-upgrade. */ void envm_init(void)
{ lpc43xn_iap_init(); }
EmcraftSystems/u-boot
C++
Other
181
/* OS entry point to allow host driver to alloc memory for each scsi target. Called once per device the bus scan. Return non-zero if allocation fails. */
static int mptfc_target_alloc(struct scsi_target *starget)
/* OS entry point to allow host driver to alloc memory for each scsi target. Called once per device the bus scan. Return non-zero if allocation fails. */ static int mptfc_target_alloc(struct scsi_target *starget)
{ VirtTarget *vtarget; struct fc_rport *rport; struct mptfc_rport_info *ri; int rc; vtarget = kzalloc(sizeof(VirtTarget), GFP_KERNEL); if (!vtarget) return -ENOMEM; starget->hostdata = vtarget; rc = -ENODEV; rport = starget_to_rport(starget); if (rport) { ri = *((struct mptfc_rport_info **)rport->dd_d...
robutest/uclinux
C++
GPL-2.0
60
/* Writes NumberOfBytes data bytes from Buffer to the serial device. The number of bytes actually written to the serial device is returned. If the return value is less than NumberOfBytes, then the write operation failed. If NumberOfBytes is zero, then return 0. */
UINTN EFIAPI SerialPortWrite(IN UINT8 *Buffer, IN UINTN NumberOfBytes)
/* Writes NumberOfBytes data bytes from Buffer to the serial device. The number of bytes actually written to the serial device is returned. If the return value is less than NumberOfBytes, then the write operation failed. If NumberOfBytes is zero, then return 0. */ UINTN EFIAPI SerialPortWrite(IN UINT8 *Buffer, IN UINTN...
{ if (NumberOfBytes == 0) { return 0; } if (mHaveDbcn) { return SbiDbcnWrite (Buffer, NumberOfBytes); } else if (mHaveLegacyPutchar) { return SbiLegacyPutchar (Buffer, NumberOfBytes); } return 0; }
tianocore/edk2
C++
Other
4,240
/* @event: event Return: true if event is queued */
static bool efi_event_is_queued(struct efi_event *event)
/* @event: event Return: true if event is queued */ static bool efi_event_is_queued(struct efi_event *event)
{ return !!event->queue_link.next; }
4ms/stm32mp1-baremetal
C++
Other
137
/* If discovery is not enabled, you should call this function again after 1 or 2 seconds (i.e. after discovery has been done). */
struct irda_device_info* irlmp_get_discoveries(int *pn, __u16 mask, int nslots)
/* If discovery is not enabled, you should call this function again after 1 or 2 seconds (i.e. after discovery has been done). */ struct irda_device_info* irlmp_get_discoveries(int *pn, __u16 mask, int nslots)
{ if (!sysctl_discovery) { if (nslots == DISCOVERY_DEFAULT_SLOTS) nslots = sysctl_discovery_slots; irlmp_do_discovery(nslots); } return(irlmp_copy_discoveries(irlmp->cachelog, pn, mask, TRUE)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Configures external clock mode of the GPTM. Used ETI as the clock source. The */
void TimerETIExtClkConfigure(unsigned long ulBase, unsigned long ulEXIPrescale, unsigned long ulEXIPolarity, unsigned char ucFilter)
/* Configures external clock mode of the GPTM. Used ETI as the clock source. The */ void TimerETIExtClkConfigure(unsigned long ulBase, unsigned long ulEXIPrescale, unsigned long ulEXIPolarity, unsigned char ucFilter)
{ xASSERT((ulBase == TIMER1_BASE) || (ulBase == TIMER0_BASE)); xASSERT((ulEXIPrescale == TIMER_ETIPSC_OFF) || (ulEXIPrescale == TIMER_ETIPSC_2) || (ulEXIPrescale == TIMER_ETIPSC_4) || (ulEXIPrescale == TIMER_ETIPSC_8)); xASSERT((ulEXIPolarity == TIMER_ETIPOL_NONINVERTED)...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge. */
void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
/* Enables or Disables the RTC TimeStamp functionality with the specified time stamp pin stimulating edge. */ void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState)
{ uint32_t tmpreg = 0; assert_param(IS_RTC_TIMESTAMP_EDGE(RTC_TimeStampEdge)); assert_param(IS_FUNCTIONAL_STATE(NewState)); tmpreg = (uint32_t)(RTC->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE)); if (NewState != DISABLE) { tmpreg |= (uint32_t)(RTC_TimeStampEdge | RTC_CR_TSE); } e...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Disable the PWM output of the PWM module. The */
void PWMOutputDisable(unsigned long ulBase, unsigned long ulChannel)
/* Disable the PWM output of the PWM module. The */ void PWMOutputDisable(unsigned long ulBase, unsigned long ulChannel)
{ unsigned long ulChannelTemp; ulChannelTemp = (ulBase == PWMA_BASE) ? ulChannel : (ulChannel - 4); xASSERT(ulBase == PWMA_BASE); xASSERT(((ulChannelTemp >= 0) || (ulChannelTemp <= 3))); xHWREG(ulBase + PWM_POE) &= ~(PWM_POE_PWM0 << (ulChannelTemp)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104