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
/* Waits a SETUP packet and load data in main_setup_packet. */
static void main_usb_wait_setup_packet(void)
/* Waits a SETUP packet and load data in main_setup_packet. */ static void main_usb_wait_setup_packet(void)
{ while (!Is_udd_setup_received(0)); Assert(8 == udd_byte_count(0)); uint8_t *ptr = (uint8_t *) & udd_get_endpoint_fifo_access(0,8); for (uint8_t i = 0; i < 8; i++) { ((uint8_t*) &main_setup_packet)[i] = *ptr++; } udd_ack_setup_received(0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Change Logs: Date Author Notes Bernard add file header export bsd socket symbol for RT-Thread Application Module Bernard add lock for init_done callback. MurphyZhao port to lwip2.1.0 Initialize the network interface device */
static err_t netif_device_init(struct netif *netif)
/* Change Logs: Date Author Notes Bernard add file header export bsd socket symbol for RT-Thread Application Module Bernard add lock for init_done callback. MurphyZhao port to lwip2.1.0 Initialize the network interface device */ static err_t netif_device_init(struct netif *netif)
{ struct eth_device *ethif; ethif = (struct eth_device *)netif->state; if (ethif != RT_NULL) { rt_device_t device; device = (rt_device_t) ethif; if (rt_device_init(device) != RT_EOK) { return ERR_IF; } netif->flags = ethif->flags; netif->mtu = ETHERNET_MTU; netif->output = etharp_output; return ERR_OK; } return ERR_IF; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations. */
UINTN EFIAPI Sha512GetContextSize(VOID)
/* Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations. */ UINTN EFIAPI Sha512GetContextSize(VOID)
{ return (UINTN)(sizeof (SHA512_CTX)); }
tianocore/edk2
C++
Other
4,240
/* IOA requires hard reset if any of the following conditions is true. */
static void pmcraid_reset_type(struct pmcraid_instance *pinstance)
/* IOA requires hard reset if any of the following conditions is true. */ static void pmcraid_reset_type(struct pmcraid_instance *pinstance)
{ u32 mask; u32 intrs; u32 alerts; mask = ioread32(pinstance->int_regs.ioa_host_interrupt_mask_reg); intrs = ioread32(pinstance->int_regs.ioa_host_interrupt_reg); alerts = ioread32(pinstance->int_regs.host_ioa_interrupt_reg); if ((mask & INTRS_HRRQ_VALID) == 0 || (alerts & DOORBELL_IOA_RESET_ALERT) || (intrs & PMCRAID_ERROR_INTERRUPTS)) { pmcraid_info("IOA requires hard reset\n"); pinstance->ioa_hard_reset = 1; } if (intrs & INTRS_IOA_UNIT_CHECK) pinstance->ioa_unit_check = 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Place the data bus in a high impedance state, if */
static void parport_ip32_data_reverse(struct parport *p)
/* Place the data bus in a high impedance state, if */ static void parport_ip32_data_reverse(struct parport *p)
{ __parport_ip32_frob_control(p, DCR_DIR, DCR_DIR); }
robutest/uclinux
C++
GPL-2.0
60
/* Enable Auto-Reload Buffering. During counter operation this causes the counter to be loaded from its auto-reload register only at the next update event. */
void timer_enable_preload(uint32_t timer_peripheral)
/* Enable Auto-Reload Buffering. During counter operation this causes the counter to be loaded from its auto-reload register only at the next update event. */ void timer_enable_preload(uint32_t timer_peripheral)
{ TIM_CR1(timer_peripheral) |= TIM_CR1_ARPE; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* each module has a separate wait call, create a thread for each module that we are using. */
static void vcard_emul_new_event_thread(SECMODModule *module)
/* each module has a separate wait call, create a thread for each module that we are using. */ static void vcard_emul_new_event_thread(SECMODModule *module)
{ PR_CreateThread(PR_SYSTEM_THREAD, vcard_emul_event_thread, module, PR_PRIORITY_HIGH, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); }
ve3wwg/teensy3_qemu
C++
Other
15
/* Set Timer DMA Requests on Update Events. Update events will cause DMA requests to be generated. */
void timer_set_dma_on_update_event(uint32_t timer_peripheral)
/* Set Timer DMA Requests on Update Events. Update events will cause DMA requests to be generated. */ void timer_set_dma_on_update_event(uint32_t timer_peripheral)
{ TIM_CR2(timer_peripheral) |= TIM_CR2_CCDS; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* param base SAI base pointer param mask Channel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled. */
void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
/* param base SAI base pointer param mask Channel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled. */ void SAI_TxSetChannelFIFOMask(I2S_Type *base, uint8_t mask)
{ base->TCR3 &= ~I2S_TCR3_TCE_MASK; base->TCR3 |= I2S_TCR3_TCE(mask); }
eclipse-threadx/getting-started
C++
Other
310
/* Description: Enables a low level driver to set an upper limit on the size of a coalesced segment */
void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
/* Description: Enables a low level driver to set an upper limit on the size of a coalesced segment */ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
{ if (max_size < PAGE_CACHE_SIZE) { max_size = PAGE_CACHE_SIZE; printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_size); } q->limits.max_segment_size = max_size; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function takes a string and copies it, inserting a 'chr' before every 'chr' in it. */
gchar* ws_strdup_escape_char(const gchar *str, const gchar chr)
/* This function takes a string and copies it, inserting a 'chr' before every 'chr' in it. */ gchar* ws_strdup_escape_char(const gchar *str, const gchar chr)
{ const gchar *p; gchar *q, *new_str; if(!str) return NULL; p = str; q = new_str = (gchar *)g_malloc (strlen(str) * 2 + 1); while(*p != 0) { if(*p == chr) *q++ = chr; *q++ = *p++; } *q = '\0'; return new_str; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Show simplified fallback BSOD screen. Used if new BSOD happens before previous BSOD can be shown. */
static void fallback_bsod(const char *fmt, const char *file_name, int line_number, va_list args)
/* Show simplified fallback BSOD screen. Used if new BSOD happens before previous BSOD can be shown. */ static void fallback_bsod(const char *fmt, const char *file_name, int line_number, va_list args)
{ vsnprintf(fallback_bsod_text + consumed, std::size(fallback_bsod_text) - consumed, fmt, args); } render_text_align(Rect16(8, 10, 230, 290), string_view_utf8::MakeRAM((const uint8_t *)fallback_bsod_text), resource_font(IDR_FNT_SMALL), COLOR_NAVY, COLOR_WHITE, { 0, 0, 0, 0 }, { Align_t::LeftTop(), is_multiline::yes }); while (1) { wdt_iwdg_refresh(); } }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* STUSB1602 checks the Data Role SWAP status (bit3 0x18 */
Data_Role_Swap_TypeDef STUSB1602_Data_Role_Swap_Status_Get(uint8_t Addr)
/* STUSB1602 checks the Data Role SWAP status (bit3 0x18 */ Data_Role_Swap_TypeDef STUSB1602_Data_Role_Swap_Status_Get(uint8_t Addr)
{ STUSB1602_CC_CAPABILITY_CTRL_RegTypeDef reg; STUSB1602_ReadReg(&reg.d8, Addr, STUSB1602_CC_CAPABILITY_CTRL_REG, 1); return (Data_Role_Swap_TypeDef)(reg.b.DR_SWAP_EN); }
st-one/X-CUBE-USB-PD
C++
null
110
/* get a map of all nodes that are heartbeating in any regions */
void o2hb_fill_node_map(unsigned long *map, unsigned bytes)
/* get a map of all nodes that are heartbeating in any regions */ void o2hb_fill_node_map(unsigned long *map, unsigned bytes)
{ down_read(&o2hb_callback_sem); spin_lock(&o2hb_live_lock); o2hb_fill_node_map_from_callback(map, bytes); spin_unlock(&o2hb_live_lock); up_read(&o2hb_callback_sem); }
robutest/uclinux
C++
GPL-2.0
60
/* brief DMA instance 0, channel 12 IRQ handler. */
void EDMA_0_CH12_DriverIRQHandler(void)
/* brief DMA instance 0, channel 12 IRQ handler. */ void EDMA_0_CH12_DriverIRQHandler(void)
{ EDMA_DriverIRQHandler(0U, 12U); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* SYSCTRL HRPWM Bus&Function Clock Enable and Reset Release. */
void LL_SYSCTRL_HRPWM_ClkEnRstRelease(void)
/* SYSCTRL HRPWM Bus&Function Clock Enable and Reset Release. */ void LL_SYSCTRL_HRPWM_ClkEnRstRelease(void)
{ __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); __LL_SYSCTRL_HRPWMBusClk_En(SYSCTRL); __LL_SYSCTRL_HRPWMFunClk_En(SYSCTRL); __LL_SYSCTRL_HRPWMSoftRst_Release(SYSCTRL); __LL_SYSCTRL_Reg_Lock(SYSCTRL); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Before you start, select your target, on the right of the "Load" button */
int main(void)
/* Before you start, select your target, on the right of the "Load" button */ int main(void)
{ if (TM_I2C_IsDeviceConnected(I2C3, i)) { sprintf(buffer, "Device: %02X", i); TM_ILI9341_Puts(10, 10 + 12 * devices_found++, buffer, &TM_Font_7x10, 0x0000, 0x1234); } } while (1) { } }
MaJerle/stm32f429
C++
null
2,036
/* Displays a maximum of 20 char on the LCD. */
void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr)
/* Displays a maximum of 20 char on the LCD. */ void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr)
{ uint16_t refcolumn = LCD_PIXEL_WIDTH - 1; if(LCD_ID == LCD_HX8347D) { refcolumn = 0; while ((*ptr != 0) & ((LCD_PIXEL_WIDTH - (refcolumn & 0xFFFF)) >= LCD_Currentfonts->Width)) { LCD_DisplayChar(Line, refcolumn, *ptr); refcolumn += LCD_Currentfonts->Width; ptr++; } } else { while ((*ptr != 0) & (((refcolumn + 1) & 0xFFFF) >= LCD_Currentfonts->Width)) { LCD_DisplayChar(Line, refcolumn, *ptr); refcolumn -= LCD_Currentfonts->Width; ptr++; } } }
avem-labs/Avem
C++
MIT License
1,752
/* param base PXP peripheral base address. param config Pointer to the configuration. */
void PXP_SetPorterDuffConfig(PXP_Type *base, const pxp_porter_duff_config_t *config)
/* param base PXP peripheral base address. param config Pointer to the configuration. */ void PXP_SetPorterDuffConfig(PXP_Type *base, const pxp_porter_duff_config_t *config)
{ assert(NULL != config); union { pxp_porter_duff_config_t pdConfigStruct; uint32_t u32; } pdConfig; pdConfig.pdConfigStruct = *config; base->PORTER_DUFF_CTRL = pdConfig.u32; }
eclipse-threadx/getting-started
C++
Other
310
/* Set direction flag: Which packets do we accept on a forwarding single device? IN, OUT or both? */
static int sf_setdirection(pcap_t *p, pcap_direction_t d _U_)
/* Set direction flag: Which packets do we accept on a forwarding single device? IN, OUT or both? */ static int sf_setdirection(pcap_t *p, pcap_direction_t d _U_)
{ pcap_snprintf(p->errbuf, sizeof(p->errbuf), "Setting direction is not supported on savefiles"); return (-1); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function must be called with hardirqs disabled. It is normally invoked from the scheduling-clock interrupt. If rcu_pending returns false, there is no point in invoking rcu_check_callbacks(). */
void rcu_check_callbacks(int cpu, int user)
/* This function must be called with hardirqs disabled. It is normally invoked from the scheduling-clock interrupt. If rcu_pending returns false, there is no point in invoking rcu_check_callbacks(). */ void rcu_check_callbacks(int cpu, int user)
{ if (!rcu_pending(cpu)) return; if (user || (idle_cpu(cpu) && rcu_scheduler_active && !in_softirq() && hardirq_count() <= (1 << HARDIRQ_SHIFT))) { rcu_sched_qs(cpu); rcu_bh_qs(cpu); } else if (!in_softirq()) { rcu_bh_qs(cpu); } rcu_preempt_check_callbacks(cpu); raise_softirq(RCU_SOFTIRQ); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* WDT interrupt handler. This function is the WDT interrupt handler, it simple execute the callback function if there be one. */
void WDTIntHandler(void)
/* WDT interrupt handler. This function is the WDT interrupt handler, it simple execute the callback function if there be one. */ void WDTIntHandler(void)
{ if(g_pfnWDTHandlerCallbacks != 0) { g_pfnWDTHandlerCallbacks(0, 0, 0, 0); } else { while(1); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciAnd32(IN UINTN Address, IN UINT32 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciAnd32(IN UINTN Address, IN UINT32 AndData)
{ return PciWrite32 (Address, PciRead32 (Address) & AndData); }
tianocore/edk2
C++
Other
4,240
/* Calculate how many bits are the same between two IPv6 addresses. */
UINT8 Ip6CommonPrefixLen(IN EFI_IPv6_ADDRESS *AddressA, IN EFI_IPv6_ADDRESS *AddressB)
/* Calculate how many bits are the same between two IPv6 addresses. */ UINT8 Ip6CommonPrefixLen(IN EFI_IPv6_ADDRESS *AddressA, IN EFI_IPv6_ADDRESS *AddressB)
{ UINT8 Count; UINT8 Index; UINT8 ByteA; UINT8 ByteB; UINT8 NumBits; Count = 0; Index = 0; while (Index < 16) { ByteA = AddressA->Addr[Index]; ByteB = AddressB->Addr[Index]; if (ByteA == ByteB) { Count += 8; Index++; continue; } NumBits = 8; ByteA = (UINT8)(ByteA ^ ByteB); while (ByteA != 0) { NumBits--; ByteA = (UINT8)(ByteA >> 1); } return (UINT8)(Count + NumBits); } return Count; }
tianocore/edk2
C++
Other
4,240
/* Gets the number of bits transferred per frame. */
unsigned char SPIBitLengthGet(unsigned long ulBase)
/* Gets the number of bits transferred per frame. */ unsigned char SPIBitLengthGet(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE)||(ulBase == SPI3_BASE) ); return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_TX_BIT_LEN_M) >> SPI_CNTRL_TX_BIT_LEN_S); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* compute the CAS write latency according to DDR3 spec CWL = 5 if tCK >= 2.5ns 6 if 2.5ns > tCK >= 1.875ns 7 if 1.875ns > tCK >= 1.5ns 8 if 1.5ns > tCK >= 1.25ns */
static unsigned int compute_cas_write_latency(void)
/* compute the CAS write latency according to DDR3 spec CWL = 5 if tCK >= 2.5ns 6 if 2.5ns > tCK >= 1.875ns 7 if 1.875ns > tCK >= 1.5ns 8 if 1.5ns > tCK >= 1.25ns */ static unsigned int compute_cas_write_latency(void)
{ unsigned int cwl; const unsigned int mclk_ps = get_memory_clk_period_ps(); if (mclk_ps >= 2500) cwl = 5; else if (mclk_ps >= 1875) cwl = 6; else if (mclk_ps >= 1500) cwl = 7; else if (mclk_ps >= 1250) cwl = 8; else cwl = 8; return cwl; }
EmcraftSystems/u-boot
C++
Other
181
/* Enables or disables the TIMx peripheral Preload register on CCR5. */
void TIM_OC5PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
/* Enables or disables the TIMx peripheral Preload register on CCR5. */ void TIM_OC5PreloadConfig(TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
{ uint32_t tmpccmr3 = 0; assert_param(IS_TIM_LIST4_PERIPH(TIMx)); assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload)); tmpccmr3 = TIMx->CCMR3; tmpccmr3 &= (uint32_t)(~TIM_CCMR3_OC5PE); tmpccmr3 |= (uint32_t)(TIM_OCPreload); TIMx->CCMR3 = tmpccmr3; }
ajhc/demo-cortex-m3
C++
null
38
/* Internal Function. Allocate n pages from free page list at given address. */
UINTN InternalAllocAddress(IN OUT LIST_ENTRY *FreePageList, IN UINTN NumberOfPages, IN UINTN Address)
/* Internal Function. Allocate n pages from free page list at given address. */ UINTN InternalAllocAddress(IN OUT LIST_ENTRY *FreePageList, IN UINTN NumberOfPages, IN UINTN Address)
{ UINTN EndAddress; LIST_ENTRY *Node; FREE_PAGE_LIST *Pages; if ((Address & EFI_PAGE_MASK) != 0) { return ~Address; } EndAddress = Address + EFI_PAGES_TO_SIZE (NumberOfPages); for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) { Pages = BASE_CR (Node, FREE_PAGE_LIST, Link); if ((UINTN)Pages <= Address) { if ((UINTN)Pages + EFI_PAGES_TO_SIZE (Pages->NumberOfPages) < EndAddress) { break; } return InternalAllocPagesOnOneNode (Pages, NumberOfPages, EndAddress); } } return ~Address; }
tianocore/edk2
C++
Other
4,240
/* We change rt_genid and let gc do the cleanup */
static void rt_secret_rebuild(unsigned long __net)
/* We change rt_genid and let gc do the cleanup */ static void rt_secret_rebuild(unsigned long __net)
{ struct net *net = (struct net *)__net; rt_cache_invalidate(net); mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* mpt_clear_taskmgmt_in_progress_flag - clear flags associated with task management @ioc: Pointer to MPT_ADAPTER structure */
void mpt_clear_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc)
/* mpt_clear_taskmgmt_in_progress_flag - clear flags associated with task management @ioc: Pointer to MPT_ADAPTER structure */ void mpt_clear_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc)
{ unsigned long flags; spin_lock_irqsave(&ioc->taskmgmt_lock, flags); ioc->taskmgmt_in_progress = 0; ioc->taskmgmt_quiesce_io = 0; if (ioc->alt_ioc) { ioc->alt_ioc->taskmgmt_in_progress = 0; ioc->alt_ioc->taskmgmt_quiesce_io = 0; } spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Given a circuit type and ID for a packet, search for a matching circuit and, if found and it has a circuit dissector, call that dissector and return TRUE, otherwise return FALSE. */
gboolean try_circuit_dissector(circuit_type ctype, guint32 circuit_id, guint32 frame, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
/* Given a circuit type and ID for a packet, search for a matching circuit and, if found and it has a circuit dissector, call that dissector and return TRUE, otherwise return FALSE. */ gboolean try_circuit_dissector(circuit_type ctype, guint32 circuit_id, guint32 frame, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{ circuit_t *circuit; circuit = find_circuit(ctype, circuit_id, frame); if (circuit != NULL) { if (circuit->dissector_handle == NULL) return FALSE; call_dissector_with_data(circuit->dissector_handle, tvb, pinfo, tree, data); return TRUE; } return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Find child node with given basename. Needs to be called with node_lock held. */
static struct gcov_node* get_child_by_name(struct gcov_node *parent, const char *name)
/* Find child node with given basename. Needs to be called with node_lock held. */ static struct gcov_node* get_child_by_name(struct gcov_node *parent, const char *name)
{ struct gcov_node *node; list_for_each_entry(node, &parent->children, list) { if (strcmp(node->name, name) == 0) return node; } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Fast approximation to the trigonometric sine function for Q15 data. */
q15_t arm_sin_q15(q15_t x)
/* Fast approximation to the trigonometric sine function for Q15 data. */ q15_t arm_sin_q15(q15_t x)
{ q15_t sinVal; int32_t index; q15_t a, b; q15_t fract; if (x < 0) { x = (uint16_t)x + 0x8000; } index = (uint32_t)x >> FAST_MATH_Q15_SHIFT; fract = (x - (index << FAST_MATH_Q15_SHIFT)) << 9; a = sinTable_q15[index]; b = sinTable_q15[index+1]; sinVal = (q31_t) (0x8000 - fract) * a >> 16; sinVal = (q15_t) ((((q31_t) sinVal << 16) + ((q31_t) fract * b)) >> 16); return (sinVal << 1); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Note that this must be called very early to have any effect. */
int paravirt_disable_iospace(void)
/* Note that this must be called very early to have any effect. */ int paravirt_disable_iospace(void)
{ return request_resource(&ioport_resource, &reserve_ioports); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read SFH5712 device ID and revision numbers. This function reads the sensor hardware identification registers and returns these values in the specified data structure. */
static bool sfh5712_device_id(sensor_hal_t *hal, sensor_data_t *data)
/* Read SFH5712 device ID and revision numbers. This function reads the sensor hardware identification registers and returns these values in the specified data structure. */ static bool sfh5712_device_id(sensor_hal_t *hal, sensor_data_t *data)
{ uint32_t const part_id = sensor_bus_get(hal, SFH5712_PART_ID); data->device.id = (part_id & PART_ID_MASK) >> PART_ID_SHIFT; data->device.version = (part_id & PART_REV_MASK); return true; }
memfault/zero-to-main
C++
null
200
/* Returns 0 on success or -1 with the statistic lock released if the room in the socket buffer was not sufficient. */
int gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q)
/* Returns 0 on success or -1 with the statistic lock released if the room in the socket buffer was not sufficient. */ int gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q)
{ if (d->compat_tc_stats) { d->tc_stats.drops = q->drops; d->tc_stats.qlen = q->qlen; d->tc_stats.backlog = q->backlog; d->tc_stats.overlimits = q->overlimits; } if (d->tail) return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q)); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* param handle The ENET handler pointer.This is the same state pointer used in ENET_QOS_Init. param txFrame Input parameter, pointer to enet_qos_frame_info_t for saving read out frame information. param channel Read out frame from specified channel. */
void ENET_QOS_GetTxFrame(enet_qos_handle_t *handle, enet_qos_frame_info_t *txFrame, uint8_t channel)
/* param handle The ENET handler pointer.This is the same state pointer used in ENET_QOS_Init. param txFrame Input parameter, pointer to enet_qos_frame_info_t for saving read out frame information. param channel Read out frame from specified channel. */ void ENET_QOS_GetTxFrame(enet_qos_handle_t *handle, enet_qos_frame_info_t *txFrame, uint8_t channel)
{ assert(handle != NULL); assert(channel < handle->txQueueUse); enet_qos_tx_dirty_ring_t *txDirtyRing = (enet_qos_tx_dirty_ring_t *)&handle->txDirtyRing[channel]; enet_qos_frame_info_t *txDirty = &txDirtyRing->txDirtyBase[txDirtyRing->txConsumIdx]; (void)memcpy(txFrame, txDirty, sizeof(enet_qos_frame_info_t)); txDirtyRing->isFull = false; txDirtyRing->txConsumIdx = ENET_QOS_IncreaseIndex(txDirtyRing->txConsumIdx, txDirtyRing->txRingLen); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sysdig is a tool that captures and analyzes system state. This dissects pcap-ng Sysdig Event Blocks (0x00000204), which contains a system call entry or exit along with its associated parameters. To do: */
void proto_reg_handoff_sysdig_event(void)
/* Sysdig is a tool that captures and analyzes system state. This dissects pcap-ng Sysdig Event Blocks (0x00000204), which contains a system call entry or exit along with its associated parameters. To do: */ void proto_reg_handoff_sysdig_event(void)
{ dissector_handle_t sysdig_event_handle; sysdig_event_handle = create_dissector_handle(dissect_sysdig_event, proto_sysdig_event); dissector_add_uint("pcapng.block_type", BLOCK_TYPE_SYSDIG_EVENT, sysdig_event_handle); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* HPUX's utssys() call. It's a collection of miscellaneous functions, alas, so there's no nice way of splitting them up. */
static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
/* HPUX's utssys() call. It's a collection of miscellaneous functions, alas, so there's no nice way of splitting them up. */ static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
{ struct super_block *s; struct hpux_ustat tmp; struct kstatfs sbuf; int err = -EINVAL; s = user_get_super(dev); if (s == NULL) goto out; err = vfs_statfs(s->s_root, &sbuf); drop_super(s); if (err) goto out; memset(&tmp,0,sizeof(tmp)); tmp.f_tfree = (int32_t)sbuf.f_bfree; tmp.f_tinode = (u_int32_t)sbuf.f_ffree; tmp.f_blksize = (u_int32_t)sbuf.f_bsize; err = copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; out: return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* In general this syscall should not be blocked but we will work out all possible options. */
int gdcReqDmaTrans(int gd_chn, int *dmabuf)
/* In general this syscall should not be blocked but we will work out all possible options. */ int gdcReqDmaTrans(int gd_chn, int *dmabuf)
{ LOGF("ERROR: %d != %d\n", gd_chn, GDS->req_count); return -1; } if(GDS->status != CMD_STAT_STREAMING || GDS->requested < (uint32)dmabuf[1]) { LOGF("ERROR: status = %s, remain = %d, request = %d\n", stat_name[GDS->status + 1], GDS->requested, dmabuf[1]); return -1; } GDS->requested -= dmabuf[1]; pre_read_xfer_start(dmabuf[0], dmabuf[1]); return 0; }
DC-SWAT/DreamShell
C++
null
404
/* time stamp Update This function updates (adds/subtracts) with the value specified in the Timestamp High Update and Timestamp Low Update register. */
s32 synopGMAC_TS_timestamp_update(synopGMACdevice *gmacdev, u32 high_value, u32 low_value)
/* time stamp Update This function updates (adds/subtracts) with the value specified in the Timestamp High Update and Timestamp Low Update register. */ s32 synopGMAC_TS_timestamp_update(synopGMACdevice *gmacdev, u32 high_value, u32 low_value)
{ u32 loop_variable; synopGMACWriteReg(gmacdev->MacBase, GmacTSHighUpdate, high_value); synopGMACWriteReg(gmacdev->MacBase, GmacTSLowUpdate, low_value); for (loop_variable = 0; loop_variable < DEFAULT_LOOP_VARIABLE; loop_variable++) { if (!((synopGMACReadReg(gmacdev->MacBase, GmacTSControl)) & GmacTSUPDT)) { break; } plat_delay(DEFAULT_DELAY_VARIABLE); } if (loop_variable < DEFAULT_LOOP_VARIABLE) synopGMACSetBits(gmacdev->MacBase, GmacTSControl, GmacTSUPDT); else { TR("Error::: The TSADDREG bit is not getting cleared !!!!!!\n"); return -ESYNOPGMACPHYERR; } return -ESYNOPGMACNOERR; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Boot the file specified by the input file path info. */
BOOLEAN EFIAPI BootFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
/* Boot the file specified by the input file path info. */ BOOLEAN EFIAPI BootFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
{ EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; CHAR16 *FileName; Status = EFI_NOT_STARTED; FileName = NULL; FileName = ExtractFileNameFromDevicePath (FilePath); if (FileName != NULL) { Status = EfiBootManagerInitializeLoadOption ( &BootOption, 0, LoadOptionTypeBoot, LOAD_OPTION_ACTIVE, FileName, FilePath, NULL, 0 ); } if (!EFI_ERROR (Status)) { gST->ConOut->ClearScreen (gST->ConOut); BmmSetupResetReminder (); BmmSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption); BmmSetConsoleMode (TRUE); FreePool (FileName); EfiBootManagerFreeLoadOption (&BootOption); } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* If Sha1Context is NULL, then return FALSE. If NewSha1Context is NULL, then return FALSE. */
BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context)
/* If Sha1Context is NULL, then return FALSE. If NewSha1Context is NULL, then return FALSE. */ BOOLEAN EFIAPI Sha1Duplicate(IN CONST VOID *Sha1Context, OUT VOID *NewSha1Context)
{ if ((Sha1Context == NULL) || (NewSha1Context == NULL)) { return FALSE; } CopyMem (NewSha1Context, Sha1Context, sizeof (SHA_CTX)); return TRUE; }
tianocore/edk2
C++
Other
4,240
/* NOTE: this parser is an approximate form of the real command parser. Number of args have a limit of MAX_ARGS. If cmdline contains more, it will return with failure. */
static int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
/* NOTE: this parser is an approximate form of the real command parser. Number of args have a limit of MAX_ARGS. If cmdline contains more, it will return with failure. */ static int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
{ const char *p; int nb_args, ret; char buf[1024]; p = cmdline; nb_args = 0; for (;;) { while (qemu_isspace(*p)) { p++; } if (*p == '\0') { break; } if (nb_args >= MAX_ARGS) { goto fail; } ret = get_str(buf, sizeof(buf), &p); if (ret < 0) { goto fail; } args[nb_args] = g_strdup(buf); nb_args++; } *pnb_args = nb_args; return 0; fail: free_cmdline_args(args, nb_args); return -1; }
ve3wwg/teensy3_qemu
C
Other
15
/* If Sha384Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
/* If Sha384Context is NULL, then return FALSE. If HashValue is NULL, then return FALSE. */ BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
{ INT32 Ret; if ((Sha384Context == NULL) || (HashValue == NULL)) { return FALSE; } Ret = mbedtls_sha512_finish_ret (Sha384Context, HashValue); mbedtls_sha512_free (Sha384Context); if (Ret != 0) { return FALSE; } return TRUE; }
tianocore/edk2
C++
Other
4,240
/* Register a module that will have preferences. Specify the module under which to register it or NULL to register it at the top level, the name used for the module in the preferences file, the title used in the tab for it in a preferences dialog box, and a routine to call back when we apply the preferences. */
module_t* prefs_register_module(module_t *parent, const char *name, const char *title, const char *description, void(*apply_cb)(void), const gboolean use_gui)
/* Register a module that will have preferences. Specify the module under which to register it or NULL to register it at the top level, the name used for the module in the preferences file, the title used in the tab for it in a preferences dialog box, and a routine to call back when we apply the preferences. */ module_t* prefs_register_module(module_t *parent, const char *name, const char *title, const char *description, void(*apply_cb)(void), const gboolean use_gui)
{ return prefs_register_module_or_subtree(parent, name, title, description, FALSE, apply_cb, use_gui); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Finds an active region in the address range from start_pfn to last_pfn and returns its range in ei_startpfn and ei_endpfn for the e820 entry. */
int __init e820_find_active_region(const struct e820entry *ei, unsigned long start_pfn, unsigned long last_pfn, unsigned long *ei_startpfn, unsigned long *ei_endpfn)
/* Finds an active region in the address range from start_pfn to last_pfn and returns its range in ei_startpfn and ei_endpfn for the e820 entry. */ int __init e820_find_active_region(const struct e820entry *ei, unsigned long start_pfn, unsigned long last_pfn, unsigned long *ei_startpfn, unsigned long *ei_endpfn)
{ u64 align = PAGE_SIZE; *ei_startpfn = round_up(ei->addr, align) >> PAGE_SHIFT; *ei_endpfn = round_down(ei->addr + ei->size, align) >> PAGE_SHIFT; if (*ei_startpfn >= *ei_endpfn) return 0; if (ei->type != E820_RAM || *ei_endpfn <= start_pfn || *ei_startpfn >= last_pfn) return 0; if (*ei_startpfn < start_pfn) *ei_startpfn = start_pfn; if (*ei_endpfn > last_pfn) *ei_endpfn = last_pfn; return 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Callback function which provided by user to remove one node in NetDestroyLinkList process. */
EFI_STATUS EFIAPI Udp4DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
/* Callback function which provided by user to remove one node in NetDestroyLinkList process. */ EFI_STATUS EFIAPI Udp4DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
{ UDP4_INSTANCE_DATA *Instance; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; UINTN NumberOfChildren; EFI_HANDLE *ChildHandleBuffer; if ((Entry == NULL) || (Context == NULL)) { return EFI_INVALID_PARAMETER; } Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE); ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding; NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren; ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer; if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { return EFI_SUCCESS; } return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle); }
tianocore/edk2
C++
Other
4,240
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
/* SPI MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
{ if(hspi->Instance==SPI1) { __HAL_RCC_SPI1_CLK_DISABLE(); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Tpm measure and log data, and extend the measurement result into a specific PCR. */
EFI_STATUS EFIAPI TpmMeasureAndLogDataWithFlags(IN UINT32 PcrIndex, IN UINT32 EventType, IN VOID *EventLog, IN UINT32 LogLen, IN VOID *HashData, IN UINT64 HashDataLen, IN UINT64 Flags)
/* Tpm measure and log data, and extend the measurement result into a specific PCR. */ EFI_STATUS EFIAPI TpmMeasureAndLogDataWithFlags(IN UINT32 PcrIndex, IN UINT32 EventType, IN VOID *EventLog, IN UINT32 LogLen, IN VOID *HashData, IN UINT64 HashDataLen, IN UINT64 Flags)
{ EFI_STATUS Status; EDKII_TCG_PPI *TcgPpi; TCG_PCR_EVENT_HDR TcgEventHdr; Status = PeiServicesLocatePpi ( &gEdkiiTcgPpiGuid, 0, NULL, (VOID **)&TcgPpi ); if (EFI_ERROR (Status)) { return Status; } TcgEventHdr.PCRIndex = PcrIndex; TcgEventHdr.EventType = EventType; TcgEventHdr.EventSize = LogLen; Status = TcgPpi->HashLogExtendEvent ( TcgPpi, Flags, HashData, (UINTN)HashDataLen, &TcgEventHdr, EventLog ); return Status; }
tianocore/edk2
C++
Other
4,240
/* param base The I2C peripheral base address. param addressRegister The module supports multiple address registers. The parameter determines which one shall be changed. param address The slave address to be stored to the address register for matching. param addressDisable Disable matching of the specified address register. */
void I2C_SlaveSetAddress(I2C_Type *base, i2c_slave_address_register_t addressRegister, uint8_t address, bool addressDisable)
/* param base The I2C peripheral base address. param addressRegister The module supports multiple address registers. The parameter determines which one shall be changed. param address The slave address to be stored to the address register for matching. param addressDisable Disable matching of the specified address register. */ void I2C_SlaveSetAddress(I2C_Type *base, i2c_slave_address_register_t addressRegister, uint8_t address, bool addressDisable)
{ base->SLVADR[addressRegister] = I2C_SLVADR_SLVADR(address) | I2C_SLVADR_SADISABLE(addressDisable); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return an indication of whether or not we are at the last directory in the file. */
int TIFFLastDirectory(TIFF *tif)
/* Return an indication of whether or not we are at the last directory in the file. */ int TIFFLastDirectory(TIFF *tif)
{ return (tif->tif_nextdiroff == 0); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */
void gpio_unregister_callback(uint8_t gpio_pin, enum gpio_callback callback_type)
/* Unregisters a callback. Unregisters a callback function which is implemented by the user. */ void gpio_unregister_callback(uint8_t gpio_pin, enum gpio_callback callback_type)
{ Assert(callback_func); Assert(gpio_pin < 48); uint8_t gpio_port = 0; if (gpio_pin < 16) { gpio_port = 0; } else if (gpio_pin < 32) { gpio_port = 1; } else { gpio_port = 2; } _gpio_instances[gpio_port].callback[gpio_pin % 16] = NULL; _gpio_instances[gpio_port].callback_reg_mask &= ~(1 << (gpio_pin % 16)); }
memfault/zero-to-main
C++
null
200
/* Install interrupt handler, enable irq on card. If irq is -1, choose next free irq, else irq is given explicitly. */
int act2000_isa_config_irq(act2000_card *card, short irq)
/* Install interrupt handler, enable irq on card. If irq is -1, choose next free irq, else irq is given explicitly. */ int act2000_isa_config_irq(act2000_card *card, short irq)
{ int old_irq; if (card->flags & ACT2000_FLAGS_IVALID) { free_irq(card->irq, card); } card->flags &= ~ACT2000_FLAGS_IVALID; outb(ISA_COR_IRQOFF, ISA_PORT_COR); if (!irq) return 0; old_irq = card->irq; card->irq = irq; if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { card->irq = old_irq; card->flags |= ACT2000_FLAGS_IVALID; printk(KERN_WARNING "act2000: Could not request irq %d\n",irq); return -EBUSY; } else { act2000_isa_select_irq(card); outb(0, ISA_PORT_SIS); outb(0, ISA_PORT_SOS); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Gets the states of the CTS modem status signals. */
unsigned long UARTModemStatusGet(unsigned long ulBase)
/* Gets the states of the CTS modem status signals. */ unsigned long UARTModemStatusGet(unsigned long ulBase)
{ xASSERT((ulBase == UART0_BASE) ||(ulBase == UART1_BASE) ); return(xHWREG(ulBase + UART_MSR) & (UART_MSR_CTS_ST)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* De-initializes the FMC SDRAM Banks registers to their default reset values. */
void FMC_SDRAMDeInit(uint32_t FMC_Bank)
/* De-initializes the FMC SDRAM Banks registers to their default reset values. */ void FMC_SDRAMDeInit(uint32_t FMC_Bank)
{ assert_param(IS_FMC_SDRAM_BANK(FMC_Bank)); FMC_Bank5_6->SDCR[FMC_Bank] = 0x000002D0; FMC_Bank5_6->SDTR[FMC_Bank] = 0x0FFFFFFF; FMC_Bank5_6->SDCMR = 0x00000000; FMC_Bank5_6->SDRTR = 0x00000000; FMC_Bank5_6->SDSR = 0x00000000; }
MaJerle/stm32f429
C++
null
2,036
/* Return the scb back to the free list of scbs. The caller must 'flush' the SCB before calling us. E.g., performing pci_unamp and/or pci_sync etc. NOTE NOTE: Make sure the scb is not on any list before calling this routine. */
static void megaraid_dealloc_scb(adapter_t *adapter, scb_t *scb)
/* Return the scb back to the free list of scbs. The caller must 'flush' the SCB before calling us. E.g., performing pci_unamp and/or pci_sync etc. NOTE NOTE: Make sure the scb is not on any list before calling this routine. */ static void megaraid_dealloc_scb(adapter_t *adapter, scb_t *scb)
{ unsigned long flags; scb->state = SCB_FREE; scb->scp = NULL; spin_lock_irqsave(SCSI_FREE_LIST_LOCK(adapter), flags); list_add(&scb->list, &adapter->kscb_pool); spin_unlock_irqrestore(SCSI_FREE_LIST_LOCK(adapter), flags); return; }
robutest/uclinux
C++
GPL-2.0
60
/* param handle FlexCAN handle pointer. param mbIdx The FlexCAN FD Message Buffer index. return the index of mailbox 's timestamp stored in the handle. */
uint32_t FLEXCAN_GetTimeStamp(flexcan_handle_t *handle, uint8_t mbIdx)
/* param handle FlexCAN handle pointer. param mbIdx The FlexCAN FD Message Buffer index. return the index of mailbox 's timestamp stored in the handle. */ uint32_t FLEXCAN_GetTimeStamp(flexcan_handle_t *handle, uint8_t mbIdx)
{ assert(NULL != handle); return (uint32_t)(handle->timestamp[mbIdx]); }
eclipse-threadx/getting-started
C++
Other
310
/* BACnet Application PDUs chapter 21 BACnetRecipient::= CHOICE { device BACnetObjectIdentifier address BACnetAddress } */
static guint fRecipient(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
/* BACnet Application PDUs chapter 21 BACnetRecipient::= CHOICE { device BACnetObjectIdentifier address BACnetAddress } */ static guint fRecipient(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
{ guint8 tag_no, tag_info; guint32 lvt; fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt); if (tag_no < 2) { if (tag_no == 0) { offset = fObjectIdentifier(tvb, pinfo, tree, offset); } else { offset += fTagHeaderTree(tvb, pinfo, tree, offset, &tag_no, &tag_info, &lvt); offset = fAddress(tvb, pinfo, tree, offset); offset += fTagHeaderTree(tvb, pinfo, tree, offset, &tag_no, &tag_info, &lvt); } } return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get the size of the uncompressed buffer by parsing EncodeData header. */
UINT64 GetDecodedSizeOfBuf(UINT8 *EncodedData)
/* Get the size of the uncompressed buffer by parsing EncodeData header. */ UINT64 GetDecodedSizeOfBuf(UINT8 *EncodedData)
{ UINT64 DecodedSize; INTN Index; DecodedSize = 0; for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--) { DecodedSize = LShiftU64 (DecodedSize, 8) + EncodedData[Index]; } return DecodedSize; }
tianocore/edk2
C++
Other
4,240
/* This function will set a configuration for an usb device. */
rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
/* This function will set a configuration for an usb device. */ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
{ uconfig_t cfg; LOG_D("rt_usbd_set_config"); RT_ASSERT(device != RT_NULL); RT_ASSERT(value <= device->dev_desc.bNumConfigurations); cfg = rt_usbd_find_config(device, value); device->curr_cfg = cfg; dcd_set_config(device->dcd, value); return RT_TRUE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM7) { __HAL_RCC_TIM7_CLK_DISABLE(); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice */
double fabs(double x)
/* Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice */ double fabs(double x)
{ u_int32_t high; GET_HIGH_WORD(high,x); SET_HIGH_WORD(x,high&0x7fffffff); return x; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* relay_destroy_buf - destroy an rchan_buf struct and associated buffer @buf: the buffer struct */
static void relay_destroy_buf(struct rchan_buf *buf)
/* relay_destroy_buf - destroy an rchan_buf struct and associated buffer @buf: the buffer struct */ static void relay_destroy_buf(struct rchan_buf *buf)
{ struct rchan *chan = buf->chan; unsigned int i; if (likely(buf->start)) { vunmap(buf->start); for (i = 0; i < buf->page_count; i++) __free_page(buf->page_array[i]); relay_free_page_array(buf->page_array); } chan->buf[buf->cpu] = NULL; kfree(buf->padding); kfree(buf); kref_put(&chan->kref, relay_destroy_channel); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Wait for the given number of milliseconds (using the dwTimeStamp generated by the SAM microcontrollers' system tick). */
static void mdelay(uint32_t ul_dly_ticks)
/* Wait for the given number of milliseconds (using the dwTimeStamp generated by the SAM microcontrollers' system tick). */ static void mdelay(uint32_t ul_dly_ticks)
{ uint32_t ul_cur_ticks; ul_cur_ticks = ul_ms_ticks; while ((ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks); }
remotemcu/remcu-chip-sdks
C++
null
436
/* tipc_send_buf2port - send message buffer to port identity */
int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, struct sk_buff *buf, unsigned int dsz)
/* tipc_send_buf2port - send message buffer to port identity */ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, struct sk_buff *buf, unsigned int dsz)
{ struct tipc_portid orig; orig.ref = ref; orig.node = tipc_own_addr; return tipc_forward_buf2port(ref, dest, buf, dsz, &orig, TIPC_PORT_IMPORTANCE); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* We could do with some locking to stop Arthur being removed while processes are using it. */
static int __init arthur_init(void)
/* We could do with some locking to stop Arthur being removed while processes are using it. */ static int __init arthur_init(void)
{ return register_exec_domain(&arthur_exec_domain); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Get the implementation dependent name of a controller */
const char* SDL_GameControllerNameForIndex(int device_index)
/* Get the implementation dependent name of a controller */ const char* SDL_GameControllerNameForIndex(int device_index)
{ ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); if (pSupportedController) { if (SDL_strcmp(pSupportedController->name, "*") == 0) { return SDL_JoystickNameForIndex(device_index); } else { return pSupportedController->name; } } return NULL; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Deinitializes the SPIx peripheral registers to their default reset values . */
void SPI_DeInit(SPI_TypeDef *SPIx)
/* Deinitializes the SPIx peripheral registers to their default reset values . */ void SPI_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; default: break; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The 8-tuple has the same format as CPython's datetime object: */
STATIC mp_obj_t pyb_rtc_datetime(mp_obj_t self, const mp_obj_t datetime)
/* The 8-tuple has the same format as CPython's datetime object: */ STATIC mp_obj_t pyb_rtc_datetime(mp_obj_t self, const mp_obj_t datetime)
{ useconds = pyb_rtc_datetime_s_us(datetime, &seconds); pyb_rtc_set_time (seconds, useconds / 1000); } else { seconds = pyb_rtc_reset(); } wlan_set_current_time(seconds); return mp_const_none; }
micropython/micropython
C++
Other
18,334
/* sr_ref_mutex must be held entering this routine. Because it is called on last put, you should always use the scsi_cd_get() scsi_cd_put() helpers which manipulate the semaphore directly and never do a direct kref_put(). */
static void sr_kref_release(struct kref *kref)
/* sr_ref_mutex must be held entering this routine. Because it is called on last put, you should always use the scsi_cd_get() scsi_cd_put() helpers which manipulate the semaphore directly and never do a direct kref_put(). */ static void sr_kref_release(struct kref *kref)
{ struct scsi_cd *cd = container_of(kref, struct scsi_cd, kref); struct gendisk *disk = cd->disk; spin_lock(&sr_index_lock); clear_bit(MINOR(disk_devt(disk)), sr_index_bits); spin_unlock(&sr_index_lock); unregister_cdrom(&cd->cdi); disk->private_data = NULL; put_disk(disk); kfree(cd); }
robutest/uclinux
C++
GPL-2.0
60
/* If Guid is NULL, ASSERT(). If TheHandle is NULL, ASSERT(). */
CHAR16* EFIAPI GetProtocolInformationDump(IN CONST EFI_HANDLE TheHandle, IN CONST EFI_GUID *Guid, IN CONST BOOLEAN Verbose)
/* If Guid is NULL, ASSERT(). If TheHandle is NULL, ASSERT(). */ CHAR16* EFIAPI GetProtocolInformationDump(IN CONST EFI_HANDLE TheHandle, IN CONST EFI_GUID *Guid, IN CONST BOOLEAN Verbose)
{ CONST GUID_INFO_BLOCK *Id; ASSERT (TheHandle != NULL); ASSERT (Guid != NULL); if ((TheHandle == NULL) || (Guid == NULL)) { return (NULL); } Id = InternalShellGetNodeFromGuid (Guid); if ((Id != NULL) && (Id->DumpInfo != NULL)) { return (Id->DumpInfo (TheHandle, Verbose)); } return (NULL); }
tianocore/edk2
C++
Other
4,240
/* Add some additional seeding to the random32() pool. */
void srandom32(u32 entropy)
/* Add some additional seeding to the random32() pool. */ void srandom32(u32 entropy)
{ int i; for_each_possible_cpu (i) { struct rnd_state *state = &per_cpu(net_rand_state, i); state->s1 = __seed(state->s1 ^ entropy, 1); } }
robutest/uclinux
C++
GPL-2.0
60
/* Try to release metadata pages (indirect blocks, directories) which are mapped via the block device. Since these pages could have journal heads which would prevent try_to_free_buffers() from freeing them, we must use jbd layer's try_to_free_buffers() function to release them. */
static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait)
/* Try to release metadata pages (indirect blocks, directories) which are mapped via the block device. Since these pages could have journal heads which would prevent try_to_free_buffers() from freeing them, we must use jbd layer's try_to_free_buffers() function to release them. */ static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait)
{ journal_t *journal = EXT3_SB(sb)->s_journal; WARN_ON(PageChecked(page)); if (!page_has_buffers(page)) return 0; if (journal) return journal_try_to_free_buffers(journal, page, wait & ~__GFP_WAIT); return try_to_free_buffers(page); }
robutest/uclinux
C++
GPL-2.0
60
/* This API used to get the Operational Mode from the sensor in the register 0xF4 bit 0 and 1. */
BMP280_RETURN_FUNCTION_TYPE bmp280_get_power_mode(u8 *v_power_mode_u8)
/* This API used to get the Operational Mode from the sensor in the register 0xF4 bit 0 and 1. */ BMP280_RETURN_FUNCTION_TYPE bmp280_get_power_mode(u8 *v_power_mode_u8)
{ BMP280_RETURN_FUNCTION_TYPE com_rslt = ERROR; u8 v_mode_u8 = BMP280_INIT_VALUE; if (p_bmp280 == BMP280_NULL) { com_rslt = E_BMP280_NULL_PTR; } else { com_rslt = p_bmp280->BMP280_BUS_READ_FUNC(p_bmp280->dev_addr, BMP280_CTRL_MEAS_REG_POWER_MODE__REG, &v_mode_u8, BMP280_GEN_READ_WRITE_DATA_LENGTH); *v_power_mode_u8 = BMP280_GET_BITSLICE(v_mode_u8, BMP280_CTRL_MEAS_REG_POWER_MODE); } return com_rslt; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Create an MPI from embedded constants (assumes len is an exact multiple of sizeof mbedtls_mpi_uint) Allocate a new memory as well so that it can be freed. */
static void ecp_mpi_load(mbedtls_mpi *X, const mbedtls_mpi_uint *p, size_t len)
/* Create an MPI from embedded constants (assumes len is an exact multiple of sizeof mbedtls_mpi_uint) Allocate a new memory as well so that it can be freed. */ static void ecp_mpi_load(mbedtls_mpi *X, const mbedtls_mpi_uint *p, size_t len)
{ X->s = 1; X->n = len / sizeof( mbedtls_mpi_uint ); X->p = os_zalloc(len); memcpy(X->p, (void *)p, len); }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Init interrupts callback for the specified SPI Port. */
void xSPIIntCallbackInit(unsigned long ulBase, xtEventCallback xtSPICallback)
/* Init interrupts callback for the specified SPI Port. */ void xSPIIntCallbackInit(unsigned long ulBase, xtEventCallback xtSPICallback)
{ SPIIntCallbackInit(ulBase, xtSPICallback); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns: a newly-allocated string containing all the string arguments */
gchar* g_strconcat(const gchar *string1,...)
/* Returns: a newly-allocated string containing all the string arguments */ gchar* g_strconcat(const gchar *string1,...)
{ gsize l; va_list args; gchar *s; gchar *concat; gchar *ptr; if (!string1) return NULL; l = 1 + strlen (string1); va_start (args, string1); s = va_arg (args, gchar*); while (s) { l += strlen (s); s = va_arg (args, gchar*); } va_end (args); concat = g_new (gchar, l); ptr = concat; ptr = g_stpcpy (ptr, string1); va_start (args, string1); s = va_arg (args, gchar*); while (s) { ptr = g_stpcpy (ptr, s); s = va_arg (args, gchar*); } va_end (args); return concat; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* User prompt routine. This routine prompts the user to press the button and then waits for him to do so. */
static void prompt_user(char *prompt_string)
/* User prompt routine. This routine prompts the user to press the button and then waits for him to do so. */ static void prompt_user(char *prompt_string)
{ printf("%s\r\n", prompt_string); LED_Off(ALL_LEDS); while (!SWITCH_PRESSED) { LED_Toggle(PROMPT_LED); delay_ms(100); } LED_Off(PROMPT_LED); while (SWITCH_PRESSED) { } }
memfault/zero-to-main
C++
null
200
/* Called by the tty driver when the tty line is hung up. Wait for I/O to driver to complete and unregister ISDN device. This is already done by the close routine, so just call that. Called from process context. */
static int gigaset_tty_hangup(struct tty_struct *tty)
/* Called by the tty driver when the tty line is hung up. Wait for I/O to driver to complete and unregister ISDN device. This is already done by the close routine, so just call that. Called from process context. */ static int gigaset_tty_hangup(struct tty_struct *tty)
{ gigaset_tty_close(tty); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Registers pRxCb callback. Callback will be invoked after the next received frame. When EMAC_Poll() returns EMAC_RX_NO_DATA the application task call EMAC_Set_RxCb() to register pRxCb() callback and enters suspend state. The callback is in charge to resume the task once a new frame has been received. The next time EMAC_Poll() is called, it will be successfull. */
void EMAC_Set_RxCb(EMAC_RxCallback pRxCb)
/* Registers pRxCb callback. Callback will be invoked after the next received frame. When EMAC_Poll() returns EMAC_RX_NO_DATA the application task call EMAC_Set_RxCb() to register pRxCb() callback and enters suspend state. The callback is in charge to resume the task once a new frame has been received. The next time EMAC_Poll() is called, it will be successfull. */ void EMAC_Set_RxCb(EMAC_RxCallback pRxCb)
{ rxTd.rxCb = pRxCb; AT91C_BASE_EMAC->EMAC_IER = AT91C_EMAC_RCOMP; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Unregisters Block OSM from I2O core, unregisters i2o_block block device and frees the mempool and slab. */
static void __exit i2o_block_exit(void)
/* Unregisters Block OSM from I2O core, unregisters i2o_block block device and frees the mempool and slab. */ static void __exit i2o_block_exit(void)
{ i2o_driver_unregister(&i2o_block_driver); unregister_blkdev(I2O_MAJOR, "i2o_block"); mempool_destroy(i2o_blk_req_pool.pool); kmem_cache_destroy(i2o_blk_req_pool.slab); }
robutest/uclinux
C++
GPL-2.0
60
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */
void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
/* Adjusts the Internal High Speed oscillator (HSI) calibration value. */ void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
{ uint32_t tmpreg = 0; assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue)); tmpreg = RCC->CR; tmpreg &= ~RCC_CR_HSITRIM; tmpreg |= (uint32_t)HSICalibrationValue << 3; RCC->CR = tmpreg; }
MaJerle/stm32f429
C++
null
2,036
/* Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). */
BOOLEAN EFIAPI HkdfSha256Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
/* Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF). */ BOOLEAN EFIAPI HkdfSha256Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
{ return HkdfMdExpand (MBEDTLS_MD_SHA256, Prk, PrkSize, Info, InfoSize, Out, OutSize); }
tianocore/edk2
C++
Other
4,240
/* The ACPI spec is not quite clear when the drive identify buffer should be obtained. Calling IDENTIFY DEVICE during shutdown is not the best of ideas as the drive might already being put to sleep. And obviously we can't call it during resume. So we get the information during startup; but this means that any changes during run-time will be lost after resume. */
void ide_acpi_init_port(ide_hwif_t *hwif)
/* The ACPI spec is not quite clear when the drive identify buffer should be obtained. Calling IDENTIFY DEVICE during shutdown is not the best of ideas as the drive might already being put to sleep. And obviously we can't call it during resume. So we get the information during startup; but this means that any changes during run-time will be lost after resume. */ void ide_acpi_init_port(ide_hwif_t *hwif)
{ hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL); if (!hwif->acpidata) return; hwif->acpidata->obj_handle = ide_acpi_hwif_get_handle(hwif); if (!hwif->acpidata->obj_handle) { DEBPRINT("no ACPI object for %s found\n", hwif->name); kfree(hwif->acpidata); hwif->acpidata = NULL; } }
robutest/uclinux
C++
GPL-2.0
60
/* Try to do the real allocation with a given size */
static void * ent_alloc(lv_mem_ent_t *e, uint32_t size)
/* Try to do the real allocation with a given size */ static void * ent_alloc(lv_mem_ent_t *e, uint32_t size)
{ void * alloc = NULL; if(e->header.s.used == 0 && e->header.s.d_size >= size) { ent_trunc(e, size), e->header.s.used = 1; alloc = &e->first_data; } return alloc; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Clears or safeguards the OCREF2 signal on an external event. */
void TIM_ClearOC2Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
/* Clears or safeguards the OCREF2 signal on an external event. */ void TIM_ClearOC2Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
{ uint32_t tmpccmr1 = 0; assert_param(IS_TIM_LIST2_PERIPH(TIMx)); assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); tmpccmr1 = TIMx->CCMR1; tmpccmr1 &= (uint32_t)~TIM_CCMR1_OC2CE; tmpccmr1 |= ((uint32_t)TIM_OCClear << 8); TIMx->CCMR1 = tmpccmr1; }
avem-labs/Avem
C++
MIT License
1,752
/* Search for either hba phys or expander device based on handle, then returns the sas_node object. */
static struct _sas_node* _transport_sas_node_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, u64 sas_address)
/* Search for either hba phys or expander device based on handle, then returns the sas_node object. */ static struct _sas_node* _transport_sas_node_find_by_sas_address(struct MPT2SAS_ADAPTER *ioc, u64 sas_address)
{ if (ioc->sas_hba.sas_address == sas_address) return &ioc->sas_hba; else return mpt2sas_scsih_expander_find_by_sas_address(ioc, sas_address); }
robutest/uclinux
C++
GPL-2.0
60
/* So this function tries to do the above. Returns %-EAGAIN if some free space was presumably made and the caller has to re-try budgeting the operation. Returns %-ENOSPC if it couldn't do more free space, and other negative error codes on failures. */
static int make_free_space(struct ubifs_info *c)
/* So this function tries to do the above. Returns %-EAGAIN if some free space was presumably made and the caller has to re-try budgeting the operation. Returns %-ENOSPC if it couldn't do more free space, and other negative error codes on failures. */ static int make_free_space(struct ubifs_info *c)
{ int err, retries = 0; long long liab1, liab2; do { liab1 = get_liability(c); dbg_budg("liability %lld, run write-back", liab1); shrink_liability(c, NR_TO_WRITE); liab2 = get_liability(c); if (liab2 < liab1) return -EAGAIN; dbg_budg("new liability %lld (not shrinked)", liab2); dbg_budg("Run GC"); err = run_gc(c); if (!err) return -EAGAIN; if (err != -EAGAIN && err != -ENOSPC) return err; dbg_budg("Run commit (retries %d)", retries); err = ubifs_run_commit(c); if (err) return err; } while (retries++ < MAX_MKSPC_RETRIES); return -ENOSPC; }
robutest/uclinux
C++
GPL-2.0
60
/* HASH Get Hash Result. Makes a copy of the resulting hash. */
void hash_get_result(uint32_t *data)
/* HASH Get Hash Result. Makes a copy of the resulting hash. */ void hash_get_result(uint32_t *data)
{ data[0] = HASH_HR[0]; data[1] = HASH_HR[1]; data[2] = HASH_HR[2]; data[3] = HASH_HR[3]; if ((HASH_CR & HASH_CR_ALGO) == HASH_ALGO_SHA1) { data[4] = HASH_HR[4]; } } /**@}
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* ext4_ext_calc_credits_for_single_extent: This routine returns max. credits that needed to insert an extent to the extent tree. When pass the actual path, the caller should calculate credits under i_data_sem. */
int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks, struct ext4_ext_path *path)
/* ext4_ext_calc_credits_for_single_extent: This routine returns max. credits that needed to insert an extent to the extent tree. When pass the actual path, the caller should calculate credits under i_data_sem. */ int ext4_ext_calc_credits_for_single_extent(struct inode *inode, int nrblocks, struct ext4_ext_path *path)
{ if (path) { int depth = ext_depth(inode); int ret = 0; if (le16_to_cpu(path[depth].p_hdr->eh_entries) < le16_to_cpu(path[depth].p_hdr->eh_max)) { ret = 2 + EXT4_META_TRANS_BLOCKS(inode->i_sb); return ret; } } return ext4_chunk_trans_blocks(inode, nrblocks); }
robutest/uclinux
C++
GPL-2.0
60
/* Read BMA250 acceleration data. Along with the actual sensor data, the LSB byte contains a "new" flag indicating if the data for this axis has been updated since the last time the axis data was read. Reading either LSB or MSB data will clear this flag. */
static bool bma250_get_accel(sensor_hal_t *hal, sensor_data_t *data)
/* Read BMA250 acceleration data. Along with the actual sensor data, the LSB byte contains a "new" flag indicating if the data for this axis has been updated since the last time the axis data was read. Reading either LSB or MSB data will clear this flag. */ static bool bma250_get_accel(sensor_hal_t *hal, sensor_data_t *data)
{ size_t const count = sensor_bus_read(hal, hal->burst_addr, event_regs.acc, sizeof(event_regs.acc)); format_axis_data(hal, event_regs.acc, data); return (count == sizeof(event_regs.acc)); }
memfault/zero-to-main
C++
null
200
/* mmap()d file has taken write protection fault and is being made writable. We can set the page state up correctly for a writable page, which means we can do correct delalloc accounting (ENOSPC checking!) and unwritten extent mapping. */
STATIC int xfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
/* mmap()d file has taken write protection fault and is being made writable. We can set the page state up correctly for a writable page, which means we can do correct delalloc accounting (ENOSPC checking!) and unwritten extent mapping. */ STATIC int xfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
{ return block_page_mkwrite(vma, vmf, xfs_get_blocks); }
robutest/uclinux
C++
GPL-2.0
60
/* param base MCAN peripheral base address. param config The receive fifo 1 configuration structure. */
void MCAN_SetRxFifo1Config(CAN_Type *base, const mcan_rx_fifo_config_t *config)
/* param base MCAN peripheral base address. param config The receive fifo 1 configuration structure. */ void MCAN_SetRxFifo1Config(CAN_Type *base, const mcan_rx_fifo_config_t *config)
{ base->RXF1C |= CAN_RXF1C_F1SA(config->address >> CAN_RXF1C_F1SA_SHIFT) | CAN_RXF1C_F1S(config->elementSize) | CAN_RXF1C_F1WM(config->watermark) | CAN_RXF1C_F1OM(config->opmode); base->RXESC |= CAN_RXESC_F1DS(config->datafieldSize); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Start WiFi in the netif thread context and wait for function return. */
void os_hook_send_start(wifi_task_cb handler, struct params_dispatch *p, void *pv)
/* Start WiFi in the netif thread context and wait for function return. */ void os_hook_send_start(wifi_task_cb handler, struct params_dispatch *p, void *pv)
{ hif_msg_t msg; p->signal_semaphore = 1; msg.id = MSG_START; msg.handler = handler; msg.priv = pv; xQueueSend(hif_queue, (void *)&msg, portMAX_DELAY); xSemaphoreTake(hif_notify_sem, portMAX_DELAY); }
remotemcu/remcu-chip-sdks
C++
null
436
/* leave DFU mode and reset device to jump to user loaded code */
static void dfu_mode_leave(usb_dev *udev)
/* leave DFU mode and reset device to jump to user loaded code */ static void dfu_mode_leave(usb_dev *udev)
{ usbd_dfu_handler *dfu = (usbd_dfu_handler *)udev->dev.class_data[USBD_DFU_INTERFACE]; dfu->manifest_state = MANIFEST_COMPLETE; if (dfu_config_desc.dfu_func.bmAttributes & 0x04U) { dfu->bState = STATE_DFU_MANIFEST_SYNC; } else { dfu->bState = STATE_DFU_MANIFEST_WAIT_RESET; dfu_mem_deinit(); NVIC_SystemReset(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Waits until a new conversion result is available. */
int32_t AD717X_WaitForReady(ad717x_dev *device, uint32_t timeout)
/* Waits until a new conversion result is available. */ int32_t AD717X_WaitForReady(ad717x_dev *device, uint32_t timeout)
{ ad717x_st_reg *statusReg; int32_t ret; int8_t ready = 0; if(!device || !device->regs) return INVALID_VAL; statusReg = AD717X_GetReg(device, AD717X_STATUS_REG); if (!statusReg) return INVALID_VAL; while(!ready && --timeout) { ret = AD717X_ReadRegister(device, AD717X_STATUS_REG); if(ret < 0) return ret; ready = (statusReg->value & AD717X_STATUS_REG_RDY) == 0; } return timeout ? 0 : TIMEOUT; }
analogdevicesinc/EVAL-ADICUP3029
C++
Other
36
/* Draws a string using the supplied anti-aliased font, centering it on the specified X/Y co-ordinate. */
void aafontsCenterString(uint16_t x, uint16_t y, const uint16_t *colorTable, const aafontsFont_t *font, char *str)
/* Draws a string using the supplied anti-aliased font, centering it on the specified X/Y co-ordinate. */ void aafontsCenterString(uint16_t x, uint16_t y, const uint16_t *colorTable, const aafontsFont_t *font, char *str)
{ uint32_t stringWidth; stringWidth = aafontsGetStringWidth(font, str); aafontsDrawString(x - stringWidth/2, y, colorTable, font, str); }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Outputs an error message, via the #GScanner message handler. */
void g_scanner_error(GScanner *scanner, const gchar *format,...)
/* Outputs an error message, via the #GScanner message handler. */ void g_scanner_error(GScanner *scanner, const gchar *format,...)
{ g_return_if_fail (scanner != NULL); g_return_if_fail (format != NULL); scanner->parse_errors++; if (scanner->msg_handler) { va_list args; gchar *string; va_start (args, format); string = g_strdup_vprintf (format, args); va_end (args); scanner->msg_handler (scanner, string, TRUE); g_free (string); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configures the LCD GLASS relative GPIO port IOs and LCD peripheral. */
void LCD_GLASS_Init(void)
/* Configures the LCD GLASS relative GPIO port IOs and LCD peripheral. */ void LCD_GLASS_Init(void)
{ LCD_InitTypeDef LCD_InitStructure; LCD_GPIOConfig(); RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD, ENABLE); LCD_InitStructure.LCD_Prescaler = LCD_Prescaler_8; LCD_InitStructure.LCD_Divider = LCD_Divider_16; LCD_InitStructure.LCD_Duty = LCD_Duty_1_4; LCD_InitStructure.LCD_Bias = LCD_Bias_1_3; LCD_InitStructure.LCD_VoltageSource = LCD_VoltageSource_Internal; LCD_Init(&LCD_InitStructure); LCD_PulseOnDurationConfig(LCD_PulseOnDuration_2); LCD_ContrastConfig(LCD_Contrast_Level_7); LCD_WaitForSynchro(); LCD_Cmd(ENABLE); while(LCD_GetFlagStatus(LCD_FLAG_ENS) == RESET) { } while(LCD_GetFlagStatus(LCD_FLAG_RDY) == RESET) { } }
avem-labs/Avem
C++
MIT License
1,752