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
/* After a DMA transfer, make sure the controller is stopped */
static int pmac_ide_dma_end(ide_drive_t *drive)
/* After a DMA transfer, make sure the controller is stopped */ static int pmac_ide_dma_end(ide_drive_t *drive)
{ ide_hwif_t *hwif = drive->hwif; pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; u32 dstat; dstat = readl(&dma->status); writel(((RUN|WAKE|DEAD) << 16), &dma->control); return (dstat & (RUN|DEAD)) != RUN; }
robutest/uclinux
C++
GPL-2.0
60
/* Maximum duration is the maximum time of an over threshold signal detection to be recognized as a tap event. The default value of these bits is 00b which corresponds to 4*ODR_XL time. If the SHOCK bits are set to a different value, 1LSB corresponds to 8*ODR_XL time.. */
int32_t lsm6dso_tap_shock_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Maximum duration is the maximum time of an over threshold signal detection to be recognized as a tap event. The default value of these bits is 00b which corresponds to 4*ODR_XL time. If the SHOCK bits are set to a different value, 1LSB corresponds to 8*ODR_XL time.. */ int32_t lsm6dso_tap_shock_get(stmdev_ctx_t *ct...
{ lsm6dso_int_dur2_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_INT_DUR2, (uint8_t *)&reg, 1); *val = reg.shock; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Ask the DPM to change the Source Caps. Returns true if source caps have been updated, else false. */
bool policy_change_src_caps(const struct device *dev)
/* Ask the DPM to change the Source Caps. Returns true if source caps have been updated, else false. */ bool policy_change_src_caps(const struct device *dev)
{ struct usbc_port_data *data = dev->data; if (data->policy_change_src_caps == NULL) { return false; } return data->policy_change_src_caps(dev); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Task function for blinking the LED as a fixed timer interval. */
void LedBlinkTask(void)
/* Task function for blinking the LED as a fixed timer interval. */ void LedBlinkTask(void)
{ static blt_bool ledOn = BLT_FALSE; static blt_int32u nextBlinkEvent = 0; if (TimerGet() >= nextBlinkEvent) { if (ledOn == BLT_FALSE) { ledOn = BLT_TRUE; LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_5); } else { ledOn = BLT_FALSE; LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN...
feaser/openblt
C++
GNU General Public License v3.0
601
/* This function will install a interrupt service routine to a interrupt. */
void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
/* This function will install a interrupt service routine to a interrupt. */ void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
{ if(vector < MAX_HANDLERS) { if (old_handler != RT_NULL) *old_handler = isr_table[vector]; if (new_handler != RT_NULL) isr_table[vector] = new_handler; } }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns unbound table for the caller to free. */
static struct dm_table* __unbind(struct mapped_device *md)
/* Returns unbound table for the caller to free. */ static struct dm_table* __unbind(struct mapped_device *md)
{ struct dm_table *map = md->map; unsigned long flags; if (!map) return NULL; dm_table_event_callback(map, NULL, NULL); write_lock_irqsave(&md->map_lock, flags); md->map = NULL; write_unlock_irqrestore(&md->map_lock, flags); return map; }
robutest/uclinux
C++
GPL-2.0
60
/* Wake up duration event. 1LSb = 1 / ODR. */
int32_t lsm6dso_xl_usr_offset_on_wkup_set(stmdev_ctx_t *ctx, uint8_t val)
/* Wake up duration event. 1LSb = 1 / ODR. */ int32_t lsm6dso_xl_usr_offset_on_wkup_set(stmdev_ctx_t *ctx, uint8_t val)
{ lsm6dso_wake_up_ths_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)&reg, 1); if (ret == 0) { reg.usr_off_on_wu = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)&reg, 1); } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Platform Bds init. Include the platform firmware vendor, revision and so crc check. */
VOID EFIAPI PlatformBootManagerBeforeConsole(VOID)
/* Platform Bds init. Include the platform firmware vendor, revision and so crc check. */ VOID EFIAPI PlatformBootManagerBeforeConsole(VOID)
{ UINTN Index; SetupVariableInit (); EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); Index = 0; while (gPlatformConsole[Index].DevicePath != NULL) { if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) { EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DeviceP...
tianocore/edk2
C++
Other
4,240
/* Set the telecom divisor on the MCP interface. The resulting sample rate is SIBCLOCK/div. */
void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div)
/* Set the telecom divisor on the MCP interface. The resulting sample rate is SIBCLOCK/div. */ void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div)
{ spin_lock_irq(&mcp->lock); mcp->ops->set_telecom_divisor(mcp, div); spin_unlock_irq(&mcp->lock); }
robutest/uclinux
C++
GPL-2.0
60
/* Interrupts not specified by the mask will not be affected */
void XAxiVdma_IntrEnable(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction)
/* Interrupts not specified by the mask will not be affected */ void XAxiVdma_IntrEnable(XAxiVdma *InstancePtr, u32 IntrType, u16 Direction)
{ XAxiVdma_Channel *Channel; Channel = XAxiVdma_GetChannel(InstancePtr, Direction); if (Channel->IsValid) { XAxiVdma_ChannelEnableIntr(Channel, IntrType); } return; }
ua1arn/hftrx
C++
null
69
/* The functions for inserting/removing us as a module. */
static int __init spaceball_init(void)
/* The functions for inserting/removing us as a module. */ static int __init spaceball_init(void)
{ return serio_register_driver(&spaceball_drv); }
robutest/uclinux
C++
GPL-2.0
60
/* Read available data from the read FIFO, as 32-bit data items. */
uint32_t EPINonBlockingReadGet32(uint32_t ui32Base, uint32_t ui32Count, uint32_t *pui32Buf)
/* Read available data from the read FIFO, as 32-bit data items. */ uint32_t EPINonBlockingReadGet32(uint32_t ui32Base, uint32_t ui32Count, uint32_t *pui32Buf)
{ uint32_t ui32CountRead = 0; ASSERT(ui32Base == EPI0_BASE); ASSERT(ui32Count < 4096); ASSERT(pui32Buf); while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--) { *pui32Buf = HWREG(ui32Base + EPI_O_READFIFO0); pui32Buf++; ui32CountRead++; } return(ui32CountRead); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sets the UART hardware flow control mode to be used. */
void UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode)
/* Sets the UART hardware flow control mode to be used. */ void UARTFlowControlSet(unsigned long ulBase, unsigned long ulMode)
{ xASSERT((ulBase == UART0_BASE) ||(ulBase == UART1_BASE)); xASSERT((ulMode & ~(UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)) == 0); xHWREG(ulBase + UART_IER) = ((xHWREG(ulBase + UART_IER) & ~(UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)) | ulM...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* MSS_SPI_transfer_frame() See "mss_spi.h" for details of how to use this function. */
uint32_t MSS_SPI_transfer_frame(mss_spi_instance_t *this_spi, uint32_t tx_bits)
/* MSS_SPI_transfer_frame() See "mss_spi.h" for details of how to use this function. */ uint32_t MSS_SPI_transfer_frame(mss_spi_instance_t *this_spi, uint32_t tx_bits)
{ volatile uint32_t dummy; ASSERT( (this_spi == &g_mss_spi0) || (this_spi == &g_mss_spi1) ); ASSERT( this_spi->hw_reg_bit->CTRL_MASTER == MSS_SPI_MODE_MASTER ); while ( this_spi->hw_reg_bit->STATUS_RX_RDY == 1U ) { dummy = this_spi->hw_reg->RX_DATA; dummy = dummy; } this_spi-...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Get current time and monotonic count first. Then initialize a random seed based on some basic mathematics operation on the hour, day, minute, second, nanosecond and year of the current time and the monotonic count value. */
UINT32 EFIAPI NetRandomInitSeed(VOID)
/* Get current time and monotonic count first. Then initialize a random seed based on some basic mathematics operation on the hour, day, minute, second, nanosecond and year of the current time and the monotonic count value. */ UINT32 EFIAPI NetRandomInitSeed(VOID)
{ EFI_TIME Time; UINT32 Seed; UINT64 MonotonicCount; gRT->GetTime (&Time, NULL); Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); Seed ^= Time.Nanosecond; Seed ^= Time.Year << 7; gBS->GetNextMonotonicCount (&MonotonicCount); Seed += (UINT32)MonotonicCount; return S...
tianocore/edk2
C++
Other
4,240
/* Set the GO_BUSY bit to trigger a SPI data transfer. */
void SPIBitGoBusySet(unsigned long ulBase)
/* Set the GO_BUSY bit to trigger a SPI data transfer. */ void SPIBitGoBusySet(unsigned long ulBase)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_GO_BUSY; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* This function is used to stop calculating & return elapsed time. */
u32 tls_watchdog_stop_cal_elapsed_time(void)
/* This function is used to stop calculating & return elapsed time. */ u32 tls_watchdog_stop_cal_elapsed_time(void)
{ #define RT_TIME_BASE (40) u32 val = 0; switch (wdg_jumpclear_flag) { case 1: { val = (tls_reg_read32(HR_WDG_LOAD_VALUE) - tls_reg_read32(HR_WDG_CUR_VALUE))/RT_TIME_BASE; __tls_watchdog_deinit(); __tls_watchdog_init(wdg_value_us); wdg_jumpclear_flag = 0; } break; case 2: { val = (tls_reg_...
Nicholas3388/LuaNode
C++
Other
1,055
/* Function for updating LED to be softly blinking. */
static void softblink_led_update(void)
/* Function for updating LED to be softly blinking. */ static void softblink_led_update(void)
{ uint32_t err_code; if (m_update_softblink == false) { return; } m_update_softblink = false; err_code = led_softblink_stop(); APP_ERROR_CHECK(err_code); err_code = led_softblink_start(m_active_led_mask); APP_ERROR_CHECK(err_code); }
remotemcu/remcu-chip-sdks
C++
null
436
/* The TSC is an Intel thing called the Time Stamp Counter. The Host tells us what speed it runs at, or 0 if it's unusable as a reliable clock source. This matches what we want here: if we return 0 from this function, the x86 TSC clock will give up and not register itself. */
static unsigned long lguest_tsc_khz(void)
/* The TSC is an Intel thing called the Time Stamp Counter. The Host tells us what speed it runs at, or 0 if it's unusable as a reliable clock source. This matches what we want here: if we return 0 from this function, the x86 TSC clock will give up and not register itself. */ static unsigned long lguest_tsc_khz(void)
{ return lguest_data.tsc_khz; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function returns the size of the EEPROM in bytes. */
uint32_t EEPROMSizeGet(void)
/* This function returns the size of the EEPROM in bytes. */ uint32_t EEPROMSizeGet(void)
{ return (SIZE_FROM_EESIZE(HWREG(EEPROM_EESIZE))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* These routines allow writing an arbitrary marker with parameters. The only intended use is to emit COM or APPn markers after calling write_file_header and before calling write_frame_header. Other uses are not guaranteed to produce desirable results. Counting the parameter bytes properly is the caller's responsibilit...
write_marker_header(j_compress_ptr cinfo, int marker, unsigned int datalen)
/* These routines allow writing an arbitrary marker with parameters. The only intended use is to emit COM or APPn markers after calling write_file_header and before calling write_frame_header. Other uses are not guaranteed to produce desirable results. Counting the parameter bytes properly is the caller's responsibilit...
{ if (datalen > (unsigned int)65533) ERREXIT(cinfo, JERR_BAD_LENGTH); emit_marker(cinfo, (JPEG_MARKER)marker); emit_2bytes(cinfo, (int)(datalen + 2)); }
nanoframework/nf-interpreter
C++
MIT License
293
/* HCD_HC_Init This function prepare a HC and start a transfer. */
uint32_t HCD_HC_Init(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
/* HCD_HC_Init This function prepare a HC and start a transfer. */ uint32_t HCD_HC_Init(USB_OTG_CORE_HANDLE *pdev, uint8_t hc_num)
{ return USB_OTG_HC_Init(pdev, hc_num); }
MaJerle/stm32f429
C++
null
2,036
/* This API update the length for read and write. Static Function Declarations */
static void update_len(uint8_t *len, uint8_t feature, uint8_t enable)
/* This API update the length for read and write. Static Function Declarations */ static void update_len(uint8_t *len, uint8_t feature, uint8_t enable)
{ uint8_t length = BMA423_FEATURE_SIZE; if ((feature == BMA423_ANY_MOTION) || (feature == BMA423_NO_MOTION)) { length = BMA423_ANYMOTION_EN_LEN; if (enable == BMA4_DISABLE) { length = length + 2; } } *len = length; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* This function removes data from the start of a buffer, returning the memory to the headroom. A pointer to the next data in the buffer is returned. Once the data has been pulled future pushes will overwrite the old data. */
unsigned char* skb_pull(struct sk_buff *skb, unsigned int len)
/* This function removes data from the start of a buffer, returning the memory to the headroom. A pointer to the next data in the buffer is returned. Once the data has been pulled future pushes will overwrite the old data. */ unsigned char* skb_pull(struct sk_buff *skb, unsigned int len)
{ return unlikely(len > skb->len) ? NULL : __skb_pull(skb, len); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function use to set receive timeout count. */
void SCUART_SetTimeoutCnt(UINT sc, UINT u32TOC)
/* This function use to set receive timeout count. */ void SCUART_SetTimeoutCnt(UINT sc, UINT u32TOC)
{ if (sc == 0) outpw(REG_SC0_RXTOUT, u32TOC); else outpw(REG_SC1_RXTOUT, u32TOC); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read the state of the voltage comparator. This function extracts the comparator state from the status register. */
bool am_hal_vcomp_read(void)
/* Read the state of the voltage comparator. This function extracts the comparator state from the status register. */ bool am_hal_vcomp_read(void)
{ return (AM_BFR(VCOMP, STAT, CMPOUT) == 1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* atl1c_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */
u32 atl1c_hash_mc_addr(struct atl1c_hw *hw, u8 *mc_addr)
/* atl1c_hash_mc_addr purpose set hash value for a multicast address hash calcu processing : */ u32 atl1c_hash_mc_addr(struct atl1c_hw *hw, u8 *mc_addr)
{ u32 crc32; u32 value = 0; int i; crc32 = ether_crc_le(6, mc_addr); for (i = 0; i < 32; i++) value |= (((crc32 >> i) & 1) << (31 - i)); return value; }
robutest/uclinux
C++
GPL-2.0
60
/* Core UART functions to implement for a port */
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags)
/* Core UART functions to implement for a port */ uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags)
{ uintptr_t ret = 0; if ((poll_flags & MP_STREAM_POLL_RD) && stdin_ringbuf.iget != stdin_ringbuf.iput) { ret |= MP_STREAM_POLL_RD; } return ret; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function shadows the content of variable MTRRs into an internal array: VariableMtrr. */
UINT32 EFIAPI MtrrGetMemoryAttributeInVariableMtrr(IN UINT64 MtrrValidBitsMask, IN UINT64 MtrrValidAddressMask, OUT VARIABLE_MTRR *VariableMtrr)
/* This function shadows the content of variable MTRRs into an internal array: VariableMtrr. */ UINT32 EFIAPI MtrrGetMemoryAttributeInVariableMtrr(IN UINT64 MtrrValidBitsMask, IN UINT64 MtrrValidAddressMask, OUT VARIABLE_MTRR *VariableMtrr)
{ MTRR_VARIABLE_SETTINGS VariableSettings; if (!IsMtrrSupported ()) { return 0; } MtrrGetVariableMtrrWorker ( NULL, GetVariableMtrrCountWorker (), &VariableSettings ); return MtrrGetMemoryAttributeInVariableMtrrWorker ( &VariableSettings, GetFirmwareVariableMtrrCount...
tianocore/edk2
C++
Other
4,240
/* tls_get_cipher_suite - Get TLS cipher suite @suite: Cipher suite identifier Returns: Pointer to the cipher data or NULL if not found */
const struct tls_cipher_suite* tls_get_cipher_suite(u16 suite)
/* tls_get_cipher_suite - Get TLS cipher suite @suite: Cipher suite identifier Returns: Pointer to the cipher data or NULL if not found */ const struct tls_cipher_suite* tls_get_cipher_suite(u16 suite)
{ size_t i; for (i = 0; i < NUM_TLS_CIPHER_SUITES; i++) if (tls_cipher_suites[i].suite == suite) return &tls_cipher_suites[i]; return NULL; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Shut down omap_device @od by calling all .deactivate_func() entries in the omap_device's pm_lats table and then shutting down all of the underlying omap_hwmods. Used when a device is being "removed" or a device driver is being unloaded. Returns -EINVAL if the omap_device is not currently enabled or idle, or passes a...
int omap_device_shutdown(struct platform_device *pdev)
/* Shut down omap_device @od by calling all .deactivate_func() entries in the omap_device's pm_lats table and then shutting down all of the underlying omap_hwmods. Used when a device is being "removed" or a device driver is being unloaded. Returns -EINVAL if the omap_device is not currently enabled or idle, or passes a...
{ int ret, i; struct omap_device *od; struct omap_hwmod *oh; od = _find_by_pdev(pdev); if (od->_state != OMAP_DEVICE_STATE_ENABLED && od->_state != OMAP_DEVICE_STATE_IDLE) { WARN(1, "omap_device: %s.%d: omap_device_shutdown() called " "from invalid state\n", od->pdev.name, od->pdev.id); return -EIN...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Maximum value of absolute values of a floating-point vector. */
void arm_absmax_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult, uint32_t *pIndex)
/* Maximum value of absolute values of a floating-point vector. */ void arm_absmax_f64(const float64_t *pSrc, uint32_t blockSize, float64_t *pResult, uint32_t *pIndex)
{ float64_t maxVal, out; uint32_t blkCnt, outIndex; outIndex = 0U; out = fabs(*pSrc++); blkCnt = (blockSize - 1U); while (blkCnt > 0U) { maxVal = fabs(*pSrc++); if (out < maxVal) { out = maxVal; outIndex = blockSize - blkCnt; } blkCnt--; } *pResult = out; ...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Returns: a hash value corresponding to the key */
guint g_str_hash(gconstpointer v)
/* Returns: a hash value corresponding to the key */ guint g_str_hash(gconstpointer v)
{ const signed char *p; guint32 h = 5381; for (p = v; *p != '\0'; p++) h = (h << 5) + h + *p; return h; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2. */
gint g_ascii_strncasecmp(const gchar *s1, const gchar *s2, gsize n)
/* Returns: 0 if the strings match, a negative value if @s1 < @s2, or a positive value if @s1 > @s2. */ gint g_ascii_strncasecmp(const gchar *s1, const gchar *s2, gsize n)
{ gint c1, c2; g_return_val_if_fail (s1 != NULL, 0); g_return_val_if_fail (s2 != NULL, 0); while (n && *s1 && *s2) { n -= 1; c1 = (gint)(guchar) TOLOWER (*s1); c2 = (gint)(guchar) TOLOWER (*s2); if (c1 != c2) return (c1 - c2); s1++; s2++; } if (n) return (((gi...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Find the codebook with the lowest distortion from an image */
static int index_mb(uint8_t cluster[], uint8_t cb[], int numCB, int *outIndex, int dim)
/* Find the codebook with the lowest distortion from an image */ static int index_mb(uint8_t cluster[], uint8_t cb[], int numCB, int *outIndex, int dim)
{ int i, lDiff = INT_MAX, pick=0; for (i=0; i<numCB; i++) { int diff = squared_diff_macroblock(cluster, cb + i*dim*dim*3, dim); if (diff < lDiff) { lDiff = diff; pick = i; } } *outIndex = pick; return lDiff; }
DC-SWAT/DreamShell
C++
null
404
/* Load the Sub Second Increment value in to Sub Second increment register */
void synopGMAC_TS_subsecond_init(synopGMACdevice *gmacdev, u32 sub_sec_inc_value)
/* Load the Sub Second Increment value in to Sub Second increment register */ void synopGMAC_TS_subsecond_init(synopGMACdevice *gmacdev, u32 sub_sec_inc_value)
{ synopGMACWriteReg(gmacdev->MacBase, GmacTSSubSecIncr, (sub_sec_inc_value & GmacSSINCMsk)); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* @dev: GPIO peripheral device @offset: the GPIO pin offset from the GPIO controller */
int pinctrl_gpio_free(struct udevice *dev, unsigned offset)
/* @dev: GPIO peripheral device @offset: the GPIO pin offset from the GPIO controller */ int pinctrl_gpio_free(struct udevice *dev, unsigned offset)
{ const struct pinctrl_ops *ops; struct udevice *pctldev; unsigned int pin_selector; int ret; ret = pinctrl_gpio_get_pinctrl_and_offset(dev, offset, &pctldev, &pin_selector); if (ret) return ret; ops = pinctrl_get_ops(pctldev); if (!ops || !ops->gpio_disable_free) return -ENOTSUPP; return ops->gpio...
4ms/stm32mp1-baremetal
C++
Other
137
/* Enables or disables the TIM Capture Compare Channel x. */
void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
/* Enables or disables the TIM Capture Compare Channel x. */ void TIM_CCxCmd(TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
{ uint16_t tmp = 0; assert_param(IS_TIM_LIST4_PERIPH(TIMx)); assert_param(IS_TIM_CCX(TIM_CCx)); tmp = CCER_CCE_SET << TIM_Channel; TIMx->CCER &= (uint16_t)~ tmp; TIMx->CCER |= (uint16_t)(TIM_CCx << TIM_Channel); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize a CAN_Config_T structure with the initial value. */
void CAN_ConfigStructInit(CAN_Config_T *canConfig)
/* Initialize a CAN_Config_T structure with the initial value. */ void CAN_ConfigStructInit(CAN_Config_T *canConfig)
{ canConfig->timeTrigComMode = DISABLE; canConfig->autoBusOffManage = DISABLE; canConfig->autoWakeUpMode = DISABLE; canConfig->nonAutoRetran = DISABLE; canConfig->rxFIFOLockMode = DISABLE; canConfig->txFIFOPriority = DISABLE; canConfig->mode = CAN_MODE_NORMAL; canCo...
pikasTech/PikaPython
C++
MIT License
1,403
/* This service lets the caller enable or disable an AP from this point onward. This service may only be called from the BSP. */
EFI_STATUS EFIAPI MpInitLibEnableDisableAP(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
/* This service lets the caller enable or disable an AP from this point onward. This service may only be called from the BSP. */ EFI_STATUS EFIAPI MpInitLibEnableDisableAP(IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
{ EFI_STATUS Status; BOOLEAN TempStopCheckState; TempStopCheckState = FALSE; if (!mStopCheckAllApsStatus) { mStopCheckAllApsStatus = TRUE; TempStopCheckState = TRUE; } Status = EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag); if (TempStopCheckState) { mStopCheckAllApsSta...
tianocore/edk2
C++
Other
4,240
/* Retrieves the current system clock frequency, computed from the reference clock. */
static uint32_t get_osc_frequency(void)
/* Retrieves the current system clock frequency, computed from the reference clock. */ static uint32_t get_osc_frequency(void)
{ tc_clear_status(&tc_comp, TC_STATUS_CHANNEL_0_MATCH); tc_start_counter(&tc_calib); tc_start_counter(&tc_comp); while (!(tc_get_status(&tc_comp) & TC_STATUS_CHANNEL_0_MATCH)) { } uint64_t tmp = tc_get_capture_value(&tc_calib, TC_COMPARE_CAPTURE_CHANNEL_0); return ((tmp * REFERENCE_CLOCK_HZ) >> CALIBRATION_RESOL...
memfault/zero-to-main
C++
null
200
/* sym2_io_error_detected() - called when PCI error is detected @pdev: pointer to PCI device @state: current state of the PCI slot */
static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, enum pci_channel_state state)
/* sym2_io_error_detected() - called when PCI error is detected @pdev: pointer to PCI device @state: current state of the PCI slot */ static pci_ers_result_t sym2_io_error_detected(struct pci_dev *pdev, enum pci_channel_state state)
{ if (state == pci_channel_io_perm_failure) { sym2_remove(pdev); return PCI_ERS_RESULT_DISCONNECT; } disable_irq(pdev->irq); pci_disable_device(pdev); return PCI_ERS_RESULT_CAN_RECOVER; }
robutest/uclinux
C++
GPL-2.0
60
/* Count the number of inline directory entries in di_bh and compare them against the number of entries we can hold in an inline dx root block. */
static int ocfs2_new_dx_should_be_inline(struct inode *dir, struct buffer_head *di_bh)
/* Count the number of inline directory entries in di_bh and compare them against the number of entries we can hold in an inline dx root block. */ static int ocfs2_new_dx_should_be_inline(struct inode *dir, struct buffer_head *di_bh)
{ int dirent_count = 0; char *de_buf, *limit; struct ocfs2_dir_entry *de; struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; de_buf = di->id2.i_data.id_data; limit = de_buf + i_size_read(dir); while (de_buf < limit) { de = (struct ocfs2_dir_entry *)de_buf; if (de->name_len && de->inode) diren...
robutest/uclinux
C++
GPL-2.0
60
/* DMA Channel Enable Memory Circular Mode. After the number of bytes/words to be transferred has been completed, the original transfer block size, memory and peripheral base addresses are reloaded and the process repeats. */
void dma_enable_circular_mode(uint32_t dma, uint8_t channel)
/* DMA Channel Enable Memory Circular Mode. After the number of bytes/words to be transferred has been completed, the original transfer block size, memory and peripheral base addresses are reloaded and the process repeats. */ void dma_enable_circular_mode(uint32_t dma, uint8_t channel)
{ DMA_CCR(dma, channel) |= DMA_CCR_CIRC; DMA_CCR(dma, channel) &= ~DMA_CCR_MEM2MEM; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Copy expanded memory page (4kB) into main memory */
static int xpram_page_in(unsigned long page_addr, unsigned int xpage_index)
/* Copy expanded memory page (4kB) into main memory */ static int xpram_page_in(unsigned long page_addr, unsigned int xpage_index)
{ int cc = 2; asm volatile( " .insn rre,0xb22e0000,%1,%2\n" "0: ipm %0\n" " srl %0,28\n" "1:\n" EX_TABLE(0b,1b) : "+d" (cc) : "a" (__pa(page_addr)), "d" (xpage_index) : "cc"); if (cc == 3) return -ENXIO; if (cc == 2) return -ENXIO; if (cc == 1) return -EIO; return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns zero if the physical eraseblock is good, %-EINVAL if it is bad and a negative error code if an error occurred. */
static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
/* This function returns zero if the physical eraseblock is good, %-EINVAL if it is bad and a negative error code if an error occurred. */ static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
{ int err; if (!ubi_dbg_chk_io(ubi)) return 0; err = ubi_io_is_bad(ubi, pnum); if (!err) return err; ubi_err(ubi, "self-check failed for PEB %d", pnum); dump_stack(); return err > 0 ? -EINVAL : err; }
4ms/stm32mp1-baremetal
C++
Other
137
/* The following functions allow us to read data using a swap map in a file-alike way */
static void release_swap_reader(struct swap_map_handle *handle)
/* The following functions allow us to read data using a swap map in a file-alike way */ static void release_swap_reader(struct swap_map_handle *handle)
{ if (handle->cur) free_page((unsigned long)handle->cur); handle->cur = NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) in order to make sure any currently executing ldisc work is also flushed. */
static int tty_ldisc_halt(struct tty_struct *tty)
/* You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex) in order to make sure any currently executing ldisc work is also flushed. */ static int tty_ldisc_halt(struct tty_struct *tty)
{ clear_bit(TTY_LDISC, &tty->flags); return cancel_delayed_work_sync(&tty->buf.work); }
robutest/uclinux
C++
GPL-2.0
60
/* Opens a file and copies its content to a buffer. */
uint32_t Storage_CheckBitmapFile(const char *BmpName, uint32_t *FileLen)
/* Opens a file and copies its content to a buffer. */ uint32_t Storage_CheckBitmapFile(const char *BmpName, uint32_t *FileLen)
{ if(f_mount(&fs, (TCHAR const*)"",0)) { return 1; } if(f_open (&MyFile, (TCHAR const*)BmpName, FA_READ)) { return 2; } f_read (&MyFile, aBuffer, 6, (UINT *)&BytesRead); if (Buffercmp((uint8_t *)SlidesCheck, (uint8_t *) aBuffer, 2) != 0) { return 3; } return 0; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnToIntn(IN UINTN Operand, OUT INTN *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUintnToIntn(IN UINTN Operand, OUT INTN *Result)
{ RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (Operand <= MAX_INTN) { *Result = (INTN)Operand; Status = RETURN_SUCCESS; } else { *Result = INTN_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; }
tianocore/edk2
C++
Other
4,240
/* SmartScroll / CruiseControl for some newer Logitech mice Defaults to enabled if we do nothing to it. Of course I put this in because I want it disabled :P 1 - enabled (if previously disabled, also default) 0 - disabled */
static void ps2pp_set_smartscroll(struct psmouse *psmouse, bool smartscroll)
/* SmartScroll / CruiseControl for some newer Logitech mice Defaults to enabled if we do nothing to it. Of course I put this in because I want it disabled :P 1 - enabled (if previously disabled, also default) 0 - disabled */ static void ps2pp_set_smartscroll(struct psmouse *psmouse, bool smartscroll)
{ struct ps2dev *ps2dev = &psmouse->ps2dev; unsigned char param[4]; ps2pp_cmd(psmouse, param, 0x32); param[0] = 0; ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES); param[0] = smartscroll; ps2_command(ps2dev, param, P...
robutest/uclinux
C++
GPL-2.0
60
/* Return the actual size of the MC private DRAM block. */
unsigned long mc_get_dram_block_size(void)
/* Return the actual size of the MC private DRAM block. */ unsigned long mc_get_dram_block_size(void)
{ unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE; char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR); if (dram_block_size_env_var) { dram_block_size = simple_strtoul(dram_block_size_env_var, NULL, 16); if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) { printf(...
4ms/stm32mp1-baremetal
C++
Other
137
/* Read a byte from a SHELL_FILE_HANDLE, buffered with a */
STATIC EFI_STATUS FileBufferReadByte(IN SHELL_FILE_HANDLE FileHandle, IN OUT FILE_BUFFER *FileBuffer, OUT UINTN *BytesRead, OUT UINT8 *Byte)
/* Read a byte from a SHELL_FILE_HANDLE, buffered with a */ STATIC EFI_STATUS FileBufferReadByte(IN SHELL_FILE_HANDLE FileHandle, IN OUT FILE_BUFFER *FileBuffer, OUT UINTN *BytesRead, OUT UINT8 *Byte)
{ UINTN ReadSize; EFI_STATUS Status; if (FileBuffer->Left == 0) { ReadSize = FileBuffer->Allocated; Status = gEfiShellProtocol->ReadFile ( FileHandle, &ReadSize, FileBuffer->Data ...
tianocore/edk2
C++
Other
4,240
/* Disable the ETH DMA Tx Descriptor Transmit interrupt. */
void ETH_DisableDMATxDescTransmitInterrupt(ETH_DMADescConfig_T *DMATxDesc)
/* Disable the ETH DMA Tx Descriptor Transmit interrupt. */ void ETH_DisableDMATxDescTransmitInterrupt(ETH_DMADescConfig_T *DMATxDesc)
{ DMATxDesc->Status &= (~(uint32_t)ETH_DMATXDESC_INTC); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function posts more buffers to the HBQ. This function is called with no lock held. The function returns the number of HBQ entries successfully allocated. */
int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno)
/* This function posts more buffers to the HBQ. This function is called with no lock held. The function returns the number of HBQ entries successfully allocated. */ int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno)
{ if (phba->sli_rev == LPFC_SLI_REV4) return 0; else return lpfc_sli_hbqbuf_fill_hbqs(phba, qno, lpfc_hbq_defs[qno]->add_count); }
robutest/uclinux
C++
GPL-2.0
60
/* Get rid of all migration entries and replace them by references to the indicated page. */
static void remove_migration_ptes(struct page *old, struct page *new)
/* Get rid of all migration entries and replace them by references to the indicated page. */ static void remove_migration_ptes(struct page *old, struct page *new)
{ rmap_walk(new, remove_migration_pte, old); }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */
EFI_STATUS EFIAPI TlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen)
/* This function returns the TLS/SSL session ID currently used by the specified TLS connection. */ EFI_STATUS EFIAPI TlsGetSessionId(IN VOID *Tls, IN OUT UINT8 *SessionId, IN OUT UINT16 *SessionIdLen)
{ TLS_CONNECTION *TlsConn; SSL_SESSION *Session; CONST UINT8 *SslSessionId; TlsConn = (TLS_CONNECTION *)Tls; Session = NULL; if ((TlsConn == NULL) || (TlsConn->Ssl == NULL) || (SessionId == NULL) || (SessionIdLen == NULL)) { return EFI_INVALID_PARAMETER; } Session = SSL_get_session (TlsConn...
tianocore/edk2
C++
Other
4,240
/* Returns: a pointer to the new or existing copy of @string within the #GStringChunk */
gchar* g_string_chunk_insert_const(GStringChunk *chunk, const gchar *string)
/* Returns: a pointer to the new or existing copy of @string within the #GStringChunk */ gchar* g_string_chunk_insert_const(GStringChunk *chunk, const gchar *string)
{ char* lookup; g_return_val_if_fail (chunk != NULL, NULL); if (!chunk->const_table) chunk->const_table = g_hash_table_new (g_str_hash, g_str_equal); lookup = (char*) g_hash_table_lookup (chunk->const_table, (gchar *)string); if (!lookup) { lookup = g_string_chunk_insert (chunk, string); g...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Execute "resume" callbacks for all devices and complete the PM transition of the system. */
void dpm_resume_end(pm_message_t state)
/* Execute "resume" callbacks for all devices and complete the PM transition of the system. */ void dpm_resume_end(pm_message_t state)
{ might_sleep(); dpm_resume(state); dpm_complete(state); }
robutest/uclinux
C++
GPL-2.0
60
/* Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted: */
uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection)
/* Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted: */ uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection)
{ uint32_t compout = 0x0; assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); if ((*(__IO uint32_t *) (COMP_BASE + COMP_Selection) & (COMP_CSR_COMPxOUT)) != 0) { compout = COMP_OutputLevel_High; } else { compout = COMP_OutputLevel_Low; } return (uint32_t)(compout); }
ajhc/demo-cortex-m3
C++
null
38
/* Function: void msgqueue_initialise(MsgQueue_t *msgq) Purpose : initialise a message queue Params : msgq - queue to initialise */
void msgqueue_initialise(MsgQueue_t *msgq)
/* Function: void msgqueue_initialise(MsgQueue_t *msgq) Purpose : initialise a message queue Params : msgq - queue to initialise */ void msgqueue_initialise(MsgQueue_t *msgq)
{ int i; msgq->qe = NULL; msgq->free = &msgq->entries[0]; for (i = 0; i < NR_MESSAGES; i++) msgq->entries[i].next = &msgq->entries[i + 1]; msgq->entries[NR_MESSAGES - 1].next = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Configures the priority grouping: pre-emption priority and subpriority. */
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
/* Configures the priority grouping: pre-emption priority and subpriority. */ void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
{ SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Presents I2C password, to authorize the I2C writes to protected areas. */
int32_t ST25DV_PresentI2CPassword(ST25DV_Object_t *pObj, const ST25DV_PASSWD PassWord)
/* Presents I2C password, to authorize the I2C writes to protected areas. */ int32_t ST25DV_PresentI2CPassword(ST25DV_Object_t *pObj, const ST25DV_PASSWD PassWord)
{ uint8_t ai2c_message[17] = {0}; uint8_t i; ai2c_message[8] = 0x09; for( i = 0; i < 4; i++ ) { ai2c_message[i] = ( PassWord.MsbPasswd >> ( (3 - i) * 8) ) & 0xFF; ai2c_message[i + 4] = ( PassWord.LsbPasswd >> ( (3 - i) * 8) ) & 0xFF; ai2c_message[i + 9] = ai2c_message[i]; ai2c_message[i + 13] ...
eclipse-threadx/getting-started
C++
Other
310
/* Clear the MSTATUS bits and wait for them to be cleared with time out. */
static int mcux_i3c_status_clear_timeout(I3C_Type *base, uint32_t mask, uint32_t init_delay_us, uint32_t step_delay_us, uint32_t total_delay_us)
/* Clear the MSTATUS bits and wait for them to be cleared with time out. */ static int mcux_i3c_status_clear_timeout(I3C_Type *base, uint32_t mask, uint32_t init_delay_us, uint32_t step_delay_us, uint32_t total_delay_us)
{ uint32_t delayed = init_delay_us; int ret = -ETIMEDOUT; while (delayed <= total_delay_us) { base->MSTATUS = mask; if (!mcux_i3c_status_is_set(base, mask)) { ret = 0; break; } k_busy_wait(step_delay_us); delayed += step_delay_us; } return ret; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Software reset. Restore the default values in user registers. */
int32_t lsm6dso_reset_set(lsm6dso_ctx_t *ctx, uint8_t val)
/* Software reset. Restore the default values in user registers. */ int32_t lsm6dso_reset_set(lsm6dso_ctx_t *ctx, uint8_t val)
{ lsm6dso_ctrl3_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)&reg, 1); if (ret == 0) { reg.sw_reset = val; ret = lsm6dso_write_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)&reg, 1); } return ret; }
alexander-g-dean/ESF
C++
null
41
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint8Mult(IN UINT8 Multiplicand, IN UINT8 Multiplier, OUT UINT8 *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUint8Mult(IN UINT8 Multiplicand, IN UINT8 Multiplier, OUT UINT8 *Result)
{ UINT32 IntermediateResult; IntermediateResult = ((UINT32)Multiplicand) *((UINT32)Multiplier); return SafeUint32ToUint8 (IntermediateResult, Result); }
tianocore/edk2
C++
Other
4,240
/* Check whether a controller device path is in a globle device path list */
BOOLEAN EFIAPI CheckExistInStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* Check whether a controller device path is in a globle device path list */ BOOLEAN EFIAPI CheckExistInStack(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ DEVICE_PATH_STACK_ITEM *DevicePathStackItem; LIST_ENTRY *ItemListIndex; UINTN DevicePathSize; ItemListIndex = mDevicePathStack.BackLink; while (ItemListIndex != &mDevicePathStack) { DevicePathStackItem = CR (ItemListIndex, DEVICE_PATH_STACK_ITEM, Link, DEVICE_PATH_STACK_I...
tianocore/edk2
C++
Other
4,240
/* clear the SSL context option bit of "op" */
unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)
/* clear the SSL context option bit of "op" */ unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)
{ SSL_ASSERT1(ctx); return ctx->options &= ~op; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Channel mode helper snd_hda_ch_mode_info - Info callback helper for the channel mode enum */
int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, const struct hda_channel_mode *chmode, int num_chmodes)
/* Channel mode helper snd_hda_ch_mode_info - Info callback helper for the channel mode enum */ int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, const struct hda_channel_mode *chmode, int num_chmodes)
{ uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = num_chmodes; if (uinfo->value.enumerated.item >= num_chmodes) uinfo->value.enumerated.item = num_chmodes - 1; sprintf(uinfo->value.enumerated.name, "%dch", chmode[uinfo->value.enumerated.item].channels); return 0...
robutest/uclinux
C++
GPL-2.0
60
/* Task to manage an enumerated USB RNDIS device once connected, to display device received data packets. */
void RNDISHost_Task(void)
/* Task to manage an enumerated USB RNDIS device once connected, to display device received data packets. */ void RNDISHost_Task(void)
{ if (USB_HostState != HOST_STATE_Configured) return; if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)) { LEDs_SetAllLEDs(LEDMASK_USB_BUSY); uint16_t PacketLength; RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketL...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Called to flush the icache on all cores */
static void octeon_flush_icache_all(void)
/* Called to flush the icache on all cores */ static void octeon_flush_icache_all(void)
{ octeon_flush_icache_all_cores(NULL); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciExpressAnd16(IN UINTN Address, IN UINT16 AndData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */ UINT16 EFIAPI PciExpressAnd16(IN UINTN Address, IN UINT16 AndData)
{ if (Address >= mSmmPciExpressLibPciExpressBaseSize) { return (UINT16)-1; } return MmioAnd16 (GetPciExpressAddress (Address), AndData); }
tianocore/edk2
C++
Other
4,240
/* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
/* RTC MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
{ if(hrtc->Instance==RTC) { __HAL_RCC_RTC_DISABLE(); __HAL_RCC_RTCAPB_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Fills each ADC_InitStruct member with its default value. */
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
/* Fills each ADC_InitStruct member with its default value. */ void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
{ ADC_InitStruct->ADC_Resolution = ADC_Resolution_12b; ADC_InitStruct->ADC_PRESCARE = ADC_PCLK2_PRESCARE_2; ADC_InitStruct->ADC_Mode = ADC_Mode_Single; ADC_InitStruct->ADC_ContinuousConvMode = DISABLE; ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; ADC_InitStruct->ADC_DataAl...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate direction, inclination, and field strength. This routine calculates horizontal direction, vertical inclination and net field magnitude for a "raw" (unscaled) magnetic */
bool field_direction(vector3_t *field, scalar_t *theta, scalar_t *delta, scalar_t *strength)
/* Calculate direction, inclination, and field strength. This routine calculates horizontal direction, vertical inclination and net field magnitude for a "raw" (unscaled) magnetic */ bool field_direction(vector3_t *field, scalar_t *theta, scalar_t *delta, scalar_t *strength)
{ scalar_t const magnitude = vector3_magnitude(field); if (0 == magnitude) { return false; } vector3_scale((1 / magnitude), field); *strength = magnitude; *theta = degrees(-1 * atan2(field->x, field->y)); if (*theta < 0) { *theta += 360; } *delta = degrees(-1 * asin(field->z)); return true; }
memfault/zero-to-main
C++
null
200
/* This function frees a block from block pool */
void __vxge_hw_blockpool_block_free(struct __vxge_hw_device *devh, struct __vxge_hw_blockpool_entry *entry)
/* This function frees a block from block pool */ void __vxge_hw_blockpool_block_free(struct __vxge_hw_device *devh, struct __vxge_hw_blockpool_entry *entry)
{ struct __vxge_hw_blockpool *blockpool; blockpool = &devh->block_pool; if (entry->length == blockpool->block_size) { list_add(&entry->item, &blockpool->free_block_list); blockpool->pool_size++; } __vxge_hw_blockpool_blocks_remove(blockpool); return; }
robutest/uclinux
C++
GPL-2.0
60
/* Set the Voltage Comparator DAC Level Select in Configuration Reg. */
void am_hal_vcomp_dac_level_set(uint32_t ui32Level)
/* Set the Voltage Comparator DAC Level Select in Configuration Reg. */ void am_hal_vcomp_dac_level_set(uint32_t ui32Level)
{ AM_BFW(VCOMP, CFG, LVLSEL, ui32Level >> AM_REG_VCOMP_CFG_LVLSEL_S); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Platform hook to retrieve the 16550 UART base address from the platform Device tree and store it in PcdSerialRegisterBase. */
RETURN_STATUS EFIAPI PlatformHookSerialPortInitialize(VOID)
/* Platform hook to retrieve the 16550 UART base address from the platform Device tree and store it in PcdSerialRegisterBase. */ RETURN_STATUS EFIAPI PlatformHookSerialPortInitialize(VOID)
{ RETURN_STATUS Status; VOID *DeviceTreeBase; UINT64 SerialConsoleAddress; if (PcdGet64 (PcdSerialRegisterBase) != 0) { return RETURN_SUCCESS; } DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); if (DeviceTreeBase == NULL) { return RETURN_NOT_FOUND; }...
tianocore/edk2
C++
Other
4,240
/* Enable the time tick or alarm interrupt of RTC. This function is to enable the time tick or alarm interrupt of RTC. */
void xRTCIntEnable(unsigned long ulIntType)
/* Enable the time tick or alarm interrupt of RTC. This function is to enable the time tick or alarm interrupt of RTC. */ void xRTCIntEnable(unsigned long ulIntType)
{ xASSERT(( ulIntType == xRTC_INT_SECOND ) || ( ulIntType == xRTC_INT_ALARM ) || ( ulIntType == (xRTC_INT_SECOND | xRTC_INT_ALARM) )); if(ulIntType & xRTC_INT_SECOND) { RTCIntCfg((INT_SEC_EN | INT_MIN_DIS | INT_HOUR_DIS | INT_DOM_DIS | INT_DOW_DIS | INT_...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Read in the allocation group free block array. */
STATIC int xfs_alloc_read_agfl(xfs_mount_t *mp, xfs_trans_t *tp, xfs_agnumber_t agno, xfs_buf_t **bpp)
/* Read in the allocation group free block array. */ STATIC int xfs_alloc_read_agfl(xfs_mount_t *mp, xfs_trans_t *tp, xfs_agnumber_t agno, xfs_buf_t **bpp)
{ xfs_buf_t *bp; int error; ASSERT(agno != NULLAGNUMBER); error = xfs_trans_read_buf( mp, tp, mp->m_ddev_targp, XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)), XFS_FSS_TO_BB(mp, 1), 0, &bp); if (error) return error; ASSERT(bp); ASSERT(!XFS_BUF_GETERROR(bp)); XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGFL, XFS_AGFL...
robutest/uclinux
C++
GPL-2.0
60
/* Reads the Least significant byte of the 9-bit CAN Transmit Error Counter. */
uint8_t CAN_ReadLSBTxErrorCounter(void)
/* Reads the Least significant byte of the 9-bit CAN Transmit Error Counter. */ uint8_t CAN_ReadLSBTxErrorCounter(void)
{ uint8_t counter = 0; counter = CAN->ERRSTS_B.TXERRCNT; return counter; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will make sure the PE/COFF image content read is within the image buffer. */
EFI_STATUS EFIAPI DxeImageVerificationLibImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
/* Caution: This function may receive untrusted input. PE/COFF image is external input, so this function will make sure the PE/COFF image content read is within the image buffer. */ EFI_STATUS EFIAPI DxeImageVerificationLibImageRead(IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
{ UINTN EndPosition; if ((FileHandle == NULL) || (ReadSize == NULL) || (Buffer == NULL)) { return EFI_INVALID_PARAMETER; } if (MAX_ADDRESS - FileOffset < *ReadSize) { return EFI_INVALID_PARAMETER; } EndPosition = FileOffset + *ReadSize; if (EndPosition > mImageSize) { *ReadSize = (UINT32)(mIm...
tianocore/edk2
C++
Other
4,240
/* All marks are conditional because a GC may happen while the prototype is still being created */
static void traverseproto(global_State *g, Proto *f)
/* All marks are conditional because a GC may happen while the prototype is still being created */ static void traverseproto(global_State *g, Proto *f)
{ if (f->upvalues[i]) stringmark(f->upvalues[i]); } for (i=0; i<f->sizep; i++) { if (f->p[i]) markobject(g, f->p[i]); } for (i=0; i<f->sizelocvars; i++) { if (f->locvars[i].varname) stringmark(f->locvars[i].varname); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. */
ErrorStatus RTC_WaitForSynchro(void)
/* Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. */ ErrorStatus RTC_WaitForSynchro(void)
{ __IO uint32_t synchrocounter = 0; ErrorStatus status = ERROR; uint32_t synchrostatus = 0x00; if ((RTC->CR & RTC_CR_BYPSHAD) != RESET) { status = SUCCESS; } else { RTC->WPR = 0xCA; RTC->WPR = 0x53; RTC->ISR &= (uint32_t)RTC_RSF_MASK; do { synchrostatus = RTC->ISR & RTC_ISR...
ajhc/demo-cortex-m3
C++
null
38
/* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF US...
void miniopt_init(miniopt_t *t, const char *name, const char *flags, bool longflags)
/* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF US...
{ static const char *null_flags = ""; memset(t, 0, sizeof(miniopt_t)); t->name = name; if (flags == NULL) t->flags = null_flags; else t->flags = flags; t->longflags = longflags; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function is called after a PCI bus error affecting this device has been detected. */
static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
/* This function is called after a PCI bus error affecting this device has been detected. */ static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); netif_device_detach(netdev); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; if (netif_running(netdev)) { do_s2io_card_down(sp, 0); } pci_disable_device(pdev); return PCI_ERS_RESULT_NE...
robutest/uclinux
C++
GPL-2.0
60
/* Enable pull-up resistors to precharge of the selected Tamper pin. */
void RTC_EnablePullUp(void)
/* Enable pull-up resistors to precharge of the selected Tamper pin. */ void RTC_EnablePullUp(void)
{ RTC->TACFG_B.TPPUDIS = BIT_RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Examine the status of the next Rx descriptor to see if it contains new data. */
static unsigned short prvCheckRxStatus(void)
/* Examine the status of the next Rx descriptor to see if it contains new data. */ static unsigned short prvCheckRxStatus(void)
{ unsigned long usReturn = 0; if( ( pxCurrentRxDesc->status & RX_BD_E ) != 0 ) { } else { usReturn = pxCurrentRxDesc->length; } return usReturn; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Enables or disables the High Speed APB (APB2) peripheral clock. */
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
/* Enables or disables the High Speed APB (APB2) peripheral clock. */ void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
{ assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RCC->APB2ENR |= RCC_APB2Periph; } else { RCC->APB2ENR &= ~RCC_APB2Periph; } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Enable/disable USART/UART receiver and/or transmitter. Notice that this function does not do any configuration. Enabling should normally be done after initialization is done (if not enabled as part of init). */
void USART_Enable(USART_TypeDef *usart, USART_Enable_TypeDef enable)
/* Enable/disable USART/UART receiver and/or transmitter. Notice that this function does not do any configuration. Enabling should normally be done after initialization is done (if not enabled as part of init). */ void USART_Enable(USART_TypeDef *usart, USART_Enable_TypeDef enable)
{ uint32_t tmp; EFM_ASSERT(USART_REF_VALID(usart)||(UART_REF_VALID(usart))); tmp = ~((uint32_t)(enable)); tmp &= _USART_CMD_RXEN_MASK | _USART_CMD_TXEN_MASK; usart->CMD = tmp << 1; usart->CMD = (uint32_t)(enable); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Wait for User push-button press to start transfer. */
void WaitForUserButtonPress(void)
/* Wait for User push-button press to start transfer. */ void WaitForUserButtonPress(void)
{ while (ubButtonPress == 0) { LL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN); LL_mDelay(LED_BLINK_FAST); } ubButtonPress = 0; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* This API is used to get the any motion Duration samples in the register 0x1C bit 4 and 5. */
BMG160_RETURN_FUNCTION_TYPE bmg160_get_any_motion_durn_sample(u8 *v_durn_sample_u8)
/* This API is used to get the any motion Duration samples in the register 0x1C bit 4 and 5. */ BMG160_RETURN_FUNCTION_TYPE bmg160_get_any_motion_durn_sample(u8 *v_durn_sample_u8)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_data_u8 = BMG160_INIT_VALUE; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_READ_FUNC(p_bmg160->dev_addr, BMG160_INTR_TWO_ADDR...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns addr of first byte after heap so caller can see if it took too much space. If so, change args & try again. */
void* simple_alloc_init(char *base, unsigned long heap_size, unsigned long granularity, unsigned long max_allocs)
/* Returns addr of first byte after heap so caller can see if it took too much space. If so, change args & try again. */ void* simple_alloc_init(char *base, unsigned long heap_size, unsigned long granularity, unsigned long max_allocs)
{ unsigned long heap_base, tbl_size; heap_size = _ALIGN_UP(heap_size, granularity); alloc_min = granularity; tbl_entries = max_allocs; tbl_size = tbl_entries * sizeof(struct alloc_info); alloc_tbl = (struct alloc_info *)_ALIGN_UP((unsigned long)base, 8); memset(alloc_tbl, 0, tbl_size); heap_base = _ALIGN_UP((un...
EmcraftSystems/linux-emcraft
C++
Other
266
/* init_event_struct: Initialize fields in an event struct that are always required. @evt: The event @done: Routine to call when the event is responded to @format: SRP or MAD format @timeout: timeout value set in the CRQ */
static void init_event_struct(struct srp_event_struct *evt_struct, void(*done)(struct srp_event_struct *), u8 format, int timeout)
/* init_event_struct: Initialize fields in an event struct that are always required. @evt: The event @done: Routine to call when the event is responded to @format: SRP or MAD format @timeout: timeout value set in the CRQ */ static void init_event_struct(struct srp_event_struct *evt_struct, void(*done)(struct srp_event...
{ evt_struct->cmnd = NULL; evt_struct->cmnd_done = NULL; evt_struct->sync_srp = NULL; evt_struct->crq.format = format; evt_struct->crq.timeout = timeout; evt_struct->done = done; }
robutest/uclinux
C++
GPL-2.0
60
/* Get maximum message size in a Memory Pool. */
static uint32_t svcRtxMessageQueueGetMsgSize(osMessageQueueId_t mq_id)
/* Get maximum message size in a Memory Pool. */ static uint32_t svcRtxMessageQueueGetMsgSize(osMessageQueueId_t mq_id)
{ EvrRtxMessageQueueGetMsgSize(mq, 0U); return 0U; } EvrRtxMessageQueueGetMsgSize(mq, mq->msg_size); return mq->msg_size; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Minimum value of a q7 vector without index. */
void arm_min_no_idx_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult)
/* Minimum value of a q7 vector without index. */ void arm_min_no_idx_q7(const q7_t *pSrc, uint32_t blockSize, q7_t *pResult)
{ q7_t minVal1, out; uint32_t blkCnt; out = *pSrc++; blkCnt = (blockSize - 1U); while (blkCnt > 0U) { ...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Get actual external trigger source. @rmtoll CFG TRIGSEL LPTIM_GetTriggerSource. */
uint32_t LPTIM_GetTriggerSource(LPTIM_Module *LPTIMx)
/* Get actual external trigger source. @rmtoll CFG TRIGSEL LPTIM_GetTriggerSource. */ uint32_t LPTIM_GetTriggerSource(LPTIM_Module *LPTIMx)
{ return (uint32_t)(READ_BIT(LPTIMx->CFG, LPTIM_CFG_TRGSEL)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Unregisters an interrupt handler for the timer interrupt. */
void TimerIntUnregister(uint32_t ui32Base, uint32_t ui32Timer)
/* Unregisters an interrupt handler for the timer interrupt. */ void TimerIntUnregister(uint32_t ui32Base, uint32_t ui32Timer)
{ uint32_t ui32Int; ASSERT(_TimerBaseValid(ui32Base)); ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) || (ui32Timer == TIMER_BOTH)); ui32Int = _TimerIntNumberGet(ui32Base, ui32Timer); IntDisable(ui32Int); IntUnregister(ui32Int); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Get part of a pbuf's payload as contiguous memory. The returned memory is either a pointer into the pbuf's payload or, if split over multiple pbufs, a copy into the user-supplied buffer. */
void* pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
/* Get part of a pbuf's payload as contiguous memory. The returned memory is either a pointer into the pbuf's payload or, if split over multiple pbufs, a copy into the user-supplied buffer. */ void* pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
{ const struct pbuf *q; uint16_t out_offset; LWIP_ERROR("pbuf_get_contiguous: invalid buf", (p != NULL), return NULL;); LWIP_ERROR("pbuf_get_contiguous: invalid dataptr", (buffer != NULL), return NULL;); LWIP_ERROR("pbuf_get_contiguous: invalid dataptr", (bufsize >= len), return NULL;); q = pbuf_skip_const(...
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. */
ErrorStatus RTC_WaitForSynchro(void)
/* Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. */ ErrorStatus RTC_WaitForSynchro(void)
{ __IO uint32_t synchrocounter = 0; ErrorStatus status = ERROR; uint32_t synchrostatus = 0x00; if ((RTC->CR & RTC_CR_BYPSHAD) != RESET) { status = SUCCESS; } else { RTC->WPR = 0xCA; RTC->WPR = 0x53; RTC->ISR &= (uint32_t)RTC_RSF_MASK; do { synchrostatus = RTC->ISR & RTC_ISR...
ajhc/demo-cortex-m3
C++
null
38