docstring
stringlengths
22
576
signature
stringlengths
9
317
prompt
stringlengths
57
886
code
stringlengths
20
1.36k
repository
stringclasses
49 values
language
stringclasses
2 values
license
stringclasses
9 values
stars
int64
15
21.3k
/* Get the mapping of a game controller. This can be called before any controllers are opened. If no mapping can be found, this function returns NULL. */
char* SDL_GameControllerMappingForDeviceIndex(int joystick_index)
/* Get the mapping of a game controller. This can be called before any controllers are opened. If no mapping can be found, this function returns NULL. */ char* SDL_GameControllerMappingForDeviceIndex(int joystick_index)
{ char *pMappingString = NULL; ControllerMapping_t *mapping; SDL_LockJoysticks(); mapping = SDL_PrivateGetControllerMapping(joystick_index); if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; guid = SDL_JoystickGetDeviceGUID(joystick_index); SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; pMappingString = SDL_malloc(needed); if (!pMappingString) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; } SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } SDL_UnlockJoysticks(); return pMappingString; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* heartbeat configfs bits. The heartbeat set is a default set under the cluster set in nodemanager.c. */
static struct o2hb_region* to_o2hb_region(struct config_item *item)
/* heartbeat configfs bits. The heartbeat set is a default set under the cluster set in nodemanager.c. */ static struct o2hb_region* to_o2hb_region(struct config_item *item)
{ return item ? container_of(item, struct o2hb_region, hr_item) : NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Reads the specified number of bytes over I2C. */
err_t pca9685ReadBytes(uint8_t reg, uint8_t *buffer, size_t length)
/* Reads the specified number of bytes over I2C. */ err_t pca9685ReadBytes(uint8_t reg, uint8_t *buffer, size_t length)
{ uint32_t i; ASSERT(length <= I2C_BUFSIZE, ERROR_BUFFEROVERFLOW); I2CWriteLength = 2; I2CReadLength = 0; I2CMasterBuffer[0] = _pca9685Address; I2CMasterBuffer[1] = reg; i2cEngine(); I2CWriteLength = 0; I2CReadLength = length; I2CMasterBuffer[0] = _pca9685Address | PCA9685_READBIT; ASSERT_I2C_STATUS(i2cEngine()); for ( i = 0; i < length; i++ ) { buffer[i] = I2CSlaveBuffer[i]; } return ERROR_NONE; }
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Configures several pins using config_pin(). Refer to that function for further information. */
void db8500_gpio_config_pins(unsigned long *cfgs, size_t num)
/* Configures several pins using config_pin(). Refer to that function for further information. */ void db8500_gpio_config_pins(unsigned long *cfgs, size_t num)
{ size_t i; for (i = 0; i < num; i++) config_pin(cfgs[i]); }
4ms/stm32mp1-baremetal
C++
Other
137
/* @handle: handle of the loaded image @systable: system table */
static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
/* @handle: handle of the loaded image @systable: system table */ static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
{ efi_status_t ret; boottime = systable->boottime; ret = boottime->create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, notify, (void *)&notification_count, &event_notify); if (ret != EFI_SUCCESS) { efi_st_error("could not create event\n"); return EFI_ST_FAILURE; } ret = boottime->create_event(EVT_TIMER | EVT_NOTIFY_WAIT, TPL_HIGH_LEVEL, notify, NULL, &event_wait); if (ret != EFI_SUCCESS) { efi_st_error("could not create event\n"); return EFI_ST_FAILURE; } return EFI_ST_SUCCESS; }
4ms/stm32mp1-baremetal
C++
Other
137
/* param base UART peripheral base address. param handle Pointer to the uart_edma_handle_t structure. */
void UART_TransferAbortSendEDMA(UART_Type *base, uart_edma_handle_t *handle)
/* param base UART peripheral base address. param handle Pointer to the uart_edma_handle_t structure. */ void UART_TransferAbortSendEDMA(UART_Type *base, uart_edma_handle_t *handle)
{ assert(handle); assert(handle->txEdmaHandle); UART_EnableTxDMA(base, false); EDMA_AbortTransfer(handle->txEdmaHandle); handle->txState = kUART_TxIdle; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Add a fake id field to the drive we are passed. This allows use to skip a ton of NULL checks (which people always miss) and make drive properties unconditional outside of this file */
static void generic_id(ide_drive_t *drive)
/* Add a fake id field to the drive we are passed. This allows use to skip a ton of NULL checks (which people always miss) and make drive properties unconditional outside of this file */ static void generic_id(ide_drive_t *drive)
{ u16 *id = drive->id; id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl; id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head; id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect; }
robutest/uclinux
C++
GPL-2.0
60
/* Drive the slave select line NSS (RTS pin) to 1 in SPI master mode. */
void usart_spi_release_chip_select(Usart *p_usart)
/* Drive the slave select line NSS (RTS pin) to 1 in SPI master mode. */ void usart_spi_release_chip_select(Usart *p_usart)
{ p_usart->US_CR = US_CR_RCS; }
remotemcu/remcu-chip-sdks
C++
null
436
/* configure the address of the USART in wake up by address match mode */
void usart_address_config(uint32_t usart_periph, uint8_t addr)
/* configure the address of the USART in wake up by address match mode */ void usart_address_config(uint32_t usart_periph, uint8_t addr)
{ USART_CTL1(usart_periph) &= ~(USART_CTL1_ADDR); USART_CTL1(usart_periph) |= (USART_CTL1_ADDR & (uint32_t)addr); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sends the given data directly to the printer via the data endpoints, for the sending of print commands in printer languages accepted by the attached printer (e.g. PCL). */
uint8_t Printer_SendData(const void *const PrinterCommands, const uint16_t CommandSize)
/* Sends the given data directly to the printer via the data endpoints, for the sending of print commands in printer languages accepted by the attached printer (e.g. PCL). */ uint8_t Printer_SendData(const void *const PrinterCommands, const uint16_t CommandSize)
{ uint8_t ErrorCode; Pipe_SelectPipe(PRINTER_DATA_OUT_PIPE); Pipe_Unfreeze(); if ((ErrorCode = Pipe_Write_Stream_LE(PrinterCommands, CommandSize, NULL)) != PIPE_RWSTREAM_NoError) return ErrorCode; Pipe_ClearOUT(); Pipe_WaitUntilReady(); Pipe_Freeze(); return PIPE_RWSTREAM_NoError; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Send a piece of data for ECSPI. This function computes the number of data to be written into D register or Tx FIFO, and write the data into it. At the same time, this function updates the values in master handle structure. */
static void ECSPI_SendTransfer(ECSPI_Type *base, ecspi_master_handle_t *handle)
/* Send a piece of data for ECSPI. This function computes the number of data to be written into D register or Tx FIFO, and write the data into it. At the same time, this function updates the values in master handle structure. */ static void ECSPI_SendTransfer(ECSPI_Type *base, ecspi_master_handle_t *handle)
{ assert(base); assert(handle); uint32_t dataCounts = 0U; dataCounts = (FSL_FEATURE_ECSPI_TX_FIFO_SIZEn(base) - ECSPI_GetTxFifoCount(base)) < (handle->txRemainingBytes) ? (FSL_FEATURE_ECSPI_TX_FIFO_SIZEn(base) - ECSPI_GetTxFifoCount(base)) : (handle->txRemainingBytes); while (dataCounts--) { ECSPI_WriteNonBlocking(base, handle->txData, 1); if (NULL != handle->txData) { handle->txData += 1U; } handle->txRemainingBytes -= 1U; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Change Logs: Date Author Notes bkk first version */
int main(void)
/* Change Logs: Date Author Notes bkk first version */ int main(void)
{ for(;;) { rt_thread_mdelay(500); } return RT_EOK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Flush the output text and add a tabstop */
int ecTabstop(RTF_Context *ctx)
/* Flush the output text and add a tabstop */ int ecTabstop(RTF_Context *ctx)
{ int status; status = ecProcessData(ctx); if (status == ecOK) status = ecAddTab(ctx); return status; }
DC-SWAT/DreamShell
C++
null
404
/* param name The name of the selected ldo. Please see the enumeration pmu_ldo_name_t for details. param setpointMap The map of setpoints that the LDO bypass mode will be enabled in those setpoints, this value should be the OR'ed Value of _pmu_setpoint_map. */
void PMU_GPCEnableLdoBypassMode(pmu_ldo_name_t name, uint32_t setpointMap)
/* param name The name of the selected ldo. Please see the enumeration pmu_ldo_name_t for details. param setpointMap The map of setpoints that the LDO bypass mode will be enabled in those setpoints, this value should be the OR'ed Value of _pmu_setpoint_map. */ void PMU_GPCEnableLdoBypassMode(pmu_ldo_name_t name, uint32_t setpointMap)
{ assert(name > kPMU_PllLdo); assert(name < kPMU_SnvsDigLdo); uint32_t ldoBypassEnableRegArray[] = PMU_LDO_BYPASS_EN_SETPOINT_REGISTERS; (*(volatile uint32_t *)ldoBypassEnableRegArray[(uint8_t)name]) = setpointMap; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the last key of an input device (for LV_INDEV_TYPE_KEYPAD) */
uint32_t lv_indev_get_key(const lv_indev_t *indev)
/* Get the last key of an input device (for LV_INDEV_TYPE_KEYPAD) */ uint32_t lv_indev_get_key(const lv_indev_t *indev)
{ if(indev->driver.type != LV_INDEV_TYPE_KEYPAD) return 0; else return indev->proc.last_key; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Write to a SSD2828 hardware register (regnum >= 0xB0) */
static void write_hw_register(const struct ssd2828_config *cfg, u8 regnum, u16 val)
/* Write to a SSD2828 hardware register (regnum >= 0xB0) */ static void write_hw_register(const struct ssd2828_config *cfg, u8 regnum, u16 val)
{ soft_spi_xfer_24bit_3wire(cfg, 0x700000 | regnum); soft_spi_xfer_24bit_3wire(cfg, 0x720000 | val); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns: (transfer full): a #GInputStream to read the icon from. */
GInputStream* g_loadable_icon_load(GLoadableIcon *icon, int size, char **type, GCancellable *cancellable, GError **error)
/* Returns: (transfer full): a #GInputStream to read the icon from. */ GInputStream* g_loadable_icon_load(GLoadableIcon *icon, int size, char **type, GCancellable *cancellable, GError **error)
{ GLoadableIconIface *iface; g_return_val_if_fail (G_IS_LOADABLE_ICON (icon), NULL); iface = G_LOADABLE_ICON_GET_IFACE (icon); return (* iface->load) (icon, size, type, cancellable, error); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set a QH or TD horizontally to be connected with a specific QH. */
VOID SetQHHorizontalQHorTDSelect(IN QH_STRUCT *PtrQH, IN BOOLEAN IsQH)
/* Set a QH or TD horizontally to be connected with a specific QH. */ VOID SetQHHorizontalQHorTDSelect(IN QH_STRUCT *PtrQH, IN BOOLEAN IsQH)
{ PtrQH->QueueHead.QHHorizontalQSelect = IsQH ? 1 : 0; }
tianocore/edk2
C++
Other
4,240
/* Put single characters to the ttys character buffer */
static int tty3270_put_char(struct tty_struct *tty, unsigned char ch)
/* Put single characters to the ttys character buffer */ static int tty3270_put_char(struct tty_struct *tty, unsigned char ch)
{ struct tty3270 *tp; tp = tty->driver_data; if (!tp || tp->char_count >= TTY3270_CHAR_BUF_SIZE) return 0; tp->char_buf[tp->char_count++] = ch; return 1; }
robutest/uclinux
C++
GPL-2.0
60
/* Configure DCI CROP mode by configuring the structure. */
void DCI_ConfigCROP(DCI_CropConfig_T *cropConfig)
/* Configure DCI CROP mode by configuring the structure. */ void DCI_ConfigCROP(DCI_CropConfig_T *cropConfig)
{ DCI->CROPWSTAT_B.HOFSCNT = (uint16_t)cropConfig->horizontalOffsetCount; DCI->CROPWSTAT_B.VSLINECNT = (uint16_t)cropConfig->verticalStartLine; DCI->CROPWSIZE_B.CCNT = (uint16_t)cropConfig->captureCount; DCI->CROPWSIZE_B.VLINECNT = (uint16_t)cropConfig->verticalLineCount; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Selects the GPIO pin used as EXTI Line. */
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
/* Selects the GPIO pin used as EXTI Line. */ void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
{ uint32_t tmp = 0x00; assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx)); assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex)); tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)); SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp; SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03))); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable stacking of FPU registers on exception entry. */
void am_hal_sysctrl_fpu_stacking_enable(bool bLazy)
/* Enable stacking of FPU registers on exception entry. */ void am_hal_sysctrl_fpu_stacking_enable(bool bLazy)
{ if ( bLazy ) { AM_REG(SYSCTRL, FPCCR) |= (AM_REG_SYSCTRL_FPCCR_ASPEN(0x1) | AM_REG_SYSCTRL_FPCCR_LSPEN(0x1)); } else { AM_REG(SYSCTRL, FPCCR) |= AM_REG_SYSCTRL_FPCCR_ASPEN(0x1); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns CR_OK upon succesful completion, an error code otherwise. */
enum CRStatus cr_num_set(CRNum *a_this, gdouble a_val, enum CRNumType a_type)
/* Returns CR_OK upon succesful completion, an error code otherwise. */ enum CRStatus cr_num_set(CRNum *a_this, gdouble a_val, enum CRNumType a_type)
{ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR); a_this->val = a_val; a_this->type = a_type; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* display a point on the lcd using the given colour. */
void lcd_draw_point_color(rt_uint16_t x, rt_uint16_t y, rt_uint16_t color)
/* display a point on the lcd using the given colour. */ void lcd_draw_point_color(rt_uint16_t x, rt_uint16_t y, rt_uint16_t color)
{ lcd_address_set(x, y, x, y); lcd_write_half_word(color); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This file is part of the Simba project. */
int main()
/* This file is part of the Simba project. */ int main()
{ sys_start(); thrd_suspend(NULL); return (0); }
eerimoq/simba
C++
Other
337
/* Flush routine, it simply sets the flush flag and tries to start pending IO. */
static void raw3215_flush_buffer(struct raw3215_info *raw)
/* Flush routine, it simply sets the flush flag and tries to start pending IO. */ static void raw3215_flush_buffer(struct raw3215_info *raw)
{ unsigned long flags; spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); if (raw->count > 0) { raw->flags |= RAW3215_FLUSHING; raw3215_try_io(raw); raw->flags &= ~RAW3215_FLUSHING; } spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Is lu valid? Is the 1394 node still present? */
static int sbp2util_node_is_available(struct sbp2_lu *lu)
/* Is lu valid? Is the 1394 node still present? */ static int sbp2util_node_is_available(struct sbp2_lu *lu)
{ return lu && lu->ne && !lu->ne->in_limbo; }
robutest/uclinux
C++
GPL-2.0
60
/* Get the base address and size for the fault tolerant write (FTW) spare area used for UEFI variable storage. */
EFI_STATUS EFIAPI GetVariableFlashFtwSpareInfo(OUT EFI_PHYSICAL_ADDRESS *BaseAddress, OUT UINT64 *Length)
/* Get the base address and size for the fault tolerant write (FTW) spare area used for UEFI variable storage. */ EFI_STATUS EFIAPI GetVariableFlashFtwSpareInfo(OUT EFI_PHYSICAL_ADDRESS *BaseAddress, OUT UINT64 *Length)
{ EFI_STATUS Status; VARIABLE_FLASH_INFO *VariableFlashInfo; if ((BaseAddress == NULL) || (Length == NULL)) { return EFI_INVALID_PARAMETER; } Status = GetVariableFlashInfoFromHob (&VariableFlashInfo); if (!EFI_ERROR (Status)) { *BaseAddress = VariableFlashInfo->FtwSpareBaseAddress; *Length = VariableFlashInfo->FtwSpareLength; } else { *BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageFtwSpareBase64) != 0 ? PcdGet64 (PcdFlashNvStorageFtwSpareBase64) : PcdGet32 (PcdFlashNvStorageFtwSpareBase) ); *Length = (UINT64)PcdGet32 (PcdFlashNvStorageFtwSpareSize); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* e1000_read_eeprom - Reads a 16 bit word from the EEPROM. @hw: Struct containing variables accessed by shared code @offset: offset of word in the EEPROM to read @data: word read from the EEPROM @words: number of words to read */
s32 e1000_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
/* e1000_read_eeprom - Reads a 16 bit word from the EEPROM. @hw: Struct containing variables accessed by shared code @offset: offset of word in the EEPROM to read @data: word read from the EEPROM @words: number of words to read */ s32 e1000_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
{ s32 ret; spin_lock(&e1000_eeprom_lock); ret = e1000_do_read_eeprom(hw, offset, words, data); spin_unlock(&e1000_eeprom_lock); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Compare the Unicode and Ascii string pointed by String to the string pointed by String2. */
INTN EFIAPI StriCmpUnicodeAndAscii(IN CHAR16 *String, IN CHAR8 *String2)
/* Compare the Unicode and Ascii string pointed by String to the string pointed by String2. */ INTN EFIAPI StriCmpUnicodeAndAscii(IN CHAR16 *String, IN CHAR8 *String2)
{ while ((*String != L'\0') && (CharToUpper (*String) == (CHAR16)AsciiCharToUpper (*String2))) { String++; String2++; } return CharToUpper (*String) - (CHAR16)AsciiCharToUpper (*String2); }
tianocore/edk2
C++
Other
4,240
/* brief Return Frequency of CLK 48MHz return Frequency of CLK 48MHz */
static uint32_t CLOCK_GetClk48MFreq(void)
/* brief Return Frequency of CLK 48MHz return Frequency of CLK 48MHz */ static uint32_t CLOCK_GetClk48MFreq(void)
{ return ((SCG0->FIRCCSR & SCG_FIRCCSR_FIRC_SCLK_PERIPH_EN_MASK) != 0U) ? 48000000U : 0U; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function convert UBIFS (@UBIFS_COMPR_FL, etc) to ioctl flags (@FS_COMPR_FL, etc). */
static int ubifs2ioctl(int ubifs_flags)
/* This function convert UBIFS (@UBIFS_COMPR_FL, etc) to ioctl flags (@FS_COMPR_FL, etc). */ static int ubifs2ioctl(int ubifs_flags)
{ int ioctl_flags = 0; if (ubifs_flags & UBIFS_COMPR_FL) ioctl_flags |= FS_COMPR_FL; if (ubifs_flags & UBIFS_SYNC_FL) ioctl_flags |= FS_SYNC_FL; if (ubifs_flags & UBIFS_APPEND_FL) ioctl_flags |= FS_APPEND_FL; if (ubifs_flags & UBIFS_IMMUTABLE_FL) ioctl_flags |= FS_IMMUTABLE_FL; if (ubifs_flags & UBIFS_DIRSYNC_FL) ioctl_flags |= FS_DIRSYNC_FL; return ioctl_flags; }
robutest/uclinux
C++
GPL-2.0
60
/* Remark: we just assume it is correct board here! */
int checkboard(void)
/* Remark: we just assume it is correct board here! */ int checkboard(void)
{ printf("BOARD: Cogent CSB272\n"); return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read. */
static int find_dirent(nfs_readdir_descriptor_t *desc)
/* If the end of the buffer has been reached, return -EAGAIN, if not, return the offset within the buffer of the next entry to be read. */ static int find_dirent(nfs_readdir_descriptor_t *desc)
{ struct nfs_entry *entry = desc->entry; int loop_count = 0, status; while((status = dir_decode(desc)) == 0) { dfprintk(DIRCACHE, "NFS: %s: examining cookie %Lu\n", __func__, (unsigned long long)entry->cookie); if (entry->prev_cookie == *desc->dir_cookie) break; if (loop_count++ > 200) { loop_count = 0; schedule(); } } return status; }
robutest/uclinux
C++
GPL-2.0
60
/* How much does the command regulator lag behind? */
static uint32_t via_cmdbuf_lag(drm_via_private_t *dev_priv)
/* How much does the command regulator lag behind? */ static uint32_t via_cmdbuf_lag(drm_via_private_t *dev_priv)
{ uint32_t agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; uint32_t hw_addr = *(dev_priv->hw_addr_ptr) - agp_base; return ((hw_addr <= dev_priv->dma_low) ? (dev_priv->dma_low - hw_addr) : (dev_priv->dma_wrap + dev_priv->dma_low - hw_addr)); }
robutest/uclinux
C++
GPL-2.0
60
/* param base DMA peripheral base address. param channel DMA channel number. return The number of bytes which have not been transferred yet. */
uint32_t DMA_GetRemainingBytes(DMA_Type *base, uint32_t channel)
/* param base DMA peripheral base address. param channel DMA channel number. return The number of bytes which have not been transferred yet. */ uint32_t DMA_GetRemainingBytes(DMA_Type *base, uint32_t channel)
{ assert(channel < (uint32_t)FSL_FEATURE_DMA_NUMBER_OF_CHANNELSn(base)); if ((!DMA_ChannelIsActive(base, channel)) && (0x3FFUL == ((base->CHANNEL[channel].XFERCFG & DMA_CHANNEL_XFERCFG_XFERCOUNT_MASK) >> DMA_CHANNEL_XFERCFG_XFERCOUNT_SHIFT))) { return 0UL; } return ((base->CHANNEL[channel].XFERCFG & DMA_CHANNEL_XFERCFG_XFERCOUNT_MASK) >> DMA_CHANNEL_XFERCFG_XFERCOUNT_SHIFT) + 1UL; }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Upper level users use ib_unregister_client() to remove their client registration. When ib_unregister_client() is called, the client will receive a remove callback for each IB device still registered. */
void ib_unregister_client(struct ib_client *client)
/* Upper level users use ib_unregister_client() to remove their client registration. When ib_unregister_client() is called, the client will receive a remove callback for each IB device still registered. */ void ib_unregister_client(struct ib_client *client)
{ struct ib_client_data *context, *tmp; struct ib_device *device; unsigned long flags; mutex_lock(&device_mutex); list_for_each_entry(device, &device_list, core_list) { if (client->remove) client->remove(device); spin_lock_irqsave(&device->client_data_lock, flags); list_for_each_entry_safe(context, tmp, &device->client_data_list, list) if (context->client == client) { list_del(&context->list); kfree(context); } spin_unlock_irqrestore(&device->client_data_lock, flags); } list_del(&client->list); mutex_unlock(&device_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* Request the PE to send a GET_SRC_CAPA message. */
USBPD_StatusTypeDef USBPD_DPM_RequestGetSourceCapability(uint8_t PortNum)
/* Request the PE to send a GET_SRC_CAPA message. */ USBPD_StatusTypeDef USBPD_DPM_RequestGetSourceCapability(uint8_t PortNum)
{ return USBPD_PE_Request_CtrlMessage(PortNum, USBPD_CONTROLMSG_GET_SRC_CAP, USBPD_SOPTYPE_SOP); }
st-one/X-CUBE-USB-PD
C++
null
110
/* lejp_destruct - retire a previously constructed struct lejp_ctx */
void lejp_destruct(struct lejp_ctx *ctx)
/* lejp_destruct - retire a previously constructed struct lejp_ctx */ void lejp_destruct(struct lejp_ctx *ctx)
{ ctx->callback(ctx, LEJPCB_DESTRUCTED); }
Nicholas3388/LuaNode
C++
Other
1,055
/* One byte configuration write on PSII. Currently fixes destination bus to PCI2, onboard pci. */
static int psII_write_config_byte(struct pci_controller *hose, pci_dev_t dev, int reg, u8 val)
/* One byte configuration write on PSII. Currently fixes destination bus to PCI2, onboard pci. */ static int psII_write_config_byte(struct pci_controller *hose, pci_dev_t dev, int reg, u8 val)
{ write4be (PSII_CONFIG_ADDR, PSII_CONFIG_DEST_PCI2 | (PCI_BUS (dev) << 16) | (PCI_DEV (dev) << 11) | (PCI_FUNC (dev) << 8) | ((reg & 0xFF) & ~3)); write1 (PSII_CONFIG_DATA + (reg & 0x03), (unsigned char) val); return (0); }
EmcraftSystems/u-boot
C++
Other
181
/* If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). */
VOID EFIAPI FreePool(IN VOID *Buffer)
/* If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, then ASSERT(). */ VOID EFIAPI FreePool(IN VOID *Buffer)
{ EFI_STATUS Status; if (BufferInSmram (Buffer)) { Status = SmmFreePool (Buffer); } else { Status = gBS->FreePool (Buffer); } ASSERT_EFI_ERROR (Status); }
tianocore/edk2
C++
Other
4,240
/* param base XRDC2 peripheral base address. param periph Which peripheral descriptor to set. param lockMode The lock mode to set. */
void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode)
/* param base XRDC2 peripheral base address. param periph Which peripheral descriptor to set. param lockMode The lock mode to set. */ void XRDC2_SetPeriphAccessLockMode(XRDC2_Type *base, xrdc2_periph_t periph, xrdc2_access_config_lock_t lockMode)
{ uint32_t pac = XRDC2_GET_PAC((uint32_t)periph); uint32_t pdac = XRDC2_GET_PDAC((uint32_t)periph); uint32_t reg = base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1 & ~(XRDC2_EAL_MASK | XRDC2_PAC_PDAC_W1_DL2_MASK); base->PACI_PDACJ[pac][pdac].PAC_PDAC_W1 = (reg | XRDC2_PAC_PDAC_W1_DL2(lockMode)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the partition info of all the partitions available. */
int zynq_get_partition_info(u32 image_base_addr, u32 *fsbl_len, struct partition_hdr *part_hdr)
/* Get the partition info of all the partitions available. */ int zynq_get_partition_info(u32 image_base_addr, u32 *fsbl_len, struct partition_hdr *part_hdr)
{ u32 parthdroffset; *fsbl_len = *((u32 *)(image_base_addr + ZYNQ_IMAGE_FSBL_LEN_OFFSET)); parthdroffset = *((u32 *)(image_base_addr + ZYNQ_IMAGE_PHDR_OFFSET)); parthdroffset += image_base_addr; memcpy(part_hdr, (u32 *)parthdroffset, (sizeof(struct partition_hdr) * ZYNQ_MAX_PARTITION_NUMBER)); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* return an NT error string from a SMB buffer */
const char* nt_errstr(uint32_t err)
/* return an NT error string from a SMB buffer */ const char* nt_errstr(uint32_t err)
{ static char ret[128]; int i; ret[0] = 0; for (i = 0; nt_errors[i].name; i++) { if (err == nt_errors[i].code) return nt_errors[i].name; } snprintf(ret, sizeof(ret), "0x%08x", err); return ret; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Handles an incoming execute-write-response for the specified write-long-characteristic-values proc. */
static int ble_gattc_write_long_rx_exec(struct ble_gattc_proc *proc, int status)
/* Handles an incoming execute-write-response for the specified write-long-characteristic-values proc. */ static int ble_gattc_write_long_rx_exec(struct ble_gattc_proc *proc, int status)
{ ble_gattc_dbg_assert_proc_not_inserted(proc); if (proc->write_long.attr.offset < OS_MBUF_PKTLEN(proc->write_long.attr.om)) { return BLE_HS_EBADDATA; } ble_gattc_write_long_cb(proc, status, 0); return BLE_HS_EDONE; }
Nicholas3388/LuaNode
C++
Other
1,055
/* This function returns the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts. */
uint32_t SysTickPeriodGet(void)
/* This function returns the rate at which the SysTick counter wraps, which equates to the number of processor clocks between interrupts. */ uint32_t SysTickPeriodGet(void)
{ return (HWREG(NVIC_ST_RELOAD) + 1); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configure USB Device Endpoint according to Descriptor Parameters: pEPD: Pointer to Device Endpoint Descriptor Return Value: None */
void USBD_ConfigEP(USB_ENDPOINT_DESCRIPTOR *pEPD)
/* Configure USB Device Endpoint according to Descriptor Parameters: pEPD: Pointer to Device Endpoint Descriptor Return Value: None */ void USBD_ConfigEP(USB_ENDPOINT_DESCRIPTOR *pEPD)
{ UDPHS->UDPHS_EPT[num].UDPHS_EPTCFG = (interval << 8) | (bank << 6) | (type << 4) | (dir << 3) | (size << 0) ; UDPHS->UDPHS_EPT[num].UDPHS_EPTCTLENB = (0x1 << 9) | (0x1 << 10) | (0x1 << 4) | (0x1 << 13) ; } }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */
EFI_STATUS EFIAPI TlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */ EFI_STATUS EFIAPI TlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
{ TLS_CONNECTION *TlsConn; SSL_SESSION *Session; TlsConn = (TLS_CONNECTION *)Tls; Session = NULL; if ((TlsConn == NULL) || (TlsConn->Ssl == NULL) || (KeyMaterial == NULL)) { return EFI_INVALID_PARAMETER; } Session = SSL_get_session (TlsConn->Ssl); if (Session == NULL) { return EFI_UNSUPPORTED; } SSL_SESSION_get_master_key (Session, KeyMaterial, SSL3_MASTER_SECRET_SIZE); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event. */
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t *const CDCInterfaceInfo)
/* Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event. */ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t *const CDCInterfaceInfo)
{ static bool PreviousDTRState = false; bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR); if (!(PreviousDTRState) && CurrentDTRState) { LEDs_SetAllLEDs(LEDMASK_BUSY); AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; PulseMSRemaining.ResetPulse = AVR_RESET_PULSE_MS; } PreviousDTRState = CurrentDTRState; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Read the ft3x67 device ID, pre initialize I2C in case of need to be able to read the FT3X67 device ID, and verify this is a FT3X67. */
uint16_t ft3x67_ReadID(uint16_t DeviceAddr)
/* Read the ft3x67 device ID, pre initialize I2C in case of need to be able to read the FT3X67 device ID, and verify this is a FT3X67. */ uint16_t ft3x67_ReadID(uint16_t DeviceAddr)
{ ft3x67_I2C_InitializeIfRequired(); return(TS_IO_Read(DeviceAddr, FT3X67_CHIP_ID_REG)); }
eclipse-threadx/getting-started
C++
Other
310
/* Worker function to parse CPU BIST information from Guided HOB. */
EFI_STATUS GetBistFromHob(IN OUT UINT64 *StructureSize, IN OUT VOID *StructureBuffer)
/* Worker function to parse CPU BIST information from Guided HOB. */ EFI_STATUS GetBistFromHob(IN OUT UINT64 *StructureSize, IN OUT VOID *StructureBuffer)
{ EFI_HOB_GUID_TYPE *GuidHob; VOID *DataInHob; UINTN DataSize; GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid); if (GuidHob == NULL) { *StructureSize = 0; return EFI_SUCCESS; } DataInHob = GET_GUID_HOB_DATA (GuidHob); DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob); if ((*StructureSize) < (UINT64)DataSize) { *StructureSize = (UINT64)DataSize; return EFI_BUFFER_TOO_SMALL; } *StructureSize = (UINT64)DataSize; CopyMem (StructureBuffer, DataInHob, DataSize); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* audio mute on/off mute_on : 0 output enabled 1 mute */
static int snd_ps3_mute(int mute_on)
/* audio mute on/off mute_on : 0 output enabled 1 mute */ static int snd_ps3_mute(int mute_on)
{ return ps3av_audio_mute(mute_on); }
robutest/uclinux
C++
GPL-2.0
60
/* Try to post the "msg" to the mailbox. Returns ERR_MEM if this one is full, else, ERR_OK if the "msg" is posted. */
int k_mbox_trypost(k_mbox_t *mb, void *msg)
/* Try to post the "msg" to the mailbox. Returns ERR_MEM if this one is full, else, ERR_OK if the "msg" is posted. */ int k_mbox_trypost(k_mbox_t *mb, void *msg)
{ u8_t first; k_mbox_t *mbox; if (NULL == mb) { BT_ERR("invaild mbox"); return ERR_MEM; } mbox = mb; k_sem_take(&mbox->mutex, K_FOREVER); BT_DBG("k_mbox_trypost: mbox %p msg %p\n", (void *)mbox, (void *)msg); if ((mbox->last + 1) >= (mbox->first + K_MBOX_SIZE)) { k_sem_give(&mbox->mutex); return ERR_MEM; } mbox->msgs[mbox->last % K_MBOX_SIZE] = msg; if (mbox->last == mbox->first) { first = 1; } else { first = 0; } mbox->last++; if (first) { k_sem_give(&mbox->not_empty); } k_sem_give(&mbox->mutex); return ERR_OK; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* In a fault condition, pins which have not been configured to be suppressed via a call to */
void PWMOutputFaultLevel(unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bDriveHigh)
/* In a fault condition, pins which have not been configured to be suppressed via a call to */ void PWMOutputFaultLevel(unsigned long ulBase, unsigned long ulPWMOutBits, tBoolean bDriveHigh)
{ ASSERT(HWREG(SYSCTL_DC5) & SYSCTL_DC5_PWMEFLT); ASSERT(ulBase == PWM_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(bDriveHigh == true) { HWREG(ulBase + PWM_O_FAULTVAL) |= ulPWMOutBits; } else { HWREG(ulBase + PWM_O_FAULTVAL) &= ~(ulPWMOutBits); } }
watterott/WebRadio
C++
null
71
/* Send a master data receive request with an NACK when the master have For this function returns immediately, it is always using in the interrupt hander. */
void I2CMasterReadLastRequestS2(unsigned long ulBase)
/* Send a master data receive request with an NACK when the master have For this function returns immediately, it is always using in the interrupt hander. */ void I2CMasterReadLastRequestS2(unsigned long ulBase)
{ xASSERT((ulBase == I2C0_BASE)); xHWREG(ulBase + I2C_CR) &= ~I2C_CR_AA; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* USART check if Received Data Available. Check if data buffer holds a valid received data word. */
bool usart_is_recv_ready(uint32_t usart)
/* USART check if Received Data Available. Check if data buffer holds a valid received data word. */ bool usart_is_recv_ready(uint32_t usart)
{ return ((USART_SR(usart) & USART_SR_RXNE)); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Enable the High Speed APB (APB2) peripheral clock. */
void RCM_EnableAPB2PeriphClock(uint32_t APB2Periph)
/* Enable the High Speed APB (APB2) peripheral clock. */ void RCM_EnableAPB2PeriphClock(uint32_t APB2Periph)
{ RCM->APBCLKEN2 |= APB2Periph; }
pikasTech/PikaPython
C++
MIT License
1,403
/* If Address > 0x0FFFFFFF, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */
UINT8 EFIAPI PciCf8Or8(IN UINTN Address, IN UINT8 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If the register specified by Address >= 0x100, then ASSERT(). */ UINT8 EFIAPI PciCf8Or8(IN UINTN Address, IN UINT8 OrData)
{ BOOLEAN InterruptState; UINT32 AddressPort; UINT8 Result; ASSERT_INVALID_PCI_ADDRESS (Address, 0); InterruptState = SaveAndDisableInterrupts (); AddressPort = IoRead32 (PCI_CONFIGURATION_ADDRESS_PORT); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address)); Result = IoOr8 ( PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3), OrData ); IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, AddressPort); SetInterruptState (InterruptState); return Result; }
tianocore/edk2
C++
Other
4,240
/* Fills each USART_InitStruct member with its default value. */
void USART_ConfigStructInit(USART_Config_T *usartConfig)
/* Fills each USART_InitStruct member with its default value. */ void USART_ConfigStructInit(USART_Config_T *usartConfig)
{ usartConfig->baudRate = 9600; usartConfig->wordLength = USART_WORD_LEN_8B; usartConfig->stopBits = USART_STOP_BIT_1; usartConfig->parity = USART_PARITY_NONE ; usartConfig->mode = USART_MODE_TX_RX; usartConfig->hardwareFlow = USART_HARDWARE_FLOW_NONE; }
pikasTech/PikaPython
C++
MIT License
1,403
/* free_swap_count_continuations - swapoff free all the continuation pages appended to the swap_map, after swap_map is quiesced, before vfree'ing it. */
static void free_swap_count_continuations(struct swap_info_struct *)
/* free_swap_count_continuations - swapoff free all the continuation pages appended to the swap_map, after swap_map is quiesced, before vfree'ing it. */ static void free_swap_count_continuations(struct swap_info_struct *)
{ pgoff_t offset; for (offset = 0; offset < si->max; offset += PAGE_SIZE) { struct page *head; head = vmalloc_to_page(si->swap_map + offset); if (page_private(head)) { struct list_head *this, *next; list_for_each_safe(this, next, &head->lru) { struct page *page; page = list_entry(this, struct page, lru); list_del(this); __free_page(page); } } } }
robutest/uclinux
C++
GPL-2.0
60
/* To remove and element and call the free function, call xfs_mru_cache_delete() with the data store and the element's key. */
void xfs_mru_cache_delete(xfs_mru_cache_t *mru, unsigned long key)
/* To remove and element and call the free function, call xfs_mru_cache_delete() with the data store and the element's key. */ void xfs_mru_cache_delete(xfs_mru_cache_t *mru, unsigned long key)
{ void *value = xfs_mru_cache_remove(mru, key); if (value) mru->free_func(key, value); }
robutest/uclinux
C++
GPL-2.0
60
/* nfs_sync_mapping - helper to flush all mmapped dirty data to disk */
int nfs_sync_mapping(struct address_space *mapping)
/* nfs_sync_mapping - helper to flush all mmapped dirty data to disk */ int nfs_sync_mapping(struct address_space *mapping)
{ int ret; if (mapping->nrpages == 0) return 0; unmap_mapping_range(mapping, 0, 0, 0); ret = filemap_write_and_wait(mapping); if (ret != 0) goto out; ret = nfs_wb_all(mapping->host); out: return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* For Td guest TDVMCALL_MMIO is invoked to read MMIO registers. */
UINT8 EFIAPI MmioRead8(IN UINTN Address)
/* For Td guest TDVMCALL_MMIO is invoked to read MMIO registers. */ UINT8 EFIAPI MmioRead8(IN UINTN Address)
{ UINT8 Value; BOOLEAN Flag; Flag = FilterBeforeMmIoRead (FilterWidth8, Address, &Value); if (Flag) { MemoryFence (); if (IsTdxGuest ()) { Value = TdMmioRead8 (Address); } else { Value = *(volatile UINT8 *)Address; } MemoryFence (); } FilterAfterMmIoRead (FilterWidth8, Address, &Value); return Value; }
tianocore/edk2
C++
Other
4,240
/* Encode a point. This method assumes that the point is correct and is not the point at infinity. Encoded size is always 1+2*plen, where plen is the field modulus length, in bytes. */
static void point_encode(void *dst, const jacobian *P, const curve_params *cc)
/* Encode a point. This method assumes that the point is correct and is not the point at infinity. Encoded size is always 1+2*plen, where plen is the field modulus length, in bytes. */ static void point_encode(void *dst, const jacobian *P, const curve_params *cc)
{ unsigned char *buf; size_t plen; jacobian Q, T; buf = dst; plen = (cc->p[0] - (cc->p[0] >> 4) + 7) >> 3; buf[0] = 0x04; memcpy(&Q, P, sizeof *P); set_one(T.c[2], cc->p); run_code(&Q, &T, cc, code_affine); br_i15_encode(buf + 1, plen, Q.c[0]); br_i15_encode(buf + 1 + plen, plen, Q.c[1]); }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Send STOP condition to NVRAM - puts NVRAM to sleep... ZZZzzz!! */
static void T93C46_Stop(struct sym_device *np, u_char *gpreg)
/* Send STOP condition to NVRAM - puts NVRAM to sleep... ZZZzzz!! */ static void T93C46_Stop(struct sym_device *np, u_char *gpreg)
{ *gpreg &= 0xef; OUTB(np, nc_gpreg, *gpreg); INB(np, nc_mbox1); udelay(2); T93C46_Clk(np, gpreg); }
robutest/uclinux
C++
GPL-2.0
60
/* onenand_sync_read_bufferram - Read the bufferram area with Sync. Burst mode */
static int onenand_sync_read_bufferram(struct mtd_info *mtd, loff_t addr, int area, unsigned char *buffer, int offset, size_t count)
/* onenand_sync_read_bufferram - Read the bufferram area with Sync. Burst mode */ static int onenand_sync_read_bufferram(struct mtd_info *mtd, loff_t addr, int area, unsigned char *buffer, int offset, size_t count)
{ struct onenand_chip *this = mtd->priv; void __iomem *bufferram; bufferram = this->base + area; bufferram += onenand_bufferram_offset(mtd, area); this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ); memcpy_16(buffer, bufferram + offset, count); this->mmcontrol(mtd, 0); return 0; }
EmcraftSystems/u-boot
C++
Other
181
/* Given an array of dqtrx structures, lock all the dquots associated and join them to the transaction, provided they have been modified. We know that the highest number of dquots (of one type - usr OR grp), involved in a transaction is 2 and that both usr and grp combined - 3. So, we don't attempt to make this very generic. */
STATIC void xfs_trans_dqlockedjoin(xfs_trans_t *tp, xfs_dqtrx_t *q)
/* Given an array of dqtrx structures, lock all the dquots associated and join them to the transaction, provided they have been modified. We know that the highest number of dquots (of one type - usr OR grp), involved in a transaction is 2 and that both usr and grp combined - 3. So, we don't attempt to make this very generic. */ STATIC void xfs_trans_dqlockedjoin(xfs_trans_t *tp, xfs_dqtrx_t *q)
{ ASSERT(q[0].qt_dquot != NULL); if (q[1].qt_dquot == NULL) { xfs_dqlock(q[0].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); } else { ASSERT(XFS_QM_TRANS_MAXDQS == 2); xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot); xfs_trans_dqjoin(tp, q[0].qt_dquot); xfs_trans_dqjoin(tp, q[1].qt_dquot); } }
robutest/uclinux
C++
GPL-2.0
60
/* Description: This is the hashing function for the port table, it returns the bucket number for the given port. */
static unsigned int sel_netport_hashfn(u16 pnum)
/* Description: This is the hashing function for the port table, it returns the bucket number for the given port. */ static unsigned int sel_netport_hashfn(u16 pnum)
{ return (pnum & (SEL_NETPORT_HASH_SIZE - 1)); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the frequency of the external oscillator clock connected to the SYS_XTAL_IN pin, or 0 if it cannot be determined. */
unsigned int mpc52xx_get_xtal_freq(struct device_node *node)
/* Returns the frequency of the external oscillator clock connected to the SYS_XTAL_IN pin, or 0 if it cannot be determined. */ unsigned int mpc52xx_get_xtal_freq(struct device_node *node)
{ u32 val; unsigned int freq; if (!mpc52xx_cdm) return 0; freq = mpc5xxx_get_bus_frequency(node); if (!freq) return 0; if (in_8(&mpc52xx_cdm->ipb_clk_sel) & 0x1) freq *= 2; val = in_be32(&mpc52xx_cdm->rstcfg); if (val & (1 << 5)) freq *= 8; else freq *= 4; if (val & (1 << 6)) freq /= 12; else freq /= 16; return freq; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Given a number and NULL address, return the num'th entry in the device table, if any. Given an address and num == -1, search the device table for a device with that address and return if it's still present. Given both, return the num'th driver only if its address matches. Return error code if not. */
struct mtd_info* get_mtd_device(struct mtd_info *mtd, int num)
/* Given a number and NULL address, return the num'th entry in the device table, if any. Given an address and num == -1, search the device table for a device with that address and return if it's still present. Given both, return the num'th driver only if its address matches. Return error code if not. */ struct mtd_info* get_mtd_device(struct mtd_info *mtd, int num)
{ struct mtd_info *ret = NULL; int i, err = -ENODEV; if (num == -1) { for (i = 0; i < MAX_MTD_DEVICES; i++) if (mtd_table[i] == mtd) ret = mtd_table[i]; } else if (num < MAX_MTD_DEVICES) { ret = mtd_table[num]; if (mtd && mtd != ret) ret = NULL; } if (!ret) goto out_unlock; ret->usecount++; return ret; out_unlock: return ERR_PTR(err); }
EmcraftSystems/u-boot
C++
Other
181
/* Registers an interrupt handler for the watchdog timer interrupt. */
void WatchdogIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
/* Registers an interrupt handler for the watchdog timer interrupt. */ void WatchdogIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
{ ASSERT((ui32Base == WATCHDOG0_BASE) || (ui32Base == WATCHDOG1_BASE)); IntRegister(INT_WATCHDOG_BLIZZARD, pfnHandler); IntEnable(INT_WATCHDOG_BLIZZARD); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* This routine is invoked to teardown the bootstrap mailbox region and release all host resources. This routine requires the caller to ensure all mailbox commands recovered, no additional mailbox comands are sent, and interrupts are disabled before calling this routine. */
static void lpfc_destroy_bootstrap_mbox(struct lpfc_hba *)
/* This routine is invoked to teardown the bootstrap mailbox region and release all host resources. This routine requires the caller to ensure all mailbox commands recovered, no additional mailbox comands are sent, and interrupts are disabled before calling this routine. */ static void lpfc_destroy_bootstrap_mbox(struct lpfc_hba *)
{ dma_free_coherent(&phba->pcidev->dev, phba->sli4_hba.bmbx.bmbx_size, phba->sli4_hba.bmbx.dmabuf->virt, phba->sli4_hba.bmbx.dmabuf->phys); kfree(phba->sli4_hba.bmbx.dmabuf); memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); }
robutest/uclinux
C++
GPL-2.0
60
/* MCU decoding for DC successive approximation refinement scan. Note: we assume such scans can be multi-component, although the spec is not very clear on the point. */
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
/* MCU decoding for DC successive approximation refinement scan. Note: we assume such scans can be multi-component, although the spec is not very clear on the point. */ decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; JCOEF p1; int blkn; BITREAD_STATE_VARS; if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } BITREAD_LOAD_STATE(cinfo, entropy->bitstate); p1 = 1 << cinfo->Al; for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { CHECK_BIT_BUFFER(br_state, 1, return FALSE); if (GET_BITS(1)) MCU_data[blkn][0][0] |= p1; } BITREAD_SAVE_STATE(cinfo, entropy->bitstate); if (cinfo->restart_interval) entropy->restarts_to_go--; return TRUE; }
xboot/xboot
C++
MIT License
779
/* Write Status Register. The WRSR instruction is for changing the values of Status Register Bits (and configuration register). */
enum status_code mx25v_write_status(uint8_t value)
/* Write Status Register. The WRSR instruction is for changing the values of Status Register Bits (and configuration register). */ enum status_code mx25v_write_status(uint8_t value)
{ enum status_code status; uint8_t tx_buf[2] = {MX25V_CMD_WRSR, value}; if (_mx25v_is_flash_busy()) { return STATUS_BUSY; } _mx25v_send_cmd_write_latch(MX25V_CMD_WREN); _mx25v_chip_select(); status = spi_write_buffer_wait(&_mx25v_spi, tx_buf, 2); if (status != STATUS_OK) { return STATUS_ERR_IO; } _mx25v_chip_deselect(); if (!_mx25v_wait_flash_ready(MX25V_WAIT_TIMEOUT)) { return STATUS_ERR_IO; } return STATUS_OK; }
memfault/zero-to-main
C++
null
200
/* Returns 0 if a subject with the object's smack could write to the task, an error code otherwise. */
static int smack_file_send_sigiotask(struct task_struct *tsk, struct fown_struct *fown, int signum)
/* Returns 0 if a subject with the object's smack could write to the task, an error code otherwise. */ static int smack_file_send_sigiotask(struct task_struct *tsk, struct fown_struct *fown, int signum)
{ struct file *file; int rc; char *tsp = tsk->cred->security; struct smk_audit_info ad; file = container_of(fown, struct file, f_owner); rc = smk_access(file->f_security, tsp, MAY_WRITE, NULL); if (rc != 0 && has_capability(tsk, CAP_MAC_OVERRIDE)) rc = 0; smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK); smk_ad_setfield_u_tsk(&ad, tsk); smack_log(file->f_security, tsp, MAY_WRITE, rc, &ad); return rc; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable IO compensation mechanism By default the I/O compensation cell is not used. However when the I/O output buffer speed is configured in 50 MHz mode and above, it is recommended to use the compensation cell for a slew rate control on I/O tf(IO)out/tr(IO)out commutation to reduce the I/O noise on the power supply. */
HAL_StatusTypeDef HAL_SYSCFG_EnableIOCompensation(void)
/* Enable IO compensation mechanism By default the I/O compensation cell is not used. However when the I/O output buffer speed is configured in 50 MHz mode and above, it is recommended to use the compensation cell for a slew rate control on I/O tf(IO)out/tr(IO)out commutation to reduce the I/O noise on the power supply. */ HAL_StatusTypeDef HAL_SYSCFG_EnableIOCompensation(void)
{ HAL_StatusTypeDef status = HAL_OK; __IO uint32_t count = SYSCFG_DEFAULT_TIMEOUT * (SystemCoreClock / 20U / 1000U); HAL_EnableCompensationCell(); do { if (count-- == 0U) { return HAL_TIMEOUT; } } while (__HAL_SYSCFG_CMP_CELL_GET_FLAG() == 0U); HAL_SYSCFG_CompensationCodeSelect(SYSCFG_CELL_CODE); return status; }
ua1arn/hftrx
C++
null
69
/* Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag) Purpose : remove a SCSI command from the queue for a specified target/lun/tag Params : queue - queue to remove command from target - target that we want lun - lun on device tag - tag on device Returns : struct scsi_cmnd if successful, or NULL if no command satisfies requirements */
struct scsi_cmnd* queue_remove_tgtluntag(Queue_t *queue, int target, int lun, int tag)
/* Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag) Purpose : remove a SCSI command from the queue for a specified target/lun/tag Params : queue - queue to remove command from target - target that we want lun - lun on device tag - tag on device Returns : struct scsi_cmnd if successful, or NULL if no command satisfies requirements */ struct scsi_cmnd* queue_remove_tgtluntag(Queue_t *queue, int target, int lun, int tag)
{ unsigned long flags; struct list_head *l; struct scsi_cmnd *SCpnt = NULL; spin_lock_irqsave(&queue->queue_lock, flags); list_for_each(l, &queue->head) { QE_t *q = list_entry(l, QE_t, list); if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun && q->SCpnt->tag == tag) { SCpnt = __queue_remove(queue, l); break; } } spin_unlock_irqrestore(&queue->queue_lock, flags); return SCpnt; }
robutest/uclinux
C++
GPL-2.0
60
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ length = 2 */
static gint dissect_opt_rtalert(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree, struct opt_proto_item *opt_ti, guint8 opt_len)
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ length = 2 */ static gint dissect_opt_rtalert(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree, struct opt_proto_item *opt_ti, guint8 opt_len)
{ if (opt_len != 2) { expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len, "Router alert: Invalid Length (%u bytes)", opt_len); } proto_tree_add_item(opt_tree, hf_ipv6_opt_rtalert, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; return offset; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns -1 in case of error, the index in the stack otherwise */
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
/* Returns -1 in case of error, the index in the stack otherwise */ int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{ if ((ctxt == NULL) || (value == NULL)) return(-1); if (ctxt->inputNr >= ctxt->inputMax) { ctxt->inputMax *= 2; ctxt->inputTab = (xmlParserInputPtr *) xmlRealloc(ctxt->inputTab, ctxt->inputMax * sizeof(ctxt->inputTab[0])); if (ctxt->inputTab == NULL) { xmlErrMemory(ctxt, NULL); xmlFreeInputStream(value); ctxt->inputMax /= 2; value = NULL; return (-1); } } ctxt->inputTab[ctxt->inputNr] = value; ctxt->input = value; return (ctxt->inputNr++); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the TD is targeting a low-speed device or not. */
VOID SetTDLoworFullSpeedDevice(IN TD_STRUCT *PtrTDStruct, IN BOOLEAN IsLowSpeedDevice)
/* Set the TD is targeting a low-speed device or not. */ VOID SetTDLoworFullSpeedDevice(IN TD_STRUCT *PtrTDStruct, IN BOOLEAN IsLowSpeedDevice)
{ PtrTDStruct->TDData.TDStatusLS = (IsLowSpeedDevice ? 1 : 0); }
tianocore/edk2
C++
Other
4,240
/* Function: struct scsi_cmnd *queue_remove (queue) Purpose : removes first SCSI command from a queue Params : queue - queue to remove command from Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available */
struct scsi_cmnd* queue_remove(Queue_t *queue)
/* Function: struct scsi_cmnd *queue_remove (queue) Purpose : removes first SCSI command from a queue Params : queue - queue to remove command from Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available */ struct scsi_cmnd* queue_remove(Queue_t *queue)
{ unsigned long flags; struct scsi_cmnd *SCpnt = NULL; spin_lock_irqsave(&queue->queue_lock, flags); if (!list_empty(&queue->head)) SCpnt = __queue_remove(queue, queue->head.next); spin_unlock_irqrestore(&queue->queue_lock, flags); return SCpnt; }
robutest/uclinux
C++
GPL-2.0
60
/* For synchronous operations: force any uncommitted transactions to disk. May seem kludgy, but it reuses all the handle batching code in a very simple manner. */
int jbd2_journal_force_commit(journal_t *journal)
/* For synchronous operations: force any uncommitted transactions to disk. May seem kludgy, but it reuses all the handle batching code in a very simple manner. */ int jbd2_journal_force_commit(journal_t *journal)
{ handle_t *handle; int ret; handle = jbd2_journal_start(journal, 1); if (IS_ERR(handle)) { ret = PTR_ERR(handle); } else { handle->h_sync = 1; ret = jbd2_journal_stop(handle); } return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* If Guid1 is NULL, then ASSERT(). If Guid2 is NULL, then ASSERT(). */
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
/* If Guid1 is NULL, then ASSERT(). If Guid2 is NULL, then ASSERT(). */ BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
{ ASSERT (Guid1 != NULL); ASSERT (Guid2 != NULL); return InternalMemCompareGuid (Guid1, Guid2); }
tianocore/edk2
C++
Other
4,240
/* Called when the host stop procedure has completed. */
static void ble_hs_stop_cb(int status, void *arg)
/* Called when the host stop procedure has completed. */ static void ble_hs_stop_cb(int status, void *arg)
{ ble_npl_sem_release(&ble_hs_stop_sem); }
Nicholas3388/LuaNode
C++
Other
1,055
/* Find a unique LCI for a given device. */
static unsigned int x25_new_lci(struct x25_neigh *nb)
/* Find a unique LCI for a given device. */ static unsigned int x25_new_lci(struct x25_neigh *nb)
{ unsigned int lci = 1; struct sock *sk; read_lock_bh(&x25_list_lock); while ((sk = __x25_find_socket(lci, nb)) != NULL) { sock_put(sk); if (++lci == 4096) { lci = 0; break; } } read_unlock_bh(&x25_list_lock); return lci; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* ARM PL022 exists in different 'flavors'. This drivers currently support the standard variant (0x00041022), that has a 16bit wide and 8 locations deep TX/RX FIFO. */
static int pl022_is_supported(struct pl022_spi_slave *ps)
/* ARM PL022 exists in different 'flavors'. This drivers currently support the standard variant (0x00041022), that has a 16bit wide and 8 locations deep TX/RX FIFO. */ static int pl022_is_supported(struct pl022_spi_slave *ps)
{ if ((readw(ps->base + SSP_PID0) == 0x22) && (readw(ps->base + SSP_PID1) == 0x10) && ((readw(ps->base + SSP_PID2) & 0xf) == 0x04) && (readw(ps->base + SSP_PID3) == 0x00)) return 1; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* check whether new label 'lb' matches any pending gotos in current block; solves forward jumps */
static void findgotos(LexState *ls, Labeldesc *lb)
/* check whether new label 'lb' matches any pending gotos in current block; solves forward jumps */ static void findgotos(LexState *ls, Labeldesc *lb)
{ if (luaS_eqstr(gl->arr[i].name, lb->name)) closegoto(ls, i, lb); else i++; } }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* This function builds a HOB that describes a chunk of system memory. If there is no additional space for HOB creation, then ASSERT(). */
VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
/* This function builds a HOB that describes a chunk of system memory. If there is no additional space for HOB creation, then ASSERT(). */ VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
{ EFI_HOB_RESOURCE_DESCRIPTOR *Hob; Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); ASSERT (Hob != NULL); if (Hob == NULL) { return; } Hob->ResourceType = ResourceType; Hob->ResourceAttribute = ResourceAttribute; Hob->PhysicalStart = PhysicalStart; Hob->ResourceLength = NumberOfBytes; }
tianocore/edk2
C++
Other
4,240
/* Remove node 'x' from the tree. This function shall not be called if node 'x' is not part of the tree. */
static void remove_node(br_ssl_session_cache_lru *cc, uint32_t x)
/* Remove node 'x' from the tree. This function shall not be called if node 'x' is not part of the tree. */ static void remove_node(br_ssl_session_cache_lru *cc, uint32_t x)
{ uint32_t alx, y, aly; find_node(cc, cc->store + x + SESSION_ID_OFF, &alx); y = find_replacement_node(cc, x, &aly); if (y != ADDR_NULL) { uint32_t z; z = get_left(cc, y); if (z == ADDR_NULL) { z = get_right(cc, y); } set_link(cc, aly, z); set_link(cc, alx, y); set_left(cc, y, get_left(cc, x)); set_right(cc, y, get_right(cc, x)); } else { set_link(cc, alx, ADDR_NULL); } }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Actually now I think of it, it's possible that Ron */
static bool could_be_syscall(unsigned int num)
/* Actually now I think of it, it's possible that Ron */ static bool could_be_syscall(unsigned int num)
{ return num == SYSCALL_VECTOR || num == syscall_vector; }
robutest/uclinux
C++
GPL-2.0
60
/* ti_sci_release_resource() - Release a resource from TISCI resource. @res: Pointer to the TISCI resource */
void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)
/* ti_sci_release_resource() - Release a resource from TISCI resource. @res: Pointer to the TISCI resource */ void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)
{ u16 set; for (set = 0; set < res->sets; set++) { if (res->desc[set].start <= id && (res->desc[set].num + res->desc[set].start) > id) clear_bit(id - res->desc[set].start, res->desc[set].res_map); } }
4ms/stm32mp1-baremetal
C++
Other
137
/* Registers an asynchronous callback function with the driver. Registers an asynchronous callback with the WDT driver, fired when a given criteria (such as an Early Warning) is met. Callbacks are fired once for each event. */
enum status_code wdt_register_callback(const wdt_callback_t callback, const enum wdt_callback type)
/* Registers an asynchronous callback function with the driver. Registers an asynchronous callback with the WDT driver, fired when a given criteria (such as an Early Warning) is met. Callbacks are fired once for each event. */ enum status_code wdt_register_callback(const wdt_callback_t callback, const enum wdt_callback type)
{ Assert(callback); switch (type) { case WDT_CALLBACK_EARLY_WARNING: wdt_early_warning_callback = callback; return STATUS_OK; default: Assert(false); return STATUS_ERR_INVALID_ARG; } }
memfault/zero-to-main
C++
null
200
/* Select the ACMP- input source of the comparator. */
void ACMPNegativeSrcSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulSource)
/* Select the ACMP- input source of the comparator. */ void ACMPNegativeSrcSet(unsigned long ulBase, unsigned long ulComp, unsigned long ulSource)
{ unsigned long ulCRAddr; xASSERT((ulBase == ACMP01_BASE) || (ulBase == ACMP23_BASE)); xASSERT((ulComp >= 0) && (ulComp < 2)); xASSERT((ulSource == ACMP_ASRCN_PIN) || (ulSource == ACMP_ASRCN_REF)); ulCRAddr = ulBase + ACMP_CR0 + (4 * ulComp); xHWREG(ulCRAddr) &= ~ACMP_CR_CN; xHWREG(ulCRAddr) |= ulSource; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Set the name of @mode to a standard format. */
void drm_mode_set_name(struct drm_display_mode *mode)
/* Set the name of @mode to a standard format. */ void drm_mode_set_name(struct drm_display_mode *mode)
{ snprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d", mode->hdisplay, mode->vdisplay); }
robutest/uclinux
C++
GPL-2.0
60
/* RETURNS: Pointer to allocated inode on success, NULL on failure. */
struct inode* sysfs_get_inode(struct sysfs_dirent *sd)
/* RETURNS: Pointer to allocated inode on success, NULL on failure. */ struct inode* sysfs_get_inode(struct sysfs_dirent *sd)
{ struct inode *inode; inode = iget_locked(sysfs_sb, sd->s_ino); if (inode && (inode->i_state & I_NEW)) sysfs_init_inode(sd, inode); return inode; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the TIM peripheral Main Outputs. */
void TIM_CtrlPWMOutputs(TIM_TypeDef *TIMx, FunctionalState NewState)
/* Enables or disables the TIM peripheral Main Outputs. */ void TIM_CtrlPWMOutputs(TIM_TypeDef *TIMx, FunctionalState NewState)
{ assert_param(IS_TIM_18_PERIPH(TIMx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { TIMx->BDTR |= BDTR_MOE_Set; } else { TIMx->BDTR &= BDTR_MOE_Reset; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function handles External interrupt Line 0 request. */
void EXTI0_IRQHandler(void)
/* This function handles External interrupt Line 0 request. */ void EXTI0_IRQHandler(void)
{ USART_SendData(USARTy, 0x102); while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET) { } EXTI_ClearITPendingBit(EXTI_Line0); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get the captured data from a sample sequence. */
unsigned long ADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
/* Get the captured data from a sample sequence. */ unsigned long ADCDataGet(unsigned long ulBase, unsigned long *pulBuffer)
{ unsigned long i, j; unsigned long ulSeqLen,ulChannelNo[16]; unsigned long ulWrite; xASSERT(ulBase == ADC_BASE); xASSERT(pulBuffer != 0); ulSeqLen = ((xHWREG(ulBase + ADC_CONV) & ADC_CONV_SEQL_M) >> ADC_CONV_SEQL_S) + 1; for(i = 0; i < ulSeqLen; i++) { ulChannelNo[i] = (xHWREG(ulBase + ADC_LST0 + (i/4)*4) & (0x07<<(8*(i%4)))) >> (8*(i%4)); } ulWrite = 0; for(j = 0; j < ulSeqLen; j++) { while(!ADCIntStatus(ADC_BASE, ADC_INT_END_CYCLE)); pulBuffer[ulWrite++] = xHWREG(ulBase + ADC_DR0 + ulChannelNo[j]*4) & ADC_DR0_ADD0_M; } return ulWrite; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Retreive number of DTRs available. This function can not be called from data path. ring_initial_replenishi() is the only user. */
int vxge_hw_channel_dtr_count(struct __vxge_hw_channel *channel)
/* Retreive number of DTRs available. This function can not be called from data path. ring_initial_replenishi() is the only user. */ int vxge_hw_channel_dtr_count(struct __vxge_hw_channel *channel)
{ return (channel->reserve_ptr - channel->reserve_top) + (channel->length - channel->free_ptr); }
robutest/uclinux
C++
GPL-2.0
60
/* Helper function for draw_buf_rotate_90_sqr. Given a list of four numbers, rotate the entire list to the left. */
static void draw_buf_rotate4(lv_color_t *a, lv_color_t *b, lv_color_t *c, lv_color_t *d)
/* Helper function for draw_buf_rotate_90_sqr. Given a list of four numbers, rotate the entire list to the left. */ static void draw_buf_rotate4(lv_color_t *a, lv_color_t *b, lv_color_t *c, lv_color_t *d)
{ lv_color_t tmp; tmp = *a; *a = *b; *b = *c; *c = *d; *d = tmp; }
pikasTech/PikaPython
C++
MIT License
1,403