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
/* This routine should set everything up anew at each open, even registers that "should" only need to be set once at boot, so that there is non-reboot way to recover if something goes wrong. */
static int etherh_open(struct net_device *dev)
/* This routine should set everything up anew at each open, even registers that "should" only need to be set once at boot, so that there is non-reboot way to recover if something goes wrong. */ static int etherh_open(struct net_device *dev)
{ struct ei_device *ei_local = netdev_priv(dev); if (!is_valid_ether_addr(dev->dev_addr)) { printk(KERN_WARNING "%s: invalid ethernet MAC address\n", dev->name); return -EINVAL; } if (request_irq(dev->irq, __ei_interrupt, 0, dev->name, dev)) return -EAGAIN; ei_local->interface_num = 0; if (dev->flags & I...
robutest/uclinux
C++
GPL-2.0
60
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT8 EFIAPI PciSegmentBitFieldAnd8(IN UINT64 Address, IN UINTN StartBit, IN UINTN EndBit, IN UINT8 AndData)
/* If any reserved bits in Address are set, then ASSERT(). If StartBit is greater than 7, then ASSERT(). If EndBit is greater than 7, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT8 EFIAPI PciSegme...
{ return PciSegmentWrite8 ( Address, BitFieldAnd8 (PciSegmentRead8 (Address), StartBit, EndBit, AndData) ); }
tianocore/edk2
C++
Other
4,240
/* Set up the event system, linking the measurement and comparison timers so that events generated from the reference timer are linked to the measurement timer. */
static void setup_events(struct events_resource *event)
/* Set up the event system, linking the measurement and comparison timers so that events generated from the reference timer are linked to the measurement timer. */ static void setup_events(struct events_resource *event)
{ struct events_config config; events_get_config_defaults(&config); config.edge_detect = EVENTS_EDGE_DETECT_RISING; config.path = EVENTS_PATH_SYNCHRONOUS; config.generator = CONF_EVENT_GENERATOR_ID; events_allocate(event, &config); events_attach_user(event, CONF_EVENT_USED_ID); }
memfault/zero-to-main
C++
null
200
/* Purpose: Let user call ioctl() to get info when the UART physically is emptied. On bus types like RS485, the transmitter must release the bus after transmitting. This must be done when the transmit shift register is empty, not be done when the transmit holding register is empty. This functionality */
static unsigned int dz_tx_empty(struct uart_port *uport)
/* Purpose: Let user call ioctl() to get info when the UART physically is emptied. On bus types like RS485, the transmitter must release the bus after transmitting. This must be done when the transmit shift register is empty, not be done when the transmit holding register is empty. This functionality */ static unsigne...
{ struct dz_port *dport = to_dport(uport); unsigned short tmp, mask = 1 << dport->port.line; tmp = dz_in(dport, DZ_TCR); tmp &= mask; return tmp ? 0 : TIOCSER_TEMT; }
robutest/uclinux
C++
GPL-2.0
60
/* Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods . */
void gzp_delay_rx_periods(uint32_t rx_periods)
/* Delay function. Will add a delay equal to GZLL_RX_PERIOD * rx_periods . */ void gzp_delay_rx_periods(uint32_t rx_periods)
{ nrf_delay_us(rx_periods*2*nrf_gzll_get_timeslot_period()); }
labapart/polymcu
C++
null
201
/* Gets the CAN FD Bus Error Counter value. */
void CANFD_GetBusErrCount(CANFD_T *psCanfd, uint8_t *pu8TxErrBuf, uint8_t *pu8RxErrBuf)
/* Gets the CAN FD Bus Error Counter value. */ void CANFD_GetBusErrCount(CANFD_T *psCanfd, uint8_t *pu8TxErrBuf, uint8_t *pu8RxErrBuf)
{ if (pu8TxErrBuf) { *pu8TxErrBuf = (uint8_t)((CANFD_ReadReg(&psCanfd->ECR) >> CANFD_ECR_TEC_Pos) & CANFD_ECR_TEC_Msk); } if (pu8RxErrBuf) { *pu8RxErrBuf = (uint8_t)((CANFD_ReadReg(&psCanfd->ECR) >> CANFD_ECR_REC_Pos) & CANFD_ECR_REC_Msk); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Unloads the PCAN-Basic DLL and resets the API function pointers. */
static void PCanUsbLibUnloadDll(void)
/* Unloads the PCAN-Basic DLL and resets the API function pointers. */ static void PCanUsbLibUnloadDll(void)
{ pCanUsbLibFuncInitializePtr = NULL; pCanUsbLibFuncUninitializePtr = NULL; pCanUsbLibFuncGetStatusPtr = NULL; pCanUsbLibFuncSetValuePtr = NULL; pCanUsbLibFuncReadPtr = NULL; pCanUsbLibFuncWritePtr = NULL; pCanUsbLibFuncFilterMessagesPtr = NULL; if (pCanUsbDllHandle != NULL) { (void)FreeLibrary(p...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Searching for the next command when the variable or unknown length. */
static guint searchNext(tvbuff_t *tvb, guint begin, guint end)
/* Searching for the next command when the variable or unknown length. */ static guint searchNext(tvbuff_t *tvb, guint begin, guint end)
{ for(; begin < end; begin++) { if(tvb_get_guint8(tvb, begin) & 0x80) return begin; } return end; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* ping-pong heartbeat type: 0 - disable 1 - send ping frame but don't check pong frame 2 - send ping frame and check pong frame */
int uvoice_ws_heartbeat_set(int type)
/* ping-pong heartbeat type: 0 - disable 1 - send ping frame but don't check pong frame 2 - send ping frame and check pong frame */ int uvoice_ws_heartbeat_set(int type)
{ ws_handler_t *handler = g_ws_handler; if (!handler) { M_LOGE("ws handler null !\n"); return -1; } if (type < 0 || type > 2) { M_LOGE("type %d invalid !\n", type); return -1; } if (handler->heartbeat_type != type) { handler->heartbeat_type = type; M_LOGD("set heartbeat_type %d\n", handler->heartbe...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Unregisters a callback. Unregisters a callback function implemented by the user. The callback should be disabled before it is unregistered. */
enum status_code freqm_unregister_callback(struct freqm_module *module, enum freqm_callback callback_type)
/* Unregisters a callback. Unregisters a callback function implemented by the user. The callback should be disabled before it is unregistered. */ enum status_code freqm_unregister_callback(struct freqm_module *module, enum freqm_callback callback_type)
{ Assert(module); if (callback_type >= FREQM_CALLBACK_TYPE_NUM) { Assert(false); return STATUS_ERR_INVALID_ARG; } module->callback[callback_type] = NULL; return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_EnableEP(uint32_t EPNum)
/* Enable USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_EnableEP(uint32_t EPNum)
{ uint32_t *ptr;; ptr = GetEpCmdStatPtr(EPNum); if (EPNum & USB_IN_MASK) { EPNum &= ~USB_IN_MASK; *ptr &= ~EP_DISABLED; USBHSD->INTSTAT = (1 << EP_IN_IDX(EPNum)); USBHSD->INTEN |= (1 << EP_IN_IDX(EPNum)); } else { *ptr &= ~EP_DISABLED; *ptr |= EP_BUF...
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Create a global array refs in the heap stash. */
void be_ref_setup(duk_context *ctx)
/* Create a global array refs in the heap stash. */ void be_ref_setup(duk_context *ctx)
{ duk_push_heap_stash(ctx); duk_push_array(ctx); duk_push_int(ctx, 0); duk_put_prop_index(ctx, -2, 0); duk_put_prop_string(ctx, -2, "refs"); duk_pop(ctx); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* an extra long jump if the false branch requires it (p->longjf). */
static u_int count_stmts(struct icode *ic, struct block *p)
/* an extra long jump if the false branch requires it (p->longjf). */ static u_int count_stmts(struct icode *ic, struct block *p)
{ u_int n; if (p == 0 || isMarked(ic, p)) return 0; Mark(ic, p); n = count_stmts(ic, JT(p)) + count_stmts(ic, JF(p)); return slength(p->stmts) + n + 1 + p->longjt + p->longjf; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Waits to send data over the specified data line */
void I2SDataPut(unsigned long ulBase, unsigned long ulDataLine, unsigned long ulData)
/* Waits to send data over the specified data line */ void I2SDataPut(unsigned long ulBase, unsigned long ulDataLine, unsigned long ulData)
{ ulDataLine = (ulDataLine-1) << 2; while(!( HWREG(ulBase + MCASP_O_TXSTAT) & MCASP_TXSTAT_XDATA)) { } HWREG(ulBase + MCASP_O_TXBUF0 + ulDataLine) = ulData; }
micropython/micropython
C++
Other
18,334
/* Sets the rate limit to which the @monitor will report consecutive change events to the same file. */
void g_file_monitor_set_rate_limit(GFileMonitor *monitor, gint limit_msecs)
/* Sets the rate limit to which the @monitor will report consecutive change events to the same file. */ void g_file_monitor_set_rate_limit(GFileMonitor *monitor, gint limit_msecs)
{ g_object_set (monitor, "rate-limit", limit_msecs, NULL); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* get the key data for an FSDEF index record - this is the name of the netfs for which this entry is created */
static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data, void *buffer, uint16_t bufmax)
/* get the key data for an FSDEF index record - this is the name of the netfs for which this entry is created */ static uint16_t fscache_fsdef_netfs_get_key(const void *cookie_netfs_data, void *buffer, uint16_t bufmax)
{ const struct fscache_netfs *netfs = cookie_netfs_data; unsigned klen; _enter("{%s.%u},", netfs->name, netfs->version); klen = strlen(netfs->name); if (klen > bufmax) return 0; memcpy(buffer, netfs->name, klen); return klen; }
robutest/uclinux
C++
GPL-2.0
60
/* sends an NPE the updated configuration related to one QoS priority (associated traffic class and AQM mapping) */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex)
/* sends an NPE the updated configuration related to one QoS priority (associated traffic class and AQM mapping) */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBUpdateTrafficClass(IxEthDBPortId portID, UINT32 classIndex)
{ IxNpeMhMessage message; IX_STATUS result; UINT32 trafficClass = ixEthDBPortInfo[portID].priorityTable[classIndex]; UINT32 aqmQueue = ixEthDBPortInfo[portID].ixEthDBTrafficClassAQMAssignments[trafficClass]; FILL_SETRXQOSENTRY(message, IX_ETH_DB_PORT_ID_TO_NPE_LOGICAL_ID(portID), classIndex, tra...
EmcraftSystems/u-boot
C++
Other
181
/* pmcraid_unregister_hcams - cancel HCAMs registered already @cmd: pointer to command used as part of reset sequence */
static void pmcraid_unregister_hcams(struct pmcraid_cmd *cmd)
/* pmcraid_unregister_hcams - cancel HCAMs registered already @cmd: pointer to command used as part of reset sequence */ static void pmcraid_unregister_hcams(struct pmcraid_cmd *cmd)
{ struct pmcraid_instance *pinstance = cmd->drv_inst; atomic_set(&pinstance->ccn.ignore, 1); atomic_set(&pinstance->ldn.ignore, 1); if (pinstance->force_ioa_reset && !pinstance->ioa_bringdown) { pinstance->force_ioa_reset = 0; pinstance->ioa_state = IOA_STATE_IN_RESET_ALERT; pmcraid_reset_alert(cmd); return...
robutest/uclinux
C++
GPL-2.0
60
/* ZigBee Device Profile dissector for the network address */
void dissect_zbee_zdp_req_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the network address */ void dissect_zbee_zdp_req_nwk_addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; guint64 ext_addr; ext_addr = zbee_parse_eui64(tree, hf_zbee_zdp_ext_addr, tvb, &offset, sizeof(guint64), NULL); zbee_parse_uint(tree, hf_zbee_zdp_req_type, tvb, &offset, sizeof(guint8), NULL); zbee_parse_uint(tree, hf_zbee_zdp_index, tvb, &offset, sizeof(guint8), NULL); zbee_ap...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Handler to get access to the driver specific slave data structure */
static struct lpc_spi_slave* to_lpc_spi(struct spi_slave *slave)
/* Handler to get access to the driver specific slave data structure */ static struct lpc_spi_slave* to_lpc_spi(struct spi_slave *slave)
{ return container_of(slave, struct lpc_spi_slave, slave); }
EmcraftSystems/u-boot
C++
Other
181
/* translate ns coding of SPD timing values into 10 ps unit values */
static unsigned short NSto10PS(unsigned char spd_byte)
/* translate ns coding of SPD timing values into 10 ps unit values */ static unsigned short NSto10PS(unsigned char spd_byte)
{ return (spd_byte * 100); }
EmcraftSystems/u-boot
C++
Other
181
/* Get the MIPI DSI host controller instance from peripheral base address. */
uint32_t DSI_GetInstance(const MIPI_DSI_Type *base)
/* Get the MIPI DSI host controller instance from peripheral base address. */ uint32_t DSI_GetInstance(const MIPI_DSI_Type *base)
{ uint32_t instance; for (instance = 0; instance < ARRAY_SIZE(s_dsiBases); instance++) { if (s_dsiBases[instance] == base->host) { break; } } assert(instance < ARRAY_SIZE(s_dsiBases)); return instance; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Setup DMA mask to 64MB on PCI devices. Ignore all other devices. */
static int ixp4xx_pci_platform_notify(struct device *dev)
/* Setup DMA mask to 64MB on PCI devices. Ignore all other devices. */ static int ixp4xx_pci_platform_notify(struct device *dev)
{ if(dev->bus == &pci_bus_type) { *dev->dma_mask = SZ_64M - 1; dev->coherent_dma_mask = SZ_64M - 1; dmabounce_register_dev(dev, 2048, 4096); } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Register user's interrupt callback function for the RTC. */
void RTCIntCallbackInit(xtEventCallback pfnCallback)
/* Register user's interrupt callback function for the RTC. */ void RTCIntCallbackInit(xtEventCallback pfnCallback)
{ xASSERT(pfnCallback != 0); g_pfnRTCHandlerCallbacks = pfnCallback; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* param base ACMP peripheral base address. param enable True to enable DMA. */
void ACMP_EnableDMA(CMP_Type *base, bool enable)
/* param base ACMP peripheral base address. param enable True to enable DMA. */ void ACMP_EnableDMA(CMP_Type *base, bool enable)
{ if (enable) { base->C0 = ((base->C0 | CMP_C0_DMAEN_MASK) & ~CMP_C0_CFx_MASK); } else { base->C0 &= ~(CMP_C0_DMAEN_MASK | CMP_C0_CFx_MASK); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PC.01 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PC.01 is high then the adafruit 1.8" TFT shield is available. */
static ShieldStatus TFT_ShieldDetect(void)
/* Check the availability of adafruit 1.8" TFT shield on top of STM32NUCLEO board. This is done by reading the state of IO PC.01 pin (mapped to JoyStick available on adafruit 1.8" TFT shield). If the state of PC.01 is high then the adafruit 1.8" TFT shield is available. */ static ShieldStatus TFT_ShieldDetect(...
{ GPIO_InitTypeDef GPIO_InitStruct; __HAL_RCC_GPIOC_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_1) != 0) { return SHIELD_DETECTED; } else...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Look for SBNI card which addr stored in dev->base_addr, if nonzero. Otherwise, look through PCI bus. If none PCI-card was found, scan ISA. */
static int __init sbni_isa_probe(struct net_device *dev)
/* Look for SBNI card which addr stored in dev->base_addr, if nonzero. Otherwise, look through PCI bus. If none PCI-card was found, scan ISA. */ static int __init sbni_isa_probe(struct net_device *dev)
{ if( dev->base_addr > 0x1ff && request_region( dev->base_addr, SBNI_IO_EXTENT, dev->name ) && sbni_probe1( dev, dev->base_addr, dev->irq ) ) return 0; else { printk( KERN_ERR "sbni: base address 0x%lx is busy, or adapter " "is malfunctional!\n", dev->base_addr ); return -ENODEV; } }
robutest/uclinux
C++
GPL-2.0
60
/* Operation is relative to the DMA bus master. */
EFI_STATUS EFIAPI DmaMap(IN DMA_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
/* Operation is relative to the DMA bus master. */ EFI_STATUS EFIAPI DmaMap(IN DMA_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
{ if ((HostAddress == NULL) || (NumberOfBytes == NULL) || (DeviceAddress == NULL) || (Mapping == NULL)) { return EFI_INVALID_PARAMETER; } *DeviceAddress = HostToDeviceAddress (HostAddress); *Mapping = NULL; return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* On devices supporting extended PWM fault handling, the state the affected output pins are driven to can be configured with */
void PWMOutputFault(unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bFaultSuppress)
/* On devices supporting extended PWM fault handling, the state the affected output pins are driven to can be configured with */ void PWMOutputFault(unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bFaultSuppress)
{ ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT(!(ulPWMOutBits & ~(PWM_OUT_0_BIT | PWM_OUT_1_BIT | PWM_OUT_2_BIT | PWM_OUT_3_BIT | PWM_OUT_4_BIT | PWM_OUT_5_BIT | PWM_OUT_6_BIT | PWM_OUT_7_BIT))); if(bFaultSuppress == true) { ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the CC enable mask. The mask indicates which CC line is enabled. */
static uint32_t ucpd_get_cc_enable_mask(const struct device *dev)
/* Get the CC enable mask. The mask indicates which CC line is enabled. */ static uint32_t ucpd_get_cc_enable_mask(const struct device *dev)
{ struct tcpc_data *data = dev->data; const struct tcpc_config *const config = dev->config; uint32_t mask = UCPD_CR_CCENABLE_Msk; if (data->ucpd_vconn_enable) { uint32_t cr = LL_UCPD_ReadReg(config->ucpd_port, CR); int pol = (cr & UCPD_CR_PHYCCSEL); mask &= ~BIT(UCPD_CR_CCENABLE_Pos + !pol); } return mask; ...
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* See if the mapping(s) for this btree block are valid, i.e. don't contain holes, are logically contiguous, and cover the whole range. */
STATIC int xfs_da_map_covers_blocks(int nmap, xfs_bmbt_irec_t *mapp, xfs_dablk_t bno, int count)
/* See if the mapping(s) for this btree block are valid, i.e. don't contain holes, are logically contiguous, and cover the whole range. */ STATIC int xfs_da_map_covers_blocks(int nmap, xfs_bmbt_irec_t *mapp, xfs_dablk_t bno, int count)
{ int i; xfs_fileoff_t off; for (i = 0, off = bno; i < nmap; i++) { if (mapp[i].br_startblock == HOLESTARTBLOCK || mapp[i].br_startblock == DELAYSTARTBLOCK) { return 0; } if (off != mapp[i].br_startoff) { return 0; } off += mapp[i].br_blockcount; } return off == bno + count; }
robutest/uclinux
C++
GPL-2.0
60
/* Created on: Oct 27, 2021 Author: jiangyuanyuan Configure pins as Analog Input Output EVENT_OUT EXTI */
void MY_MOTOR_Init(void)
/* Created on: Oct 27, 2021 Author: jiangyuanyuan Configure pins as Analog Input Output EVENT_OUT EXTI */ void MY_MOTOR_Init(void)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; __HAL_RCC_GPIO_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_13 | GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); Motor_Stop(); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: (transfer full): The user data pointer set, or NULL */
gpointer g_object_steal_qdata(GObject *object, GQuark quark)
/* Returns: (transfer full): The user data pointer set, or NULL */ gpointer g_object_steal_qdata(GObject *object, GQuark quark)
{ g_return_val_if_fail (G_IS_OBJECT (object), NULL); g_return_val_if_fail (quark > 0, NULL); return g_datalist_id_remove_no_notify (&object->qdata, quark); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Determine if a particular character is a space character */
int isspace(int c)
/* Determine if a particular character is a space character */ int isspace(int c)
{ return ((c) == ' ') || ((c) == '\t') || ((c) == '\r') || ((c) == '\n') || ((c) == '\v') || ((c) == '\f'); }
tianocore/edk2
C++
Other
4,240
/* Users are usually interested in average times, not accumulated time. This also helps us with atomicity problems when reading sinlge values. */
static u64 time_to_avg_nsec(u32 value, u32 count)
/* Users are usually interested in average times, not accumulated time. This also helps us with atomicity problems when reading sinlge values. */ static u64 time_to_avg_nsec(u32 value, u32 count)
{ u64 ret; if (count == 0) return 0; ret = time_to_nsec(value); do_div(ret, count); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* zfcp_erp_unit_reopen - initiate reopen of a unit @unit: unit to be reopened @clear_mask: specifies flags in unit status to be cleared Return: 0 on success, < 0 on error */
void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, void *ref)
/* zfcp_erp_unit_reopen - initiate reopen of a unit @unit: unit to be reopened @clear_mask: specifies flags in unit status to be cleared Return: 0 on success, < 0 on error */ void zfcp_erp_unit_reopen(struct zfcp_unit *unit, int clear, char *id, void *ref)
{ unsigned long flags; struct zfcp_port *port = unit->port; struct zfcp_adapter *adapter = port->adapter; write_lock_irqsave(&adapter->erp_lock, flags); _zfcp_erp_unit_reopen(unit, clear, id, ref); write_unlock_irqrestore(&adapter->erp_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Clear Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */
void USBD_ClrStallEP(uint32_t EPNum)
/* Clear Stall for USB Device Endpoint Parameters: EPNum: Device Endpoint Number EPNum.0..3: Address EPNum.7: Dir Return Value: None */ void USBD_ClrStallEP(uint32_t EPNum)
{ if (EPNum & 0x80) { EPNum &= 0x7F; ENDPTCTRL(EPNum) &= ~(1UL << 16); ENDPTCTRL(EPNum) |= (1UL << 22); while (ENDPTCTRL(EPNum) & (1UL << 16)); USBD_ResetEP(EPNum | 0x80); } else { ENDPTCTRL(EPNum) &= ~(1UL << 0); ENDPTCTRL(EPNum) |= (1UL << 6); } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* ADC MSP De-Initialization This function frees the hardware resources used in this example: */
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
/* ADC MSP De-Initialization This function frees the hardware resources used in this example: */ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
{ static DMA_HandleTypeDef hdma_adc; ADCxyz_FORCE_RESET(); ADCxyz_RELEASE_RESET(); HAL_GPIO_DeInit(ADCxyz_CHANNEL_GPIO_PORT, ADCxyz_CHANNEL_PIN); HAL_DMA_DeInit(&hdma_adc); HAL_NVIC_DisableIRQ(ADCxyz_DMA_IRQn); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Get current configured I2C bus frequency. This frequency is only of relevance when acting as master. */
uint32_t I2C_BusFreqGet(I2C_TypeDef *i2c)
/* Get current configured I2C bus frequency. This frequency is only of relevance when acting as master. */ uint32_t I2C_BusFreqGet(I2C_TypeDef *i2c)
{ uint32_t hfperclk; uint32_t n; hfperclk = CMU_ClockFreqGet(cmuClock_HFPER); n = (uint32_t)(i2cNSum[(i2c->CTRL & _I2C_CTRL_CLHR_MASK) >> _I2C_CTRL_CLHR_SHIFT]); return(hfperclk / ((n * (i2c->CLKDIV + 1)) + 4)); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* param base MCAN peripheral base address. param config The MCAN filter configuration. param filter The MCAN standard message ID filter element configuration. param idx The standard message ID filter element index. */
void MCAN_SetSTDFilterElement(CAN_Type *base, const mcan_frame_filter_config_t *config, const mcan_std_filter_element_config_t *filter, uint8_t idx)
/* param base MCAN peripheral base address. param config The MCAN filter configuration. param filter The MCAN standard message ID filter element configuration. param idx The standard message ID filter element index. */ void MCAN_SetSTDFilterElement(CAN_Type *base, const mcan_frame_filter_config_t *config, const mcan_s...
{ uint32_t *elementAddress = NULL; elementAddress = (uint32_t *)(MCAN_GetMsgRAMBase(base) + config->address + idx * 4U); (void)memcpy((void *)elementAddress, (const void *)filter, sizeof(mcan_std_filter_element_config_t)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns extra data associated with an event in WMI. */
acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
/* Returns extra data associated with an event in WMI. */ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
{ struct acpi_object_list input; union acpi_object params[1]; struct guid_block *gblock; struct wmi_block *wblock; struct list_head *p; input.count = 1; input.pointer = params; params[0].type = ACPI_TYPE_INTEGER; params[0].integer.value = event; list_for_each(p, &wmi_blocks.list) { wblock = list_entry(p, st...
EmcraftSystems/linux-emcraft
C++
Other
266
/* setup_pex() - Configure the SerDes device to PCI Express mode @dev: The device to configure @type: The PCI Express type to configure for (x1 or x2) */
static void setup_pex(struct udevice *dev, enum pex_type type)
/* setup_pex() - Configure the SerDes device to PCI Express mode @dev: The device to configure @type: The PCI Express type to configure for (x1 or x2) */ static void setup_pex(struct udevice *dev, enum pex_type type)
{ struct mpc83xx_serdes_priv *priv = dev_get_priv(dev); setbits_be32(&priv->regs->srdscr1, SRDSCR1_PLLBW); clrsetbits_be32(&priv->regs->srdscr2, SRDSCR2_SEIC_MASK, SRDSCR2_SEIC_PEX); out_be32(&priv->regs->srdscr3, SRDSCR3_SDFM_SATA_PEX); if (type == PEX_X2) out_be32(&priv->regs->srdscr4, priv->rfcks | ...
4ms/stm32mp1-baremetal
C++
Other
137
/* Indicates polarity of DEN signal on OIS chain.. */
int32_t lsm6dso_aux_den_polarity_set(stmdev_ctx_t *ctx, lsm6dso_den_lh_ois_t val)
/* Indicates polarity of DEN signal on OIS chain.. */ int32_t lsm6dso_aux_den_polarity_set(stmdev_ctx_t *ctx, lsm6dso_den_lh_ois_t val)
{ lsm6dso_int_ois_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)&reg, 1); if (ret == 0) { reg.den_lh_ois = (uint8_t)val; ret = lsm6dso_write_reg(ctx, LSM6DSO_INT_OIS, (uint8_t *)&reg, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Programs the FMC User Option Byte: WDTSEL / RSTSTOP / RSTSTDB. */
void FMC_OPT_ConfigUser(FMC_OPT_IWDT_T iwdt, FMC_OPT_STOP_T stop, FMC_OPT_STDBY_T stdby)
/* Programs the FMC User Option Byte: WDTSEL / RSTSTOP / RSTSTDB. */ void FMC_OPT_ConfigUser(FMC_OPT_IWDT_T iwdt, FMC_OPT_STOP_T stop, FMC_OPT_STDBY_T stdby)
{ uint8_t option = 0xFF; FMC_STATUS_T status = FMC_COMPLETE; status = FMC_WaitForLastOperation(); if (status == FMC_COMPLETE) { option = (uint8_t)((*(__IO uint8_t *)OPTCTRL_BYTE0_ADDRESS) & 0x0F); *(__IO uint8_t *)OPTCTRL_BYTE0_ADDRESS = ((uint8_t)iwdt | stop | stdby | option); }...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* generate a null-terminated string containing the buttons pressed returns number of keys pressed */
static int read_keys(char *buf)
/* generate a null-terminated string containing the buttons pressed returns number of keys pressed */ static int read_keys(char *buf)
{ int i, numpressed = 0; for (i = 0; i < ARRAY_SIZE(buttons); i++) { if (!gpio_get_value(buttons[i].gpnum)) buf[numpressed++] = buttons[i].ident; } buf[numpressed] = '\0'; return numpressed; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns: (transfer full) (type _GFreedesktopDBusProxy): The constructed proxy object or NULL if @error is set. */
_GFreedesktopDBus* _g_freedesktop_dbus_proxy_new_finish(GAsyncResult *res, GError **error)
/* Returns: (transfer full) (type _GFreedesktopDBusProxy): The constructed proxy object or NULL if @error is set. */ _GFreedesktopDBus* _g_freedesktop_dbus_proxy_new_finish(GAsyncResult *res, GError **error)
{ GObject *ret; GObject *source_object; source_object = g_async_result_get_source_object (res); ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (ret != NULL) return _G_FREEDESKTOP_DBUS (ret); else return NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* TIM_PWM MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim_pwm)
/* TIM_PWM MSP Initialization This function configures the hardware resources used in this example. */ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim_pwm)
{ if(htim_pwm->Instance==TIM3) { __HAL_RCC_TIM3_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get compare value of the specified TMR2 channel. */
uint32_t TMR2_GetCompareValue(const CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch)
/* Get compare value of the specified TMR2 channel. */ uint32_t TMR2_GetCompareValue(const CM_TMR2_TypeDef *TMR2x, uint32_t u32Ch)
{ __IO uint32_t *reg32CMPR; DDL_ASSERT(IS_TMR2_UNIT(TMR2x)); DDL_ASSERT(IS_TMR2_CH(u32Ch)); reg32CMPR = (__IO uint32_t *)((uint32_t)&TMR2x->CMPAR); return reg32CMPR[u32Ch]; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Return a multiplier for the exit latency that is intended to take performance requirements into account. The more performance critical we estimate the system to be, the higher this multiplier, and thus the higher the barrier to go to an expensive C state. */
static int performance_multiplier(void)
/* Return a multiplier for the exit latency that is intended to take performance requirements into account. The more performance critical we estimate the system to be, the higher this multiplier, and thus the higher the barrier to go to an expensive C state. */ static int performance_multiplier(void)
{ int mult = 1; mult += 2 * get_loadavg(); mult += 10 * nr_iowait_cpu(); return mult; }
robutest/uclinux
C++
GPL-2.0
60
/* This function causes a systemwide reset. The exact type of the reset is defined by the EFI_GUID that follows the Null-terminated Unicode string passed into ResetData. If the platform does not recognize the EFI_GUID in ResetData the platform must pick a supported reset type to perform.The platform may optionally log ...
VOID EFIAPI ResetPlatformSpecific(IN UINTN DataSize, IN VOID *ResetData)
/* This function causes a systemwide reset. The exact type of the reset is defined by the EFI_GUID that follows the Null-terminated Unicode string passed into ResetData. If the platform does not recognize the EFI_GUID in ResetData the platform must pick a supported reset type to perform.The platform may optionally log ...
{ PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData); }
tianocore/edk2
C++
Other
4,240
/* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */
int _serial_getc(const int dev_index)
/* Read a single byte from the serial port. Returns 1 on success, 0 otherwise. When the function is succesfull, the character read is written into its argument c. */ int _serial_getc(const int dev_index)
{ struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index); while (!(readl(&uart->UTRSTAT) & 0x1)) ; return readb(&uart->URXH) & 0xff; }
EmcraftSystems/u-boot
C++
Other
181
/* this function composes an element type from metadata/payload (TLV structure) */
uint16_t setElementType(uint8_t isValue, uint8_t requestIdx, uint8_t elementVal)
/* this function composes an element type from metadata/payload (TLV structure) */ uint16_t setElementType(uint8_t isValue, uint8_t requestIdx, uint8_t elementVal)
{ uint16_t elementType; elementType = elementVal; elementType |= (((isValue << 7) | (requestIdx & 0x7F)) << 8); return (elementType); }
nanoframework/nf-interpreter
C++
MIT License
293
/* This function prepares for the installation of DiskInfo protocol on the child handle. By default, it installs DiskInfo protocol with NVME interface GUID. */
VOID InitializeDiskInfo(IN NVME_DEVICE_PRIVATE_DATA *Device)
/* This function prepares for the installation of DiskInfo protocol on the child handle. By default, it installs DiskInfo protocol with NVME interface GUID. */ VOID InitializeDiskInfo(IN NVME_DEVICE_PRIVATE_DATA *Device)
{ CopyMem (&Device->DiskInfo, &gNvmExpressDiskInfoProtocolTemplate, sizeof (EFI_DISK_INFO_PROTOCOL)); }
tianocore/edk2
C++
Other
4,240
/* Map linear and fragment data from the skb to spd. It reports failure if the pipe is full or if we already spliced the requested length. */
static int __skb_splice_bits(struct sk_buff *skb, unsigned int *offset, unsigned int *len, struct splice_pipe_desc *spd, struct sock *sk)
/* Map linear and fragment data from the skb to spd. It reports failure if the pipe is full or if we already spliced the requested length. */ static int __skb_splice_bits(struct sk_buff *skb, unsigned int *offset, unsigned int *len, struct splice_pipe_desc *spd, struct sock *sk)
{ int seg; if (__splice_segment(virt_to_page(skb->data), (unsigned long) skb->data & (PAGE_SIZE - 1), skb_headlen(skb), offset, len, skb, spd, 1, sk)) return 1; for (seg = 0; seg < skb_shinfo(skb)->nr_frags; seg++) { const skb_frag_t *f = &skb_shinfo(skb)->frags[seg]; if (__splice_segme...
EmcraftSystems/linux-emcraft
C++
Other
266
/* If PemData is NULL, then return FALSE. If RsaContext is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI RsaGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **RsaContext)
/* If PemData is NULL, then return FALSE. If RsaContext is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI RsaGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **RsaContext)
{ CALL_CRYPTO_SERVICE (RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Gets the callback for an interrupt if one is registered. */
bsp_int_err_t R_BSP_InterruptRead(bsp_int_src_t vector, bsp_int_cb_t *callback)
/* Gets the callback for an interrupt if one is registered. */ bsp_int_err_t R_BSP_InterruptRead(bsp_int_src_t vector, bsp_int_cb_t *callback)
{ bsp_int_err_t err; err = BSP_INT_SUCCESS; if (((uint32_t)g_bsp_vectors[vector] == (uint32_t)NULL) || ((uint32_t)g_bsp_vectors[vector] == (uint32_t)FIT_NO_FUNC)) { err = BSP_INT_ERR_NO_REGISTERED_CALLBACK; } else { *callback = g_bsp_vectors[vector]; } return err; }
eclipse-threadx/getting-started
C++
Other
310
/* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */
int ZEXPORT unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
/* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ int ZEXPORT unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf)
{ unz64_s* s; uLong uReadThis ; if (file==NULL) return (int)UNZ_PARAMERROR; s=(unz64_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) ...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* At a minimum one references should still be held. */
static void svc_rdma_detach(struct svc_xprt *xprt)
/* At a minimum one references should still be held. */ static void svc_rdma_detach(struct svc_xprt *xprt)
{ struct svcxprt_rdma *rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt); dprintk("svc: svc_rdma_detach(%p)\n", xprt); rdma_disconnect(rdma->sc_cm_id); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* kfifo_skip - skip output data @fifo: the fifo to be used. @len: number of bytes to skip */
void kfifo_skip(struct kfifo *fifo, unsigned int len)
/* kfifo_skip - skip output data @fifo: the fifo to be used. @len: number of bytes to skip */ void kfifo_skip(struct kfifo *fifo, unsigned int len)
{ if (len < kfifo_len(fifo)) { __kfifo_add_out(fifo, len); return; } kfifo_reset_out(fifo); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Write new etr control register if it differs from the current one. Return 1 if etr_tolec has been updated as well. */
static void etr_update_eacr(struct etr_eacr eacr)
/* Write new etr control register if it differs from the current one. Return 1 if etr_tolec has been updated as well. */ static void etr_update_eacr(struct etr_eacr eacr)
{ int dp_changed; if (memcmp(&etr_eacr, &eacr, sizeof(eacr)) == 0) return; dp_changed = etr_eacr.e0 > eacr.e0 || etr_eacr.e1 > eacr.e1 || (etr_eacr.dp ^ eacr.dp) != 0; etr_eacr = eacr; etr_setr(&etr_eacr); if (dp_changed) etr_tolec = get_clock(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the number of rules in the stylesheet. */
gint cr_stylesheet_nr_rules(CRStyleSheet *a_this)
/* Return the number of rules in the stylesheet. */ gint cr_stylesheet_nr_rules(CRStyleSheet *a_this)
{ g_return_val_if_fail (a_this, -1); return cr_statement_nr_rules (a_this->statements); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* FLASH_SetStatusBits set or clear status bits., used to set protect bit or quad enable bit, and lock CPU when set. */
IMAGE2_RAM_TEXT_SECTION void FLASH_SetStatusBitsXIP(u32 SetBits, u32 NewState)
/* FLASH_SetStatusBits set or clear status bits., used to set protect bit or quad enable bit, and lock CPU when set. */ IMAGE2_RAM_TEXT_SECTION void FLASH_SetStatusBitsXIP(u32 SetBits, u32 NewState)
{ FLASH_Write_Lock(); FLASH_SetStatusBits(SetBits, NewState); FLASH_Write_Unlock(); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Retrieve the indexed string for the language. It requires two steps to get a string, first to get the string's length. Then the string itself. */
EFI_USB_STRING_DESCRIPTOR* UsbGetOneString(IN USB_DEVICE *UsbDev, IN UINT8 Index, IN UINT16 LangId)
/* Retrieve the indexed string for the language. It requires two steps to get a string, first to get the string's length. Then the string itself. */ EFI_USB_STRING_DESCRIPTOR* UsbGetOneString(IN USB_DEVICE *UsbDev, IN UINT8 Index, IN UINT16 LangId)
{ EFI_USB_STRING_DESCRIPTOR Desc; EFI_STATUS Status; UINT8 *Buf; Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_STRING, Index, LangId, &Desc, 2); if (EFI_ERROR (Status) || (Desc.Length < OFFSET_OF (EFI_USB_STRING_DESCRIPTOR, Length) + sizeof (Desc.Length)) || ...
tianocore/edk2
C++
Other
4,240
/* Generic glyph width get function used in 'font->get_width' when the font contains all characters in the range */
int16_t lv_font_get_width_continuous(const lv_font_t *font, uint32_t unicode_letter)
/* Generic glyph width get function used in 'font->get_width' when the font contains all characters in the range */ int16_t lv_font_get_width_continuous(const lv_font_t *font, uint32_t unicode_letter)
{ if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) { return -1; } uint32_t index = (unicode_letter - font->unicode_first); return font->glyph_dsc[index].w_px; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* This function makes sure UBIFS has enough free space to be mounted in read/write mode. UBIFS must always have some free space to allow deletions. */
static int check_free_space(struct ubifs_info *c)
/* This function makes sure UBIFS has enough free space to be mounted in read/write mode. UBIFS must always have some free space to allow deletions. */ static int check_free_space(struct ubifs_info *c)
{ ubifs_assert(c->dark_wm > 0); if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) { ubifs_err("insufficient free space to mount in read/write mode"); dbg_dump_budg(c); dbg_dump_lprops(c); return -ENOSPC; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Always return 1 (no second DRAM bank since based on TQM8xxL module) */
int checkboard(void)
/* Always return 1 (no second DRAM bank since based on TQM8xxL module) */ int checkboard(void)
{ unsigned char *s; unsigned char buf[64]; s = (getenv_r ("serial#", (char *)&buf, sizeof(buf)) > 0) ? buf : NULL; puts ("Board: Siemens CCM"); if (s) { puts (" ("); for (; *s; ++s) { if (*s == ' ') break; putc (*s); } putc (')'); } putc ('\n'); return (0); ...
EmcraftSystems/u-boot
C++
Other
181
/* mos7720_chars_in_buffer this function is called by the tty driver when it wants to know how many bytes of data we currently have outstanding in the port (data that has been written, but hasn't made it out the port yet) If successful, we return the number of bytes left to be written in the system, Otherwise we return...
static int mos7720_chars_in_buffer(struct tty_struct *tty)
/* mos7720_chars_in_buffer this function is called by the tty driver when it wants to know how many bytes of data we currently have outstanding in the port (data that has been written, but hasn't made it out the port yet) If successful, we return the number of bytes left to be written in the system, Otherwise we return...
{ struct usb_serial_port *port = tty->driver_data; int i; int chars = 0; struct moschip_port *mos7720_port; dbg("%s:entering ...........", __func__); mos7720_port = usb_get_serial_port_data(port); if (mos7720_port == NULL) { dbg("%s:leaving ...........", __func__); return 0; } for (i = 0; i < NUM_URBS; ++i...
robutest/uclinux
C++
GPL-2.0
60
/* Return the first urb in a list with a distinguished head "hd", or NULL if the list is empty. */
struct urb* first_urb(urb_link *hd)
/* Return the first urb in a list with a distinguished head "hd", or NULL if the list is empty. */ struct urb* first_urb(urb_link *hd)
{ urb_link *nx; if (NULL == (nx = first_urb_link (hd))) { return (NULL); } return (p2surround (struct urb, link, nx)); }
EmcraftSystems/u-boot
C++
Other
181
/* Flushes the IN and OUT FIFOs (that is read and write pointers of the FIFOs are reset) */
void CRYP_FIFOFlush(void)
/* Flushes the IN and OUT FIFOs (that is read and write pointers of the FIFOs are reset) */ void CRYP_FIFOFlush(void)
{ CRYP->CR |= CRYP_CR_FFLUSH; }
MaJerle/stm32f429
C++
null
2,036
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_set_linsync_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_set_linsync_handler(mss_uart_instance_t *this_uart, mss_uart_irq_handler_t handler)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); ASSERT(handler != INVALID_IRQ_HANDLER); if(((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)) && (handler != INVALID_IRQ_HANDLER)) { this_uart->sync_handler = handler; NVIC_ClearPendingIRQ( this_uart->...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* brief Return Frequency of PLL0 return Frequency of PLL0 */
uint32_t CLOCK_GetPll0OutFreq(void)
/* brief Return Frequency of PLL0 return Frequency of PLL0 */ uint32_t CLOCK_GetPll0OutFreq(void)
{ uint32_t clkRate = 0; uint32_t prediv, postdiv; float workRate = 0.0F; clkRate = CLOCK_GetPLL0InClockRate(); if (CLOCK_IsPLL0Locked() == true) { prediv = findPll0PreDiv(); postdiv = findPll0PostDiv(); clkRate = clkRate / prediv; workRate = (float)clkRate * (flo...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* RNG MSP De-Initialization This function freeze the hardware resources used in this example: */
void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng)
/* RNG MSP De-Initialization This function freeze the hardware resources used in this example: */ void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng)
{ __HAL_RCC_RNG_FORCE_RESET(); __HAL_RCC_RNG_RELEASE_RESET(); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* check_revision - close down user fib context @dev: adapter */
static int check_revision(struct aac_dev *dev, void __user *arg)
/* check_revision - close down user fib context @dev: adapter */ static int check_revision(struct aac_dev *dev, void __user *arg)
{ struct revision response; char *driver_version = aac_driver_version; u32 version; response.compat = 1; version = (simple_strtol(driver_version, &driver_version, 10) << 24) | 0x00000400; version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; version += simple_strtol(driver_version + 1, NUL...
robutest/uclinux
C++
GPL-2.0
60
/* dmar_table_detect - checks to see if the platform supports DMAR devices */
static int __init dmar_table_detect(void)
/* dmar_table_detect - checks to see if the platform supports DMAR devices */ static int __init dmar_table_detect(void)
{ acpi_status status = AE_OK; status = acpi_get_table_with_size(ACPI_SIG_DMAR, 0, (struct acpi_table_header **)&dmar_tbl, &dmar_tbl_size); if (ACPI_SUCCESS(status) && !dmar_tbl) { printk (KERN_WARNING PREFIX "Unable to map DMAR\n"); status = AE_NOT_FOUND; } return (ACPI_SUCCESS(status) ? 1 : 0); }
robutest/uclinux
C++
GPL-2.0
60
/* Advance this CPU's callbacks, but only if the current grace period has ended. This may be called only from the CPU to whom the rdp belongs. */
static void rcu_process_gp_end(struct rcu_state *rsp, struct rcu_data *rdp)
/* Advance this CPU's callbacks, but only if the current grace period has ended. This may be called only from the CPU to whom the rdp belongs. */ static void rcu_process_gp_end(struct rcu_state *rsp, struct rcu_data *rdp)
{ unsigned long flags; struct rcu_node *rnp; local_irq_save(flags); rnp = rdp->mynode; if (rdp->completed == ACCESS_ONCE(rnp->completed) || !spin_trylock(&rnp->lock)) { local_irq_restore(flags); return; } __rcu_process_gp_end(rsp, rnp, rdp); spin_unlock_irqrestore(&rnp->lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The functions for inserting/removing us as a module. */
static int __init touchit213_init(void)
/* The functions for inserting/removing us as a module. */ static int __init touchit213_init(void)
{ return serio_register_driver(&touchit213_drv); }
robutest/uclinux
C++
GPL-2.0
60
/* Return the biggest alignment (lowest set bit) of address. The function is equivalent to: 1 << LowBitSet64 (Address). */
UINT64 MtrrLibBiggestAlignment(UINT64 Address, UINT64 Alignment0)
/* Return the biggest alignment (lowest set bit) of address. The function is equivalent to: 1 << LowBitSet64 (Address). */ UINT64 MtrrLibBiggestAlignment(UINT64 Address, UINT64 Alignment0)
{ if (Address == 0) { return Alignment0; } return Address & ((~Address) + 1); }
tianocore/edk2
C++
Other
4,240
/* Enable the USART for the specified USART in SPI mode. */
void usart_spi_enable(Usart *p_usart)
/* Enable the USART for the specified USART in SPI mode. */ void usart_spi_enable(Usart *p_usart)
{ usart_enable_tx(p_usart); usart_enable_rx(p_usart); }
memfault/zero-to-main
C++
null
200
/* setup_sgmii() - Configure the SerDes device to SGMII mode @dev: The device to configure */
static void setup_sgmii(struct udevice *dev)
/* setup_sgmii() - Configure the SerDes device to SGMII mode @dev: The device to configure */ static void setup_sgmii(struct udevice *dev)
{ struct mpc83xx_serdes_priv *priv = dev_get_priv(dev); clrbits_be32(&priv->regs->srdscr1, SRDSCR1_PLLBW); clrsetbits_be32(&priv->regs->srdscr2, SRDSCR2_SEIC_MASK, SRDSCR2_SEIC_SGMII); out_be32(&priv->regs->srdscr3, 0); out_be32(&priv->regs->srdscr4, priv->rfcks | SRDSCR4_PROT_SGMII); }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function implements reading and resetting an atomic_t stat variable through read/write to a proc file. Any write to the file resets the associated statistic to zero. Any read returns it's current value. */
static int read_reset_stat(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
/* This function implements reading and resetting an atomic_t stat variable through read/write to a proc file. Any write to the file resets the associated statistic to zero. Any read returns it's current value. */ static int read_reset_stat(ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
{ atomic_t *stat = (atomic_t *)table->data; if (!stat) return -EINVAL; if (write) atomic_set(stat, 0); else { char str_buf[32]; char *data; int len = snprintf(str_buf, 32, "%d\n", atomic_read(stat)); if (len >= 32) return -EFAULT; len = strlen(str_buf); if (*ppos > len) { *lenp = 0; return ...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the handle of the timer of the first allocated timer that has the specified parameter. */
timer_handle_t TM_GetFirstTimerWithParam(void *param)
/* Returns the handle of the timer of the first allocated timer that has the specified parameter. */ timer_handle_t TM_GetFirstTimerWithParam(void *param)
{ list_element_handle_t list_element; list_handle_t timerHandle = &s_timermanager.timerHead; list_element = LIST_GetHead(timerHandle); while (NULL != list_element) { timer_handle_struct_t *th = (timer_handle_struct_t *)(void *)list_element; if (th->param == param) { ...
eclipse-threadx/getting-started
C++
Other
310
/* This function is convenient to getting data except including high and low data for this sensor. note:after reading lower register first,reading higher add one. */
static uint32_t read_low_and_high(uint8_t reg, uint8_t len)
/* This function is convenient to getting data except including high and low data for this sensor. note:after reading lower register first,reading higher add one. */ static uint32_t read_low_and_high(uint8_t reg, uint8_t len)
{ uint32_t data; uint8_t buf = 0; read_regs(reg, len, &buf); data = buf; read_regs(reg + 1, len, &buf); data = data + (buf << len * 8); return data; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Create the 8 bytes EBCDIC DCSS segment name from an ASCII name, incl. padding */
static void dcss_mkname(char *ascii_name, char *ebcdic_name)
/* Create the 8 bytes EBCDIC DCSS segment name from an ASCII name, incl. padding */ static void dcss_mkname(char *ascii_name, char *ebcdic_name)
{ int i; for (i = 0; i < 8; i++) { if (ascii_name[i] == '\0') break; ebcdic_name[i] = toupper(ascii_name[i]); }; for (; i < 8; i++) ebcdic_name[i] = ' '; ASCEBC(ebcdic_name, 8); }
robutest/uclinux
C++
GPL-2.0
60
/* Parse, and display the results of an unknown IE. */
static void iw_print_ie_unknown(unsigned char *iebuf, int buflen)
/* Parse, and display the results of an unknown IE. */ static void iw_print_ie_unknown(unsigned char *iebuf, int buflen)
{ int ielen = iebuf[1] + 2; int i; if(ielen > buflen) ielen = buflen; printf("Unknown: "); for(i = 0; i < ielen; i++) printf("%02X", iebuf[i]); printf("\n"); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power state) and waits for it to take effect. */
static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
/* ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power state) and waits for it to take effect. */ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
{ unsigned long start = 0; u8 status; int ret; ret = ufshcd_send_uic_cmd(hba, cmd); if (ret) { dev_err(hba->dev, "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", cmd->command, cmd->argument3, ret); return ret; } start = get_timer(0); do { status = ufshcd_get_upmcrs(hba); if (get_timer(start) > U...
4ms/stm32mp1-baremetal
C++
Other
137
/* Get the ENET instance from peripheral base address. */
uint32_t ENET_GetInstance(ENET_Type *base)
/* Get the ENET instance from peripheral base address. */ uint32_t ENET_GetInstance(ENET_Type *base)
{ uint32_t instance; for (instance = 0; instance < ARRAY_SIZE(s_enetBases); instance++) { if (s_enetBases[instance] == base) { break; } } assert(instance < ARRAY_SIZE(s_enetBases)); return instance; }
eclipse-threadx/getting-started
C++
Other
310
/* After waiting for a given time this puts a job in the kernel-global workqueue on the specified CPU. */
int schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay)
/* After waiting for a given time this puts a job in the kernel-global workqueue on the specified CPU. */ int schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay)
{ return queue_delayed_work_on(cpu, keventd_wq, dwork, delay); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* gluebi_notify - UBI notification handler. @nb: registered notifier block @l: notification type @ptr: pointer to the &struct ubi_notification object */
static int gluebi_notify(struct notifier_block *nb, unsigned long l, void *ns_ptr)
/* gluebi_notify - UBI notification handler. @nb: registered notifier block @l: notification type @ptr: pointer to the &struct ubi_notification object */ static int gluebi_notify(struct notifier_block *nb, unsigned long l, void *ns_ptr)
{ struct ubi_notification *nt = ns_ptr; switch (l) { case UBI_VOLUME_ADDED: gluebi_create(&nt->di, &nt->vi); break; case UBI_VOLUME_REMOVED: gluebi_remove(&nt->vi); break; case UBI_VOLUME_RESIZED: gluebi_resized(&nt->vi); break; case UBI_VOLUME_UPDATED: gluebi_updated(&nt->vi); break; default: ...
robutest/uclinux
C++
GPL-2.0
60
/* Upon successful completion, poll() shall return a non-negative value. A positive value indicates the total number of pollfd structures that have selected events (that is, those for which the revents member is non-zero). A value of 0 indicates that the call timed out and no file descriptors have been selected. Upon f...
static int wait(int timeout)
/* Upon successful completion, poll() shall return a non-negative value. A positive value indicates the total number of pollfd structures that have selected events (that is, those for which the revents member is non-zero). A value of 0 indicates that the call timed out and no file descriptors have been selected. Upon f...
{ int rc = 0; if (sh_mqtt->nfds > 0) { rc = zsock_poll(sh_mqtt->fds, sh_mqtt->nfds, timeout); if (rc < 0) { LOG_ERR("poll error: %d", errno); } } return rc; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* b a c k s o l v e R */
returnValue QProblem_backsolveR(QProblem *_THIS, const real_t *const b, BooleanType transposed, real_t *const a)
/* b a c k s o l v e R */ returnValue QProblem_backsolveR(QProblem *_THIS, const real_t *const b, BooleanType transposed, real_t *const a)
{ return QProblem_backsolveRrem( _THIS,b,transposed,BT_FALSE,a ); }
DanielMartensson/EmbeddedLapack
C++
MIT License
129
/* USB Device Bulk In Endpoint Event Callback Parameters: event: not used (just for compatibility) Return Value: None */
void USBD_BULK_EP_BULKIN_Event(U32 event)
/* USB Device Bulk In Endpoint Event Callback Parameters: event: not used (just for compatibility) Return Value: None */ void USBD_BULK_EP_BULKIN_Event(U32 event)
{ uint8_t * sbuf = 0; int slen; if(DAP_queue_get_send_buf(&DAP_Cmd_queue, &sbuf, &slen)){ USBD_WriteEP(usbd_bulk_ep_bulkin | 0x80, sbuf, slen); } else { USB_ResponseIdle = 1; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Configures the RTC and LCD clock (RTCCLK / LCDCLK). */
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
/* Configures the RTC and LCD clock (RTCCLK / LCDCLK). */ void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
{ uint32_t tmpreg = 0; assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource)); if ((RCC_RTCCLKSource & RCC_CSR_RTCSEL_HSE) == RCC_CSR_RTCSEL_HSE) { tmpreg = RCC->CR; tmpreg &= ~RCC_CR_RTCPRE; tmpreg |= (RCC_RTCCLKSource & RCC_CR_RTCPRE); RCC->CR = tmpreg; } RCC->CSR &= ~RCC_CSR_RTCSEL; RCC-...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* We have to know that the key will fit, but the last entry on the page is an overflow pair, so we need to shift things. */
static void squeeze_key(u_int16_t *sp, const DBT *key, const DBT *val)
/* We have to know that the key will fit, but the last entry on the page is an overflow pair, so we need to shift things. */ static void squeeze_key(u_int16_t *sp, const DBT *key, const DBT *val)
{ register char *p; u_int16_t free_space, n, off, pageno; p = (char *)sp; n = sp[0]; free_space = FREESPACE(sp); off = OFFSET(sp); pageno = sp[n - 1]; off -= key->size; sp[n - 1] = off; memmove(p + off, key->data, key->size); off -= val->size; sp[n] = off; memmove(p + off, val->data, val->size); sp[0] = n...
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* USBH_LL_GetToggle Return the current toggle of a pipe. */
uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
/* USBH_LL_GetToggle Return the current toggle of a pipe. */ uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
{ uint8_t toggle = 0; return toggle; }
labapart/polymcu
C++
null
201
/* Two very simple procedures, poll_wait() and poll_freewait() make all the work. poll_wait() is an inline-function defined in <linux/poll.h>, as all select/poll functions have to call it to add an entry to the poll table. */
static void __pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
/* Two very simple procedures, poll_wait() and poll_freewait() make all the work. poll_wait() is an inline-function defined in <linux/poll.h>, as all select/poll functions have to call it to add an entry to the poll table. */ static void __pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
{ struct poll_wqueues *pwq = container_of(p, struct poll_wqueues, pt); struct poll_table_entry *entry = poll_get_entry(pwq); if (!entry) return; get_file(filp); entry->filp = filp; entry->wait_address = wait_address; entry->key = p->key; init_waitqueue_func_entry(&entry->wait, pollwake); entry->wait.private ...
robutest/uclinux
C++
GPL-2.0
60
/* Return the KS8851 register number for the corresponding MII PHY register if possible. Return zero if the MII register has no direct mapping to the KS8851 register set. */
static int ks_phy_reg(int reg)
/* Return the KS8851 register number for the corresponding MII PHY register if possible. Return zero if the MII register has no direct mapping to the KS8851 register set. */ static int ks_phy_reg(int reg)
{ switch (reg) { case MII_BMCR: return KS_P1MBCR; case MII_BMSR: return KS_P1MBSR; case MII_PHYSID1: return KS_PHY1ILR; case MII_PHYSID2: return KS_PHY1IHR; case MII_ADVERTISE: return KS_P1ANAR; case MII_LPA: return KS_P1ANLPR; } return 0x0; }
robutest/uclinux
C++
GPL-2.0
60
/* Delete a Mutex that was created by osMutexCreate. */
osStatus osMutexDelete(osMutexId mutex_id)
/* Delete a Mutex that was created by osMutexCreate. */ osStatus osMutexDelete(osMutexId mutex_id)
{ return osErrorISR; } return __svcMutexDelete(mutex_id); }
labapart/polymcu
C++
null
201
/* access potentially dodgy memory through a potentially dodgy pointer */
static int gdbstub_read_dword(const void *addr, uint32_t *_res)
/* access potentially dodgy memory through a potentially dodgy pointer */ static int gdbstub_read_dword(const void *addr, uint32_t *_res)
{ unsigned long brr; uint32_t res; if (!gdbstub_addr_map(addr)) return 0; asm volatile(" movgs gr0,brr \n" " ld%I2 %M2,%0 \n" " movsg brr,%1 \n" : "=r"(res), "=r"(brr) : "m"(*(uint32_t *) addr)); *_res = res; gdbstub_addr_unmap(); return likely(!brr); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Close down an X.25 channel. This means flushing out any pending queues, and then restoring the TTY line discipline to what it was before it got hooked to X.25 (which usually is TTY again). */
static void x25_asy_close_tty(struct tty_struct *tty)
/* Close down an X.25 channel. This means flushing out any pending queues, and then restoring the TTY line discipline to what it was before it got hooked to X.25 (which usually is TTY again). */ static void x25_asy_close_tty(struct tty_struct *tty)
{ struct x25_asy *sl = tty->disc_data; if (!sl || sl->magic != X25_ASY_MAGIC) return; rtnl_lock(); if (sl->dev->flags & IFF_UP) dev_close(sl->dev); rtnl_unlock(); tty->disc_data = NULL; sl->tty = NULL; x25_asy_free(sl); }
robutest/uclinux
C++
GPL-2.0
60
/* Enable/Disable I2C 14-bit timeout counter of the specified I2C port. The */
void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulEnable, unsigned long ulDiv4)
/* Enable/Disable I2C 14-bit timeout counter of the specified I2C port. The */ void I2CTimeoutCounterSet(unsigned long ulBase, unsigned long ulEnable, unsigned long ulDiv4)
{ xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE) || (ulBase == I2C2_BASE) || (ulBase == I2C3_BASE) || (ulBase == I2C4_BASE)); xASSERT((ulEnable == I2C_TIMEOUT_EN) || (ulEnable == I2C_TIMEOUT_DIS)); xASSERT((ulDiv4 == I2C_TIMEOUT_DIV4) || (ulDiv4 == I2C_TIMEOUT_DIV_NO)); x...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104