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 |
|---|---|---|---|---|---|---|---|
/* Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 bauds and enable its transmitter and receiver. */ | static void configure_usart(void) | /* Configure USART in normal (serial rs232) mode, asynchronous, 8 bits, 1 stop bit, no parity, 115200 bauds and enable its transmitter and receiver. */
static void configure_usart(void) | {
const sam_usart_opt_t usart_console_settings = {
BOARD_USART_BAUDRATE,
US_MR_CHRL_8_BIT,
US_MR_PAR_NO,
US_MR_NBSTOP_1_BIT,
US_MR_CHMODE_NORMAL,
0
};
sysclk_enable_peripheral_clock(BOARD_ID_USART);
usart_init_rs232(BOARD_USART, &usart_console_settings,
sysclk_get_peripheral_hz());
usart_enable_tx(BOARD_USART);
usart_enable_rx(BOARD_USART);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Sets the state of saving passwords for the mount operation. */ | void g_mount_operation_set_password_save(GMountOperation *op, GPasswordSave save) | /* Sets the state of saving passwords for the mount operation. */
void g_mount_operation_set_password_save(GMountOperation *op, GPasswordSave save) | {
GMountOperationPrivate *priv;
g_return_if_fail (G_IS_MOUNT_OPERATION (op));
priv = op->priv;
if (priv->password_save != save)
{
priv->password_save = save;
g_object_notify (G_OBJECT (op), "password-save");
}
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version @hw: pointer to hardware structure @firmware_version: pointer to the PHY Firmware Version */ | s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, u16 *firmware_version) | /* ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version @hw: pointer to hardware structure @firmware_version: pointer to the PHY Firmware Version */
s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw, u16 *firmware_version) | {
s32 status = 0;
status = hw->phy.ops.read_reg(hw, TNX_FW_REV, MDIO_MMD_VEND1,
firmware_version);
return status;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* HID class driver callback function for the processing of HID reports from the host. */ | void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void *ReportData, const uint16_t ReportSize) | /* HID class driver callback function for the processing of HID reports from the host. */
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void *ReportData, const uint16_t ReportSize) | {
Device_Report_t* ReportParams = (Device_Report_t*)ReportData;
RTC_SetTimeDate(&ReportParams->TimeDate);
if (LoggingInterval500MS_SRAM != ReportParams->LogInterval500MS)
{
LoggingInterval500MS_SRAM = ReportParams->LogInterval500MS;
eeprom_update_byte(&LoggingInterval500MS_EEPROM, LoggingInterval500MS_SRAM);
}
} | prusa3d/Prusa-Firmware-Buddy | C++ | Other | 1,019 |
/* Look for possible flags for a newly added variable This is called specifically when the variable did not exist in the hash previously, so the blanket update did not find this variable. */ | void env_flags_init(struct env_entry *var_entry) | /* Look for possible flags for a newly added variable This is called specifically when the variable did not exist in the hash previously, so the blanket update did not find this variable. */
void env_flags_init(struct env_entry *var_entry) | {
const char *var_name = var_entry->key;
char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = "";
int ret = 1;
if (first_call) {
flags_list = env_get(ENV_FLAGS_VAR);
first_call = 0;
}
ret = env_flags_lookup(flags_list, var_name, flags);
if (!ret && strlen(flags))
var_entry->flags = env_parse_flags_to_bin(flags);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Return the length of the mask, the correct value is from 0 to 32. If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM. NetMask is in the host byte order. */ | INTN EFIAPI NetGetMaskLength(IN IP4_ADDR NetMask) | /* Return the length of the mask, the correct value is from 0 to 32. If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM. NetMask is in the host byte order. */
INTN EFIAPI NetGetMaskLength(IN IP4_ADDR NetMask) | {
INTN Index;
for (Index = 0; Index <= IP4_MASK_MAX; Index++) {
if (NetMask == gIp4AllMasks[Index]) {
break;
}
}
return Index;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function is to write data into transmit FIFO to send data out. */ | void SCUART_Write(SC_T *sc, uint8_t pu8TxBuf[], uint32_t u32WriteBytes) | /* This function is to write data into transmit FIFO to send data out. */
void SCUART_Write(SC_T *sc, uint8_t pu8TxBuf[], uint32_t u32WriteBytes) | {
uint32_t u32Count;
for(u32Count = 0UL; u32Count != u32WriteBytes; u32Count++)
{
while(SCUART_GET_TX_FULL(sc))
{
;
}
sc->DAT = pu8TxBuf[u32Count];
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* a3d_close() is a callback from the input close routine. */ | static void a3d_close(struct input_dev *dev) | /* a3d_close() is a callback from the input close routine. */
static void a3d_close(struct input_dev *dev) | {
struct a3d *a3d = input_get_drvdata(dev);
gameport_stop_polling(a3d->gameport);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Disable Transmit complete interrupt @rmtoll IER TCIE LL_SWPMI_DisableIT_TC. */ | void LL_SWPMI_DisableIT_TC(SWPMI_TypeDef *SWPMIx) | /* Disable Transmit complete interrupt @rmtoll IER TCIE LL_SWPMI_DisableIT_TC. */
void LL_SWPMI_DisableIT_TC(SWPMI_TypeDef *SWPMIx) | {
CLEAR_BIT(SWPMIx->IER, SWPMI_IER_TCIE);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Function to check and wait while the USB DFU is in progress. */ | void wait_for_usb_dfu(k_timeout_t delay) | /* Function to check and wait while the USB DFU is in progress. */
void wait_for_usb_dfu(k_timeout_t delay) | {
k_timepoint_t end = sys_timepoint_calc(delay);
while (!sys_timepoint_expired(end)) {
if (is_dfu_started()) {
k_poll_event_init(&dfu_event, K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY, &dfu_signal);
if (k_poll(&dfu_event, 1, K_FOREVER) != 0) {
LOG_DBG("USB DFU Error");
}
LOG_INF("USB DFU Completed");
break;
}
k_msleep(INTERMITTENT_CHECK_DELAY);
}
} | zephyrproject-rtos/zephyr | C++ | Apache License 2.0 | 9,573 |
/* This function will do USB_REQ_GET_STATUS bRequest for the device instance to get usb hub status. */ | rt_err_t rt_usbh_hub_get_status(struct uinstance *device, rt_uint32_t *buffer) | /* This function will do USB_REQ_GET_STATUS bRequest for the device instance to get usb hub status. */
rt_err_t rt_usbh_hub_get_status(struct uinstance *device, rt_uint32_t *buffer) | {
struct urequest setup;
int timeout = USB_TIMEOUT_BASIC;
RT_ASSERT(device != RT_NULL);
setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_DEVICE;
setup.bRequest = USB_REQ_GET_STATUS;
setup.wIndex = 0;
setup.wLength = 4;
setup.wValue = 0;
if(rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8)
{
if(rt_usb_hcd_pipe_xfer(device->hcd, device->pipe_ep0_in, buffer, 4, timeout) == 4)
{
return RT_EOK;
}
}
return -RT_FALSE;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Returns: one of the enum vxge_hw_status{} enumerated types. VXGE_HW_OK - for success. VXGE_HW_ERR_CRITICAL - when encounters critical error. */ | enum vxge_hw_status vxge_hw_fifo_handle_tcode(struct __vxge_hw_fifo *fifo, void *txdlh, enum vxge_hw_fifo_tcode t_code) | /* Returns: one of the enum vxge_hw_status{} enumerated types. VXGE_HW_OK - for success. VXGE_HW_ERR_CRITICAL - when encounters critical error. */
enum vxge_hw_status vxge_hw_fifo_handle_tcode(struct __vxge_hw_fifo *fifo, void *txdlh, enum vxge_hw_fifo_tcode t_code) | {
struct __vxge_hw_channel *channel;
enum vxge_hw_status status = VXGE_HW_OK;
channel = &fifo->channel;
if (((t_code & 0x7) < 0) || ((t_code & 0x7) > 0x4)) {
status = VXGE_HW_ERR_INVALID_TCODE;
goto exit;
}
fifo->stats->txd_t_code_err_cnt[t_code]++;
exit:
return status;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Check the status of the Rx buffer of the specified SPI port. */ | xtBoolean xSPIIsRxFull(unsigned long ulBase) | /* Check the status of the Rx buffer of the specified SPI port. */
xtBoolean xSPIIsRxFull(unsigned long ulBase) | {
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
return ((xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_RX_FULL)? xtrue : xfalse);
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* This function is used to get the total number of regions that are supported by the MPU, including regions that are already programmed. */ | uint32_t MPURegionCountGet(void) | /* This function is used to get the total number of regions that are supported by the MPU, including regions that are already programmed. */
uint32_t MPURegionCountGet(void) | {
return ((HWREG(NVIC_MPU_TYPE) & NVIC_MPU_TYPE_DREGION_M) >>
NVIC_MPU_TYPE_DREGION_S);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* I/O work flow to wait output buffer full in given time. */ | EFI_STATUS WaitOutputFull(IN UINTN Timeout) | /* I/O work flow to wait output buffer full in given time. */
EFI_STATUS WaitOutputFull(IN UINTN Timeout) | {
UINTN Delay;
UINT8 Data;
Delay = Timeout / 50;
do {
Data = IoRead8 (KBC_CMD_STS_PORT);
if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {
break;
}
gBS->Stall (50);
Delay--;
} while (Delay != 0);
if (Delay == 0) {
return EFI_TIMEOUT;
}
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* As we have a virtual frame buffer, we need our own mmap function */ | static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | /* As we have a virtual frame buffer, we need our own mmap function */
static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | {
unsigned long size, offset;
size = vma->vm_end - vma->vm_start;
offset = vma->vm_pgoff << PAGE_SHIFT;
if (offset + size > info->fix.smem_len)
return -EINVAL;
offset += info->fix.smem_start;
if (remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT,
size, vma->vm_page_prot))
return -EAGAIN;
dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n",
offset, vma->vm_start);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Pick up the last hashvalue from an intermediate node. */ | STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) | /* Pick up the last hashvalue from an intermediate node. */
STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) | {
xfs_da_intnode_t *node;
node = bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
if (count)
*count = be16_to_cpu(node->hdr.count);
if (!node->hdr.count)
return(0);
return be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* DMAMUX Set DMA Channel Request.
Set DMA Request Signal ID (dmamux_cxcr_dmareq_id) for given DMA channel. Request must be set before enabling and after configuring said DMA channel. */ | void dmamux_set_dma_channel_request(uint32_t dmamux, uint8_t channel, uint8_t request_id) | /* DMAMUX Set DMA Channel Request.
Set DMA Request Signal ID (dmamux_cxcr_dmareq_id) for given DMA channel. Request must be set before enabling and after configuring said DMA channel. */
void dmamux_set_dma_channel_request(uint32_t dmamux, uint8_t channel, uint8_t request_id) | {
uint32_t reg32 = DMAMUX_CxCR(dmamux, channel);
reg32 &= ~(DMAMUX_CxCR_DMAREQ_ID_MASK << DMAMUX_CxCR_DMAREQ_ID_SHIFT);
reg32 |= ((request_id & DMAMUX_CxCR_DMAREQ_ID_MASK) << DMAMUX_CxCR_DMAREQ_ID_SHIFT);
DMAMUX_CxCR(dmamux, channel) = reg32;
} | libopencm3/libopencm3 | C++ | GNU General Public License v3.0 | 2,931 |
/* keycode is expressed as follow: bit 7 - 0 key pressed, 1 = key released bits 6-0 - translated scancode set 2 */ | static void ps2_put_keycode(void *opaque, int keycode) | /* keycode is expressed as follow: bit 7 - 0 key pressed, 1 = key released bits 6-0 - translated scancode set 2 */
static void ps2_put_keycode(void *opaque, int keycode) | {
PS2KbdState *s = opaque;
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
if (!s->translate && keycode < 0xe0 && s->scancode_set > 1) {
if (keycode & 0x80) {
ps2_queue(&s->common, 0xf0);
}
if (s->scancode_set == 2) {
keycode = ps2_raw_keycode[keycode & 0x7f];
} else if (s->scancode_set == 3) {
keycode = ps2_raw_keycode_set3[keycode & 0x7f];
}
}
ps2_queue(&s->common, keycode);
} | ve3wwg/teensy3_qemu | C++ | Other | 15 |
/* Link down notification from BFA physical port module. */ | void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric) | /* Link down notification from BFA physical port module. */
void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric) | {
bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Register user interrupts callback function for the GPIO. */ | void xGPIOPinIntCallbackInit(unsigned long ulPort, unsigned long ulPin, xtEventCallback xtPortCallback) | /* Register user interrupts callback function for the GPIO. */
void xGPIOPinIntCallbackInit(unsigned long ulPort, unsigned long ulPin, xtEventCallback xtPortCallback) | {
unsigned long PinNum = PinIDToPos(ulPin);
if(GPIOA_BASE == ulPort)
{
g_psGPIOPinIntAssignTable[PinNum] = xtPortCallback;
}
else if(GPIOC_BASE == ulPort)
{
PinNum += 32;
g_psGPIOPinIntAssignTable[PinNum] = xtPortCallback;
}
else
{
while(1);
}
} | coocox/cox | C++ | Berkeley Software Distribution (BSD) | 104 |
/* USB Device Check Data IN Format Parameters: None Return Value: TRUE - Success, FALSE - Error */ | BOOL USBD_MSC_DataInFormat(void) | /* USB Device Check Data IN Format Parameters: None Return Value: TRUE - Success, FALSE - Error */
BOOL USBD_MSC_DataInFormat(void) | {
if (USBD_MSC_CBW.dDataLength == 0) {
USBD_MSC_CSW.bStatus = CSW_PHASE_ERROR;
USBD_MSC_SetCSW();
return (__FALSE);
}
if ((USBD_MSC_CBW.bmFlags & 0x80) == 0) {
USBD_MSC_SetStallEP(usbd_msc_ep_bulkout);
USBD_MSC_CSW.bStatus = CSW_PHASE_ERROR;
USBD_MSC_SetCSW();
return (__FALSE);
}
return (__TRUE);
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* Check register-stack level, keeping track of its maximum size in field 'maxstacksize' */ | void luaK_checkstack(FuncState *fs, int n) | /* Check register-stack level, keeping track of its maximum size in field 'maxstacksize' */
void luaK_checkstack(FuncState *fs, int n) | {
if (newstack >= MAXREGS)
luaX_syntaxerror(fs->ls,
"function or expression needs too many registers");
fs->f->maxstacksize = cast_byte(newstack);
}
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Returns the ETH DMA Rx descriptor frame length. */ | uint32_t ETH_ReadDMARxDescFrameLength(ETH_DMADescConfig_T *DMARxDesc) | /* Returns the ETH DMA Rx descriptor frame length. */
uint32_t ETH_ReadDMARxDescFrameLength(ETH_DMADescConfig_T *DMARxDesc) | {
return ((DMARxDesc->Status & ETH_DMARXDESC_FL) >> ETH_DMARXDESC_FRAME_LENGTHSHIFT);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* fill out the sys_info struct containing selected parameters about the machine */ | static int API_get_sys_info(va_list ap) | /* fill out the sys_info struct containing selected parameters about the machine */
static int API_get_sys_info(va_list ap) | {
struct sys_info *si;
si = (struct sys_info *)va_arg(ap, uintptr_t);
if (si == NULL)
return API_ENOMEM;
return (platform_sys_info(si)) ? 0 : API_ENODEV;
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* The handler for the high priority timer interrupt. */ | static void prvPortHighFrequencyTimerHandler(int iArg) __attribute__((longcall)) | /* The handler for the high priority timer interrupt. */
static void prvPortHighFrequencyTimerHandler(int iArg) __attribute__((longcall)) | {
static volatile unsigned long ulExecutionCounter = 0UL;
unsigned long ulHigherPriorityTaskWoken = pdFALSE;
( void ) iArg;
STM_ISRR.reg = 1UL << 2UL;
STM_CMP1.reg += ulCompareMatchValue;
ulExecutionCounter++;
if( ulExecutionCounter >= ulInterruptsPer10ms )
{
ulExecutionCounter = xSemaphoreGiveFromISR( xHighFrequencyTimerSemaphore, &ulHigherPriorityTaskWoken );
configASSERT( ulExecutionCounter == pdTRUE );
ulExecutionCounter = 0UL;
}
portYIELD_FROM_ISR( ulHigherPriorityTaskWoken );
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / GET DESCRIPTOR */ | proto_item* dissect_usb_descriptor_header(proto_tree *tree, tvbuff_t *tvb, int offset, value_string_ext *type_val_str) | /* These dissectors are used to dissect the setup part and the data for URB_CONTROL_INPUT / GET DESCRIPTOR */
proto_item* dissect_usb_descriptor_header(proto_tree *tree, tvbuff_t *tvb, int offset, value_string_ext *type_val_str) | {
guint8 desc_type;
proto_item *length_item;
proto_item *type_item;
length_item = proto_tree_add_item(tree, hf_usb_bLength,
tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
desc_type = tvb_get_guint8(tvb, offset);
type_item = proto_tree_add_item(tree, hf_usb_bDescriptorType,
tvb, offset, 1, ENC_LITTLE_ENDIAN);
if (!type_val_str)
type_val_str = &std_descriptor_type_vals_ext;
proto_item_append_text(type_item, " (%s)",
val_to_str_ext(desc_type, type_val_str, "unknown"));
return length_item;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Initialize an input device driver with default values. It is used to surly have known values in the fields ant not memory junk. After it you can set the fields. */ | void lv_indev_drv_init(lv_indev_drv_t *driver) | /* Initialize an input device driver with default values. It is used to surly have known values in the fields ant not memory junk. After it you can set the fields. */
void lv_indev_drv_init(lv_indev_drv_t *driver) | {
driver->read = NULL;
driver->type = LV_INDEV_TYPE_NONE;
driver->user_data = NULL;
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* Decimation of read operation on Slave 0 starting from the sensor hub trigger.. */ | int32_t lsm6dsl_sh_slave_0_dec_set(stmdev_ctx_t *ctx, lsm6dsl_slave0_rate_t val) | /* Decimation of read operation on Slave 0 starting from the sensor hub trigger.. */
int32_t lsm6dsl_sh_slave_0_dec_set(stmdev_ctx_t *ctx, lsm6dsl_slave0_rate_t val) | {
lsm6dsl_slave0_config_t slave0_config;
int32_t ret;
ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_BANK_A);
if(ret == 0){
ret = lsm6dsl_read_reg(ctx, LSM6DSL_SLAVE0_CONFIG,
(uint8_t*)&slave0_config, 1);
if(ret == 0){
slave0_config.slave0_rate = (uint8_t) val;
ret = lsm6dsl_write_reg(ctx, LSM6DSL_SLAVE0_CONFIG,
(uint8_t*)&slave0_config, 1);
if(ret == 0){
ret = lsm6dsl_mem_bank_set(ctx, LSM6DSL_USER_BANK);
}
}
}
return ret;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Clear __GFP_FS when allocating the page to avoid recursion into the fs and deadlock against the caller's locked page. */ | struct page* grab_cache_page_nowait(struct address_space *mapping, pgoff_t index) | /* Clear __GFP_FS when allocating the page to avoid recursion into the fs and deadlock against the caller's locked page. */
struct page* grab_cache_page_nowait(struct address_space *mapping, pgoff_t index) | {
struct page *page = find_get_page(mapping, index);
if (page) {
if (trylock_page(page))
return page;
page_cache_release(page);
return NULL;
}
page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~__GFP_FS);
if (page && add_to_page_cache_lru(page, mapping, index, GFP_NOFS)) {
page_cache_release(page);
page = NULL;
}
return page;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */ | void SDL_DitherColors(SDL_Color *colors, int bpp) | /* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */
void SDL_DitherColors(SDL_Color *colors, int bpp) | {
int i;
if (bpp != 8)
return;
for (i = 0; i < 256; i++) {
int r, g, b;
r = i & 0xe0;
r |= r >> 3 | r >> 6;
colors[i].r = r;
g = (i << 3) & 0xe0;
g |= g >> 3 | g >> 6;
colors[i].g = g;
b = i & 0x3;
b |= b << 2;
b |= b << 4;
colors[i].b = b;
colors[i].a = SDL_ALPHA_OPAQUE;
}
} | alibaba/AliOS-Things | C++ | Apache License 2.0 | 4,536 |
/* Free an allocated DMA resource.
This function will free an allocated DMA resource. */ | enum status_code dma_free(struct dma_resource *resource) | /* Free an allocated DMA resource.
This function will free an allocated DMA resource. */
enum status_code dma_free(struct dma_resource *resource) | {
Assert(resource);
Assert(resource->channel_id != DMA_INVALID_CHANNEL);
system_interrupt_enter_critical_section();
if (dma_is_busy(resource)) {
system_interrupt_leave_critical_section();
return STATUS_BUSY;
}
if (!(_dma_inst.allocated_channels & (1 << resource->channel_id))) {
system_interrupt_leave_critical_section();
return STATUS_ERR_NOT_INITIALIZED;
}
_dma_release_channel(resource->channel_id);
_dma_active_resource[resource->channel_id] = NULL;
system_interrupt_leave_critical_section();
return STATUS_OK;
} | memfault/zero-to-main | C++ | null | 200 |
/* Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance) */ | NMI_API sint8 m2m_wifi_enable_firmware_logs(uint8 u8Enable) | /* Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance) */
NMI_API sint8 m2m_wifi_enable_firmware_logs(uint8 u8Enable) | {
sint8 ret = M2M_SUCCESS;
tstrM2mEnableLogs strM2mEnableLogs;
strM2mEnableLogs.u8Enable = u8Enable;
ret = hif_send(M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_ENABLE_LOGS, (uint8*)&strM2mEnableLogs,sizeof(tstrM2mEnableLogs), NULL, 0, 0);
return ret;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Units handling. Caller must protect concurrent access by holding all_ppp_mutex */ | static int unit_set(struct idr *p, void *ptr, int n) | /* Units handling. Caller must protect concurrent access by holding all_ppp_mutex */
static int unit_set(struct idr *p, void *ptr, int n) | {
int unit, err;
again:
if (!idr_pre_get(p, GFP_KERNEL)) {
printk(KERN_ERR "PPP: No free memory for idr\n");
return -ENOMEM;
}
err = idr_get_new_above(p, ptr, n, &unit);
if (err == -EAGAIN)
goto again;
if (unit != n) {
idr_remove(p, unit);
return -EINVAL;
}
return unit;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* lookup and return any extent before 'file_offset'. NULL is returned if none is found */ | struct btrfs_ordered_extent* btrfs_lookup_first_ordered_extent(struct inode *inode, u64 file_offset) | /* lookup and return any extent before 'file_offset'. NULL is returned if none is found */
struct btrfs_ordered_extent* btrfs_lookup_first_ordered_extent(struct inode *inode, u64 file_offset) | {
struct btrfs_ordered_inode_tree *tree;
struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL;
tree = &BTRFS_I(inode)->ordered_tree;
mutex_lock(&tree->mutex);
node = tree_search(tree, file_offset);
if (!node)
goto out;
entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
atomic_inc(&entry->refs);
out:
mutex_unlock(&tree->mutex);
return entry;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base Pointer to FLEXIO_CAMERA_Type structure return FlexIO shifter status flags arg FLEXIO_SHIFTSTAT_SSF_MASK arg 0 */ | uint32_t FLEXIO_CAMERA_GetStatusFlags(FLEXIO_CAMERA_Type *base) | /* param base Pointer to FLEXIO_CAMERA_Type structure return FlexIO shifter status flags arg FLEXIO_SHIFTSTAT_SSF_MASK arg 0 */
uint32_t FLEXIO_CAMERA_GetStatusFlags(FLEXIO_CAMERA_Type *base) | {
uint32_t status = 0;
status = ((FLEXIO_GetShifterStatusFlags(base->flexioBase) >> (base->shifterStartIdx)) &
((1U << (base->shifterCount)) - 1U));
return status;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* Return if there is touches detected or not. Try to detect new touches and forget the old ones (reset internal global variables). */ | uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr) | /* Return if there is touches detected or not. Try to detect new touches and forget the old ones (reset internal global variables). */
uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr) | {
volatile uint8_t nbTouch = 0;
nbTouch = TS_IO_Read(DeviceAddr, FT6206_TD_STAT_REG);
nbTouch &= FT6206_TD_STAT_MASK;
if(nbTouch > FT6206_MAX_DETECTABLE_TOUCH)
{
nbTouch = 0;
}
ft6x06_handle.currActiveTouchNb = nbTouch;
ft6x06_handle.currActiveTouchIdx = 0;
return(nbTouch);
} | STMicroelectronics/STM32CubeF4 | C++ | Other | 789 |
/* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */ | int32_t lsm6dso_filter_settling_mask_get(lsm6dso_ctx_t *ctx, uint8_t *val) | /* Mask DRDY on pin (both XL & Gyro) until filter settling ends (XL and Gyro independently masked).. */
int32_t lsm6dso_filter_settling_mask_get(lsm6dso_ctx_t *ctx, uint8_t *val) | {
lsm6dso_ctrl4_c_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL4_C, (uint8_t*)®, 1);
*val = reg.drdy_mask;
return ret;
} | alexander-g-dean/ESF | C++ | null | 41 |
/* Stops the TIM Output Compare signal generation in interrupt mode. */ | static void SINGLE_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t tim_it) | /* Stops the TIM Output Compare signal generation in interrupt mode. */
static void SINGLE_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t tim_it) | {
assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
__HAL_TIM_DISABLE_IT(htim, tim_it);
TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
if(IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
{
htim->Instance->BDTR &= ~(TIM_BDTR_MOE);
}
htim->Instance->BDTR &= ~(TIM_BDTR_MOE);
} | st-one/X-CUBE-USB-PD | C++ | null | 110 |
/* This function builds the Ip6 configdata from the Udp6ConfigData. */ | VOID Udp6BuildIp6ConfigData(IN EFI_UDP6_CONFIG_DATA *Udp6ConfigData, IN OUT EFI_IP6_CONFIG_DATA *Ip6ConfigData) | /* This function builds the Ip6 configdata from the Udp6ConfigData. */
VOID Udp6BuildIp6ConfigData(IN EFI_UDP6_CONFIG_DATA *Udp6ConfigData, IN OUT EFI_IP6_CONFIG_DATA *Ip6ConfigData) | {
CopyMem (
Ip6ConfigData,
&mIp6IoDefaultIpConfigData,
sizeof (EFI_IP6_CONFIG_DATA)
);
Ip6ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP;
Ip6ConfigData->AcceptPromiscuous = Udp6ConfigData->AcceptPromiscuous;
IP6_COPY_ADDRESS (&Ip6ConfigData->StationAddress, &Udp6ConfigData->StationAddress);
IP6_COPY_ADDRESS (&Ip6ConfigData->DestinationAddress, &Udp6ConfigData->RemoteAddress);
Ip6ConfigData->ReceiveTimeout = (UINT32)(-1);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* If anything is wrong, return -1, since -1 is not a valid string length. Else, return the number of chars processed. */ | static guint16 proto_add_icq_attr(proto_tree *tree, tvbuff_t *tvb, const int offset, const int *hf) | /* If anything is wrong, return -1, since -1 is not a valid string length. Else, return the number of chars processed. */
static guint16 proto_add_icq_attr(proto_tree *tree, tvbuff_t *tvb, const int offset, const int *hf) | {
guint16 len;
len = tvb_get_letohs(tvb, offset);
if (len > tvb_reported_length_remaining(tvb, offset))
return -1;
proto_tree_add_string(tree, *hf, tvb, offset, len+2,
tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 2, len, ENC_ASCII));
return len + 2;
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as: 000: 10 001: 11 010: 12 011: invalid 100: 14 101: 15 110: invalid 111: invalid */ | static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev) | /* The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as: 000: 10 001: 11 010: 12 011: invalid 100: 14 101: 15 110: invalid 111: invalid */
static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev) | {
unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
if ((chip_irq == 13) || (chip_irq > 15))
return 0;
return chip_irq;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Returns the last data output value of the selected DAC channel. */ | uint16_t DAC_GetOutputDataVal(uint32_t DAC_Channel) | /* Returns the last data output value of the selected DAC channel. */
uint16_t DAC_GetOutputDataVal(uint32_t DAC_Channel) | {
__IO uint32_t tmp = 0;
assert_param(IS_DAC_CHANNEL(DAC_Channel));
tmp = (uint32_t)DAC_BASE;
tmp += DATO1_OFFSET + ((uint32_t)DAC_Channel >> 2);
return (uint16_t)(*(__IO uint32_t*)tmp);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function is called when mounting to erase orphans from the previous session. If UBIFS was not unmounted cleanly, then the inodes recorded as orphans are deleted. */ | int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only) | /* This function is called when mounting to erase orphans from the previous session. If UBIFS was not unmounted cleanly, then the inodes recorded as orphans are deleted. */
int ubifs_mount_orphans(struct ubifs_info *c, int unclean, int read_only) | {
int err = 0;
c->max_orphans = tot_avail_orphs(c);
if (!read_only) {
c->orph_buf = vmalloc(c->leb_size);
if (!c->orph_buf)
return -ENOMEM;
}
if (unclean)
err = kill_orphans(c);
else if (!read_only)
err = ubifs_clear_orphans(c);
return err;
} | EmcraftSystems/u-boot | C++ | Other | 181 |
/* Returns the total number of entries in the ring buffer (all CPU entries) */ | unsigned long ring_buffer_entries(struct ring_buffer *buffer) | /* Returns the total number of entries in the ring buffer (all CPU entries) */
unsigned long ring_buffer_entries(struct ring_buffer *buffer) | {
struct ring_buffer_per_cpu *cpu_buffer;
unsigned long entries = 0;
int cpu;
for_each_buffer_cpu(buffer, cpu) {
cpu_buffer = buffer->buffers[cpu];
entries += (local_read(&cpu_buffer->entries) -
local_read(&cpu_buffer->overrun)) - cpu_buffer->read;
}
return entries;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */ | EFI_STATUS EFIAPI SdBlockIoPeimGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo) | /* This function will provide the caller with the specified block device's media information. If the media changes, calling this function will update the media information accordingly. */
EFI_STATUS EFIAPI SdBlockIoPeimGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo) | {
SD_PEIM_HC_PRIVATE_DATA *Private;
Private = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This);
if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) || (DeviceIndex > SD_PEIM_MAX_SLOTS)) {
return EFI_INVALID_PARAMETER;
}
MediaInfo->DeviceType = SD;
MediaInfo->MediaPresent = TRUE;
MediaInfo->LastBlock = (UINTN)Private->Slot[DeviceIndex - 1].Media.LastBlock;
MediaInfo->BlockSize = Private->Slot[DeviceIndex - 1].Media.BlockSize;
return EFI_SUCCESS;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* The strnlen() function returns the number of characters in the string pointed to by s, excluding the terminating null byte ('\0'), but at most maxlen. In doing this, strnlen() looks only at the first maxlen characters in the string pointed to by s and never beyond s+maxlen. */ | rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen) | /* The strnlen() function returns the number of characters in the string pointed to by s, excluding the terminating null byte ('\0'), but at most maxlen. In doing this, strnlen() looks only at the first maxlen characters in the string pointed to by s and never beyond s+maxlen. */
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen) | {
const char *sc;
for (sc = s; *sc != '\0' && (rt_ubase_t)(sc - s) < maxlen; ++sc)
;
return sc - s;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Compare one source clock to another source clock. */ | uint32_t CGU_RealFrequencyCompare(CGU_ENTITY_T Clock, CGU_ENTITY_T CompareToClock, uint32_t *m, uint32_t *d) | /* Compare one source clock to another source clock. */
uint32_t CGU_RealFrequencyCompare(CGU_ENTITY_T Clock, CGU_ENTITY_T CompareToClock, uint32_t *m, uint32_t *d) | {
uint32_t m1, m2, d1, d2;
if ((Clock > CGU_CLKSRC_IDIVE) || (CompareToClock > CGU_CLKSRC_IDIVE)) {
return CGU_ERROR_INVALID_PARAM;
}
CGU_FrequencyMonitor(Clock, &m1, &d1);
CGU_FrequencyMonitor(CompareToClock, &m2, &d2);
*m = m1 * d2;
*d = d1 * m2;
return 0;
} | ARMmbed/DAPLink | C++ | Apache License 2.0 | 2,140 |
/* We do this to firstly avoid sleeping with the network device locked, and secondly so we can round up more than one packet to transmit which means we can try and avoid generating too many transmit done interrupts. */ | static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) | /* We do this to firstly avoid sleeping with the network device locked, and secondly so we can round up more than one packet to transmit which means we can try and avoid generating too many transmit done interrupts. */
static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) | {
struct ks8851_net *ks = netdev_priv(dev);
unsigned needed = calc_txlen(skb->len);
netdev_tx_t ret = NETDEV_TX_OK;
if (netif_msg_tx_queued(ks))
ks_dbg(ks, "%s: skb %p, %d@%p\n", __func__,
skb, skb->len, skb->data);
spin_lock(&ks->statelock);
if (needed > ks->tx_space) {
netif_stop_queue(dev);
ret = NETDEV_TX_BUSY;
} else {
ks->tx_space -= needed;
skb_queue_tail(&ks->txq, skb);
}
spin_unlock(&ks->statelock);
schedule_work(&ks->tx_work);
return ret;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Add a new chunk of special memory to the specified pool. */ | int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size, int nid) | /* Add a new chunk of special memory to the specified pool. */
int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size, int nid) | {
struct gen_pool_chunk *chunk;
int nbits = size >> pool->min_alloc_order;
int nbytes = sizeof(struct gen_pool_chunk) +
(nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
chunk = kmalloc_node(nbytes, GFP_KERNEL | __GFP_ZERO, nid);
if (unlikely(chunk == NULL))
return -1;
spin_lock_init(&chunk->lock);
chunk->start_addr = addr;
chunk->end_addr = addr + size;
write_lock(&pool->lock);
list_add(&chunk->next_chunk, &pool->chunks);
write_unlock(&pool->lock);
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* USBH_HID_InterfaceDeInit The function DeInit the Pipes used for the HID class. */ | USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost) | /* USBH_HID_InterfaceDeInit The function DeInit the Pipes used for the HID class. */
USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost) | { HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData;
if(HID_Handle->InPipe != 0x00)
{
USBH_ClosePipe (phost, HID_Handle->InPipe);
USBH_FreePipe (phost, HID_Handle->InPipe);
HID_Handle->InPipe = 0;
}
if(HID_Handle->OutPipe != 0x00)
{
USBH_ClosePipe(phost, HID_Handle->OutPipe);
USBH_FreePipe (phost, HID_Handle->OutPipe);
HID_Handle->OutPipe = 0;
}
if(phost->pActiveClass->pData)
{
USBH_free (phost->pActiveClass->pData);
}
return USBH_OK;
} | labapart/polymcu | C++ | null | 201 |
/* Query server portmapper for the port of a daemon program. */ | static int __init root_nfs_getport(int program, int version, int proto) | /* Query server portmapper for the port of a daemon program. */
static int __init root_nfs_getport(int program, int version, int proto) | {
struct sockaddr_in sin;
printk(KERN_NOTICE "Looking up port of RPC %d/%d on %pI4\n",
program, version, &servaddr);
set_sockaddr(&sin, servaddr, 0);
return rpcb_getport_sync(&sin, program, version, proto);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* DAC MSP Initialization This function configures the hardware resources used in this example. */ | void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) | /* DAC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) | {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(hdac->Instance==DAC1)
{
__HAL_RCC_DAC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Configure USART to work in SYNC mode and act as a master. */ | uint32_t usart_init_sync_master(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck) | /* Configure USART to work in SYNC mode and act as a master. */
uint32_t usart_init_sync_master(Usart *p_usart, const sam_usart_opt_t *p_usart_opt, uint32_t ul_mck) | {
static uint32_t ul_reg_val;
usart_reset(p_usart);
ul_reg_val = 0;
if (!p_usart_opt || usart_set_sync_master_baudrate(p_usart,
p_usart_opt->baudrate, ul_mck)) {
return 1;
}
ul_reg_val |= p_usart_opt->char_length | p_usart_opt->parity_type |
p_usart_opt->channel_mode | p_usart_opt->stop_bits;
ul_reg_val |= US_MR_USART_MODE_NORMAL | US_MR_CLKO;
p_usart->US_MR |= ul_reg_val;
return 0;
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Get the period value of the TMR4 counter. */ | uint16_t TMR4_GetPeriodValue(const CM_TMR4_TypeDef *TMR4x) | /* Get the period value of the TMR4 counter. */
uint16_t TMR4_GetPeriodValue(const CM_TMR4_TypeDef *TMR4x) | {
DDL_ASSERT(IS_TMR4_UNIT(TMR4x));
return READ_REG16(TMR4x->CPSR);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return the number of tasks in the cgroup. */ | int cgroup_task_count(const struct cgroup *cgrp) | /* Return the number of tasks in the cgroup. */
int cgroup_task_count(const struct cgroup *cgrp) | {
int count = 0;
struct cg_cgroup_link *link;
read_lock(&css_set_lock);
list_for_each_entry(link, &cgrp->css_sets, cgrp_link_list) {
count += atomic_read(&link->cg->refcount);
}
read_unlock(&css_set_lock);
return count;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Also validate snapshot exception store handovers. On success, returns 1 if this registration is a handover destination, otherwise returns 0. */ | static int register_snapshot(struct dm_snapshot *snap) | /* Also validate snapshot exception store handovers. On success, returns 1 if this registration is a handover destination, otherwise returns 0. */
static int register_snapshot(struct dm_snapshot *snap) | {
struct origin *o, *new_o = NULL;
struct block_device *bdev = snap->origin->bdev;
int r = 0;
new_o = kmalloc(sizeof(*new_o), GFP_KERNEL);
if (!new_o)
return -ENOMEM;
down_write(&_origins_lock);
r = __validate_exception_handover(snap);
if (r < 0) {
kfree(new_o);
goto out;
}
o = __lookup_origin(bdev);
if (o)
kfree(new_o);
else {
o = new_o;
INIT_LIST_HEAD(&o->snapshots);
o->bdev = bdev;
__insert_origin(o);
}
__insert_snapshot(o, snap);
out:
up_write(&_origins_lock);
return r;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function is the entry point for a UEFI Application. This function must call ProcessLibraryConstructorList(), ProcessModuleEntryPointList(), and ProcessLibraryDestructorList(). The return value from ProcessModuleEntryPointList() is returned. If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION. */ | EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | /* This function is the entry point for a UEFI Application. This function must call ProcessLibraryConstructorList(), ProcessModuleEntryPointList(), and ProcessLibraryDestructorList(). The return value from ProcessModuleEntryPointList() is returned. If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION. */
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) | {
EFI_STATUS Status;
if (_gUefiDriverRevision != 0) {
if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
return EFI_INCOMPATIBLE_VERSION;
}
}
ProcessLibraryConstructorList (ImageHandle, SystemTable);
Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);
ProcessLibraryDestructorList (ImageHandle, SystemTable);
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Wait for status ready (i.e. command done) or timeout. */ | static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) | /* Wait for status ready (i.e. command done) or timeout. */
static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) | {
register struct nand_chip *chip = mtd_to_nand(mtd);
u32 time_start;
int ret;
timeo = (CONFIG_SYS_HZ * timeo) / 1000;
time_start = get_timer(0);
while (get_timer(time_start) < timeo) {
u8 status;
ret = nand_read_data_op(chip, &status, sizeof(status), true);
if (ret)
return;
if (status & NAND_STATUS_READY)
break;
WATCHDOG_RESET();
}
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Skip a number of bytes at the start of a pbuf */ | struct pbuf* pbuf_skip(struct pbuf *in, u16_t in_offset, u16_t *out_offset) | /* Skip a number of bytes at the start of a pbuf */
struct pbuf* pbuf_skip(struct pbuf *in, u16_t in_offset, u16_t *out_offset) | {
const struct pbuf* out = pbuf_skip_const(in, in_offset, out_offset);
return LWIP_CONST_CAST(struct pbuf*, out);
} | Nicholas3388/LuaNode | C++ | Other | 1,055 |
/* Walk the EFI memory map looking for the I/O port range. There can only be one entry of this type, other I/O port ranges should be described via ACPI. */ | u64 efi_get_iobase(void) | /* Walk the EFI memory map looking for the I/O port range. There can only be one entry of this type, other I/O port ranges should be described via ACPI. */
u64 efi_get_iobase(void) | {
void *efi_map_start, *efi_map_end, *p;
efi_memory_desc_t *md;
u64 efi_desc_size;
efi_map_start = __va(ia64_boot_param->efi_memmap);
efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
efi_desc_size = ia64_boot_param->efi_memdesc_size;
for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
md = p;
if (md->type == EFI_MEMORY_MAPPED_IO_PORT_SPACE) {
if (md->attribute & EFI_MEMORY_UC)
return md->phys_addr;
}
}
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* @discussion This function tells the engine that it has finished the frame data and GPU can draw it now. It's blocked until GPU rendering done. */ | BOOL ElmFinish() | /* @discussion This function tells the engine that it has finished the frame data and GPU can draw it now. It's blocked until GPU rendering done. */
BOOL ElmFinish() | {
vg_lite_finish();
return TRUE;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Get the maximum weight of the service destinations. */ | static int ip_vs_wrr_max_weight(struct ip_vs_service *svc) | /* Get the maximum weight of the service destinations. */
static int ip_vs_wrr_max_weight(struct ip_vs_service *svc) | {
struct ip_vs_dest *dest;
int new_weight, weight = 0;
list_for_each_entry(dest, &svc->destinations, n_list) {
new_weight = atomic_read(&dest->weight);
if (new_weight > weight)
weight = new_weight;
}
return weight;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* Validates the given user key for flash erase APIs. */ | static status_t flash_check_user_key(uint32_t key) | /* Validates the given user key for flash erase APIs. */
static status_t flash_check_user_key(uint32_t key) | {
if (key != kFLASH_ApiEraseKey)
{
return kStatus_FLASH_EraseKeyError;
}
return kStatus_FLASH_Success;
} | labapart/polymcu | C++ | null | 201 |
/* Clear the AST periodic prescaler counter to zero. */ | void ast_clear_prescalar(Ast *ast) | /* Clear the AST periodic prescaler counter to zero. */
void ast_clear_prescalar(Ast *ast) | {
while (ast_is_busy(ast)) {
}
ast->AST_CR |= AST_CR_PCLR;
while (ast_is_busy(ast)) {
}
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Clears the module OCP socket ENAWAKEUP bit to prevent the module from sending wakeups to the PRCM. Eventually this should clear PRCM wakeup registers to cause the PRCM to ignore wakeup events from the module. Does not set any wakeup routing registers beyond this point - if the module is to wake up any other module or subsystem, that must be set separately. Called by omap_device code. Returns -EINVAL on error or 0 upon success. */ | int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | /* Clears the module OCP socket ENAWAKEUP bit to prevent the module from sending wakeups to the PRCM. Eventually this should clear PRCM wakeup registers to cause the PRCM to ignore wakeup events from the module. Does not set any wakeup routing registers beyond this point - if the module is to wake up any other module or subsystem, that must be set separately. Called by omap_device code. Returns -EINVAL on error or 0 upon success. */
int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | {
if (!oh->sysconfig ||
!(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP))
return -EINVAL;
mutex_lock(&omap_hwmod_mutex);
_disable_wakeup(oh);
mutex_unlock(&omap_hwmod_mutex);
return 0;
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* ETR sync check machine check. This is called when the ETR OTE and the local clock OTE are farther apart than the ETR sync check tolerance. After a ETR sync check the clock is not in sync. The machine check is broadcasted to all cpus at the same time. */ | void etr_sync_check(void) | /* ETR sync check machine check. This is called when the ETR OTE and the local clock OTE are farther apart than the ETR sync check tolerance. After a ETR sync check the clock is not in sync. The machine check is broadcasted to all cpus at the same time. */
void etr_sync_check(void) | {
if (!etr_eacr.es)
return;
disable_sync_clock(NULL);
set_bit(ETR_EVENT_SYNC_CHECK, &etr_events);
queue_work(time_sync_wq, &etr_work);
} | EmcraftSystems/linux-emcraft | C++ | Other | 266 |
/* CAN Initialize a 16bit Message ID Mask Filter. */ | void can_filter_id_mask_16bit_init(uint32_t canport, uint32_t nr, uint16_t id1, uint16_t mask1, uint16_t id2, uint16_t mask2, uint32_t fifo, bool enable) | /* CAN Initialize a 16bit Message ID Mask Filter. */
void can_filter_id_mask_16bit_init(uint32_t canport, uint32_t nr, uint16_t id1, uint16_t mask1, uint16_t id2, uint16_t mask2, uint32_t fifo, bool enable) | {
can_filter_init(canport, nr, false, false,
((uint32_t)id1 << 16) | (uint32_t)mask1,
((uint32_t)id2 << 16) | (uint32_t)mask2, fifo, enable);
} | insane-adding-machines/unicore-mx | C++ | GNU General Public License v3.0 | 50 |
/* The LED timer callback function. This does nothing but switch off the LED defined by the mainTIMER_CONTROLLED_LED constant. */ | static void vLEDTimerCallback(xTimerHandle xTimer) | /* The LED timer callback function. This does nothing but switch off the LED defined by the mainTIMER_CONTROLLED_LED constant. */
static void vLEDTimerCallback(xTimerHandle xTimer) | {
ulGPIOState |= mainTIMER_CONTROLLED_LED;
MSS_GPIO_set_outputs( ulGPIOState );
} | apopple/Pandaboard-FreeRTOS | C++ | null | 25 |
/* Draws a single pixel at the specified X/Y location. */ | void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) | /* Draws a single pixel at the specified X/Y location. */
void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) | {
if ((x >= lcdGetWidth()) || (y >= lcdGetHeight())) return;
hx8347gSetCursor(x,y);
hx8347gWriteCommand(HX8347G_CMD_SRAMWRITECONTROL);
hx8347gWriteData(color);
} | microbuilder/LPC11U_LPC13U_CodeBase | C++ | Other | 54 |
/* Check the status of the UART and gather information about any ongoing receive operations. */ | UARTDRV_Status_t UARTDRV_GetReceiveStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *itemsReceived, UARTDRV_Count_t *itemsRemaining) | /* Check the status of the UART and gather information about any ongoing receive operations. */
UARTDRV_Status_t UARTDRV_GetReceiveStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *itemsReceived, UARTDRV_Count_t *itemsRemaining) | {
UARTDRV_Buffer_t *rxBuffer = NULL;
Ecode_t retVal = ECODE_EMDRV_UARTDRV_OK;
uint32_t remaining = 0;
if (handle->rxQueue->used > 0)
{
retVal = GetTailBuffer(handle->rxQueue, &rxBuffer);
DMADRV_TransferRemainingCount(handle->rxDmaCh,
(int*)&remaining);
}
if (rxBuffer && (retVal == ECODE_EMDRV_UARTDRV_OK))
{
*itemsReceived = rxBuffer->transferCount - remaining;
*itemsRemaining = remaining;
*buffer = rxBuffer->data;
}
else
{
*itemsRemaining = 0;
*itemsReceived = 0;
*buffer = NULL;
}
return UARTDRV_GetPeripheralStatus(handle);
} | remotemcu/remcu-chip-sdks | C++ | null | 436 |
/* Redraw a single text page, e.g. to use a new font. */ | void text_page_redraw(GtkWidget *page, const char *absolute_path) | /* Redraw a single text page, e.g. to use a new font. */
void text_page_redraw(GtkWidget *page, const char *absolute_path) | {
text_page_clear(page);
text_page_set_text(page, absolute_path);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Return the hash index value for the specified address. */ | static int hash_get_index(__u8 *addr) | /* Return the hash index value for the specified address. */
static int hash_get_index(__u8 *addr) | {
int i, j, bitval;
int hash_index = 0;
for (j = 0; j < 6; j++) {
for (i = 0, bitval = 0; i < 8; i++)
bitval ^= hash_bit_value(i*6 + j, addr);
hash_index |= (bitval << j);
}
return hash_index;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Power level (octet 2)The power level field is coded as the binaryRepresentation of the "power control level", see 3GPP TS 3GPP TS 45.005. This value shall be used by the mobile station According to 3GPP TS 45.008.Range: 0 to 31. */ | static guint16 de_rr_pow_cmd(tvbuff_t *tvb, proto_tree *subtree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) | /* Power level (octet 2)The power level field is coded as the binaryRepresentation of the "power control level", see 3GPP TS 3GPP TS 45.005. This value shall be used by the mobile station According to 3GPP TS 45.008.Range: 0 to 31. */
static guint16 de_rr_pow_cmd(tvbuff_t *tvb, proto_tree *subtree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) | {
guint32 curr_offset;
curr_offset = offset;
proto_tree_add_item(subtree, hf_gsm_a_b8spare, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_epc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_fpcepc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(subtree, hf_gsm_a_rr_pow_cmd_powlev, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
curr_offset = curr_offset + 1;
return(curr_offset - offset);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* param base SPC peripheral base address. param config The pointer to spc_sram_voltage_config_t, specifies the configuration of sram voltage. */ | void SPC_SetSRAMOperateVoltage(SPC_Type *base, const spc_sram_voltage_config_t *config) | /* param base SPC peripheral base address. param config The pointer to spc_sram_voltage_config_t, specifies the configuration of sram voltage. */
void SPC_SetSRAMOperateVoltage(SPC_Type *base, const spc_sram_voltage_config_t *config) | {
assert(config != NULL);
uint32_t reg = 0UL;
reg |= SPC_SRAMCTL_VSM(config->operateVoltage);
base->SRAMCTL = reg;
if (config->requestVoltageUpdate)
{
base->SRAMCTL |= SPC_SRAMCTL_REQ_MASK;
while ((base->SRAMCTL & SPC_SRAMCTL_ACK_MASK) == 0UL)
{
;
}
base->SRAMCTL &= ~SPC_SRAMCTL_REQ_MASK;
}
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* This function returns the I2C address of a chosen SHA204 device. */ | uint8_t sha204_i2c_address(uint8_t index) | /* This function returns the I2C address of a chosen SHA204 device. */
uint8_t sha204_i2c_address(uint8_t index) | {
static uint8_t i2c_addresses[SHA204_DEVICE_COUNT] = {SHA204_I2C_DEFAULT_ADDRESS, 0xCC, 0xCE, 0xF8};
return i2c_addresses[index % SHA204_DEVICE_COUNT];
} | memfault/zero-to-main | C++ | null | 200 |
/* ioc3_set_proto - set the protocol for the port @port: port to use @proto: protocol to use */ | static int ioc3_set_proto(struct ioc3_port *port, int proto) | /* ioc3_set_proto - set the protocol for the port @port: port to use @proto: protocol to use */
static int ioc3_set_proto(struct ioc3_port *port, int proto) | {
struct port_hooks *hooks = port->ip_hooks;
switch (proto) {
default:
case PROTO_RS232:
DPRINT_CONFIG(("%s: rs232\n", __func__));
writel(0, (&port->ip_idd->vma->gppr[0]
+ hooks->rs422_select_pin));
break;
case PROTO_RS422:
DPRINT_CONFIG(("%s: rs422\n", __func__));
writel(1, (&port->ip_idd->vma->gppr[0]
+ hooks->rs422_select_pin));
break;
}
return 0;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* param base SPC peripheral base address. param count The count value, 16 bit width. */ | void SPC_SetDCDCRefreshCount(SPC_Type *base, uint16_t count) | /* param base SPC peripheral base address. param count The count value, 16 bit width. */
void SPC_SetDCDCRefreshCount(SPC_Type *base, uint16_t count) | {
uint32_t reg;
reg = base->DCDC_BURST_CFG;
reg &= ~SPC_DCDC_BURST_CFG_PULSE_REFRESH_CNT_MASK;
reg |= SPC_DCDC_BURST_CFG_PULSE_REFRESH_CNT(count);
base->DCDC_BURST_CFG = reg;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Programs a half word at a specified Option Byte Data address. */ | FMC_STATUS_T FMC_ProgramOptionByteData(uint32_t address, uint8_t data) | /* Programs a half word at a specified Option Byte Data address. */
FMC_STATUS_T FMC_ProgramOptionByteData(uint32_t address, uint8_t data) | {
FMC_STATUS_T status = FMC_STATUS_COMPLETE;
status = FMC_WaitForLastOperation(0x000B0000);
if(status == FMC_STATUS_COMPLETE)
{
FMC->OBKEY = 0x45670123;
FMC->OBKEY = 0xCDEF89AB;
FMC->CTRL2_B.OBP = BIT_SET;
*(__IOM uint16_t *)address = data;
status = FMC_WaitForLastOperation(0x000B0000);
if(status == FMC_STATUS_TIMEOUT)
{
FMC->CTRL2_B.OBP = BIT_RESET;
}
}
return status;
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* note This is an internal used function, upper layer should not use. */ | void FLEXIO_MCULCD_ClearMultiBeatsWriteConfig(FLEXIO_MCULCD_Type *base) | /* note This is an internal used function, upper layer should not use. */
void FLEXIO_MCULCD_ClearMultiBeatsWriteConfig(FLEXIO_MCULCD_Type *base) | {
uint8_t i;
uint32_t statusFlags = 0U;
base->flexioBase->TIMCTL[base->timerIndex] = 0U;
base->flexioBase->TIMCFG[base->timerIndex] = 0U;
base->flexioBase->TIMSTAT = (1U << base->timerIndex);
for (i = base->txShifterStartIndex; i <= base->txShifterEndIndex; i++)
{
base->flexioBase->SHIFTCFG[i] = 0U;
base->flexioBase->SHIFTCTL[i] = 0U;
statusFlags |= (1U << i);
}
base->flexioBase->SHIFTSTAT = statusFlags;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Registers an asynchronous callback function with the driver.
Registers an asynchronous callback with the DAC driver, fired when a callback condition occurs. */ | enum status_code dac_register_callback(struct dac_module *const module_inst, const enum dac_channel channel, const dac_callback_t callback, const enum dac_callback type) | /* Registers an asynchronous callback function with the driver.
Registers an asynchronous callback with the DAC driver, fired when a callback condition occurs. */
enum status_code dac_register_callback(struct dac_module *const module_inst, const enum dac_channel channel, const dac_callback_t callback, const enum dac_callback type) | {
Assert(module_inst);
Assert(callback);
UNUSED(channel);
if (module_inst->start_on_event == false) {
return STATUS_ERR_UNSUPPORTED_DEV;
}
if ((uint8_t)type < DAC_CALLBACK_N) {
module_inst->callback[(uint8_t)type] = callback;
return STATUS_OK;
}
return STATUS_ERR_INVALID_ARG;
} | memfault/zero-to-main | C++ | null | 200 |
/* Link a period-1 interrupt or async QH into the schedule at the correct spot in the async skeleton's list, and update the FSBR link */ | static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) | /* Link a period-1 interrupt or async QH into the schedule at the correct spot in the async skeleton's list, and update the FSBR link */
static void link_async(struct uhci_hcd *uhci, struct uhci_qh *qh) | {
struct uhci_qh *pqh;
__le32 link_to_new_qh;
list_for_each_entry_reverse(pqh, &uhci->skel_async_qh->node, node) {
if (pqh->skel <= qh->skel)
break;
}
list_add(&qh->node, &pqh->node);
qh->link = pqh->link;
wmb();
link_to_new_qh = LINK_TO_QH(qh);
pqh->link = link_to_new_qh;
if (pqh->skel < SKEL_FSBR && qh->skel >= SKEL_FSBR)
uhci->skel_term_qh->link = link_to_new_qh;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* If the pixel to be set is outside the image, this function does nothing. */ | static void draw_pixel(unsigned char *data, int width, int height, int stride, int x, int y, uint16_t r, uint16_t g, uint16_t b, uint16_t a) | /* If the pixel to be set is outside the image, this function does nothing. */
static void draw_pixel(unsigned char *data, int width, int height, int stride, int x, int y, uint16_t r, uint16_t g, uint16_t b, uint16_t a) | {
if (likely (0 <= x && 0 <= y && x < width && y < height)) {
uint32_t tr, tg, tb, ta;
ta = a;
tr = r * ta + 0x8000;
tg = g * ta + 0x8000;
tb = b * ta + 0x8000;
tr += tr >> 16;
tg += tg >> 16;
tb += tb >> 16;
*((uint32_t*) (data + y*(ptrdiff_t)stride + 4*x)) = ((ta << 16) & 0xff000000) |
((tr >> 8) & 0xff0000) | ((tg >> 16) & 0xff00) | (tb >> 24);
}
} | xboot/xboot | C++ | MIT License | 779 |
/* Convert a signed value in seconds and fractions of a second to a string, giving time in days, hours, minutes, and seconds, and put the result into a buffer. "is_nsecs" says that "frac" is nanoseconds if true and milliseconds if false. */ | static void signed_time_secs_to_str_buf(gint32 time_val, const guint32 frac, const gboolean is_nsecs, wmem_strbuf_t *buf) | /* Convert a signed value in seconds and fractions of a second to a string, giving time in days, hours, minutes, and seconds, and put the result into a buffer. "is_nsecs" says that "frac" is nanoseconds if true and milliseconds if false. */
static void signed_time_secs_to_str_buf(gint32 time_val, const guint32 frac, const gboolean is_nsecs, wmem_strbuf_t *buf) | {
if(time_val < 0){
wmem_strbuf_append_printf(buf, "-");
if(time_val == G_MININT32) {
unsigned_time_secs_to_str_buf(G_MAXUINT32, frac,
is_nsecs, buf);
} else {
unsigned_time_secs_to_str_buf(-time_val, frac,
is_nsecs, buf);
}
} else
unsigned_time_secs_to_str_buf(time_val, frac, is_nsecs, buf);
} | seemoo-lab/nexmon | C++ | GNU General Public License v3.0 | 2,330 |
/* Retrieve the list of registered multicast addresses for the bonding device and retransmit an IGMP JOIN request to the current active slave. */ | static void bond_resend_igmp_join_requests(struct bonding *bond) | /* Retrieve the list of registered multicast addresses for the bonding device and retransmit an IGMP JOIN request to the current active slave. */
static void bond_resend_igmp_join_requests(struct bonding *bond) | {
struct in_device *in_dev;
struct ip_mc_list *im;
rcu_read_lock();
in_dev = __in_dev_get_rcu(bond->dev);
if (in_dev) {
for (im = in_dev->mc_list; im; im = im->next)
ip_mc_rejoin_group(im);
}
rcu_read_unlock();
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Scan the flash and attempt to attach via fastmap */ | static void ipl_scan(struct ubi_scan_info *ubi) | /* Scan the flash and attempt to attach via fastmap */
static void ipl_scan(struct ubi_scan_info *ubi) | {
unsigned int pnum;
int res;
for (pnum = 0; pnum < UBI_FM_MAX_START; pnum++) {
res = ubi_scan_vid_hdr(ubi, ubi->blockinfo + pnum, pnum);
if (res != UBI_FASTMAP_ANCHOR)
continue;
if (!ubi->fm_enabled)
continue;
if (!ubi_scan_fastmap(ubi, NULL, pnum))
return;
memset(ubi->volinfo, 0, sizeof(ubi->volinfo));
pnum = 0;
break;
}
for (; pnum < ubi->peb_count; pnum++)
ubi_scan_vid_hdr(ubi, ubi->blockinfo + pnum, pnum);
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* Enables Frame bursting (Only in Half Duplex Mode). When enabled, GMAC allows frame bursting in GMII Half Duplex mode. Reserved in 10/100 and Full-Duplex configurations. */ | void synopGMAC_frame_burst_enable(synopGMACdevice *gmacdev) | /* Enables Frame bursting (Only in Half Duplex Mode). When enabled, GMAC allows frame bursting in GMII Half Duplex mode. Reserved in 10/100 and Full-Duplex configurations. */
void synopGMAC_frame_burst_enable(synopGMACdevice *gmacdev) | {
synopGMACSetBits(gmacdev -> MacBase, GmacConfig, GmacFrameBurst);
return;
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* @field: an initialized field @value: a colon delimited string of byte values (i.e. "1:02:3:ff") */ | int eeprom_field_update_mac(struct eeprom_field *field, char *value) | /* @field: an initialized field @value: a colon delimited string of byte values (i.e. "1:02:3:ff") */
int eeprom_field_update_mac(struct eeprom_field *field, char *value) | {
return __eeprom_field_update_bin_delim(field, value, ":");
} | 4ms/stm32mp1-baremetal | C++ | Other | 137 |
/* This reverses the effect of atmel_tc_alloc(), unmapping the I/O registers, invalidating the resource returned by that routine and making the TC available to other drivers. */ | void atmel_tc_free(struct atmel_tc *tc) | /* This reverses the effect of atmel_tc_alloc(), unmapping the I/O registers, invalidating the resource returned by that routine and making the TC available to other drivers. */
void atmel_tc_free(struct atmel_tc *tc) | {
spin_lock(&tc_list_lock);
if (tc->regs) {
iounmap(tc->regs);
release_resource(tc->iomem);
tc->regs = NULL;
tc->iomem = NULL;
}
spin_unlock(&tc_list_lock);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* This function calculates the UINT16 sum for the requested region. */ | UINT16 CalculateSum16(IN UINT16 *Buffer, IN UINTN Size) | /* This function calculates the UINT16 sum for the requested region. */
UINT16 CalculateSum16(IN UINT16 *Buffer, IN UINTN Size) | {
UINTN Index;
UINT16 Sum;
Sum = 0;
for (Index = 0; Index < Size; Index++) {
Sum = (UINT16) (Sum + Buffer[Index]);
}
return (UINT16) Sum;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* param base to FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */ | status_t FLEXIO_UART_TransferCreateHandle(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_callback_t callback, void *userData) | /* param base to FLEXIO_UART_Type structure. param handle Pointer to the flexio_uart_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range. */
status_t FLEXIO_UART_TransferCreateHandle(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_callback_t callback, void *userData) | {
assert(handle != NULL);
IRQn_Type flexio_irqs[] = FLEXIO_IRQS;
(void)memset(handle, 0, sizeof(*handle));
handle->rxState = (uint8_t)kFLEXIO_UART_RxIdle;
handle->txState = (uint8_t)kFLEXIO_UART_TxIdle;
handle->callback = callback;
handle->userData = userData;
(void)EnableIRQ(flexio_irqs[FLEXIO_UART_GetInstance(base)]);
return FLEXIO_RegisterHandleIRQ(base, handle, FLEXIO_UART_TransferHandleIRQ);
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* aend character c with ZMODEM escape sequence encoding. */ | void zsend_zdle_char(rt_uint16_t ch) | /* aend character c with ZMODEM escape sequence encoding. */
void zsend_zdle_char(rt_uint16_t ch) | {
rt_uint16_t res;
res = ch & 0377;
switch (res)
{
case 0377:
zsend_byte(res);
break;
case ZDLE:
zsend_byte(ZDLE);
res ^= 0100;
zsend_byte(res);
break;
case 021:
case 023:
case 0221:
case 0223:
zsend_byte(ZDLE);
res ^= 0100;
zsend_byte(res);
break;
default:
zsend_byte(res);
}
} | pikasTech/PikaPython | C++ | MIT License | 1,403 |
/* Drives a GPIO pin to 0 using open drain. */ | void gpio_clr_gpio_open_drain_pin(uint32_t pin) | /* Drives a GPIO pin to 0 using open drain. */
void gpio_clr_gpio_open_drain_pin(uint32_t pin) | {
volatile avr32_gpio_port_t *gpio_port = &AVR32_GPIO.port[pin >> 5];
gpio_port->ovrc = 1 << (pin & 0x1F);
gpio_port->oders = 1 << (pin & 0x1F);
gpio_port->gpers = 1 << (pin & 0x1F);
} | RT-Thread/rt-thread | C++ | Apache License 2.0 | 9,535 |
/* Return: Link-attention status in terms of base driver's coding. */ | static uint16_t lpfc_sli4_parse_latt_fault(struct lpfc_hba *phba, struct lpfc_acqe_link *acqe_link) | /* Return: Link-attention status in terms of base driver's coding. */
static uint16_t lpfc_sli4_parse_latt_fault(struct lpfc_hba *phba, struct lpfc_acqe_link *acqe_link) | {
uint16_t latt_fault;
switch (bf_get(lpfc_acqe_link_fault, acqe_link)) {
case LPFC_ASYNC_LINK_FAULT_NONE:
case LPFC_ASYNC_LINK_FAULT_LOCAL:
case LPFC_ASYNC_LINK_FAULT_REMOTE:
latt_fault = 0;
break;
default:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"0398 Invalid link fault code: x%x\n",
bf_get(lpfc_acqe_link_fault, acqe_link));
latt_fault = MBXERR_ERROR;
break;
}
return latt_fault;
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
/* Reposition the children of an object. (Called recursively) */ | static void refresh_childen_position(lv_obj_t *obj, lv_coord_t x_diff, lv_coord_t y_diff) | /* Reposition the children of an object. (Called recursively) */
static void refresh_childen_position(lv_obj_t *obj, lv_coord_t x_diff, lv_coord_t y_diff) | {
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
i->coords.x1 += x_diff;
i->coords.y1 += y_diff;
i->coords.x2 += x_diff;
i->coords.y2 += y_diff;
refresh_childen_position(i, x_diff, y_diff);
}
} | RavenSystem/esp-homekit-devices | C++ | Other | 2,577 |
/* This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private key) into the specified TLS object for TLS negotiation. */ | EFI_STATUS EFIAPI CryptoServiceTlsSetHostPrivateKeyEx(IN VOID *Tls, IN VOID *Data, IN UINTN DataSize, IN VOID *Password OPTIONAL) | /* This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private key) into the specified TLS object for TLS negotiation. */
EFI_STATUS EFIAPI CryptoServiceTlsSetHostPrivateKeyEx(IN VOID *Tls, IN VOID *Data, IN UINTN DataSize, IN VOID *Password OPTIONAL) | {
return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKeyEx, TlsSetHostPrivateKeyEx, (Tls, Data, DataSize, Password), EFI_UNSUPPORTED);
} | tianocore/edk2 | C++ | Other | 4,240 |
/* This function destory REST property EFI structure which returned in JsonToStructure(). */ | EFI_STATUS EFIAPI RestJsonStructureDestroyStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader) | /* This function destory REST property EFI structure which returned in JsonToStructure(). */
EFI_STATUS EFIAPI RestJsonStructureDestroyStruct(IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader) | {
EFI_STATUS Status;
REST_JSON_STRUCTURE_INSTANCE *Instance;
if ((This == NULL) || (RestJSonHeader == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (IsListEmpty (&mRestJsonStructureList)) {
return EFI_UNSUPPORTED;
}
Status = EFI_SUCCESS;
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
while (TRUE) {
Status = InterpreterInstanceDestoryJsonStruct (
This,
Instance,
RestJSonHeader
);
if (!EFI_ERROR (Status)) {
break;
}
if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
Status = EFI_UNSUPPORTED;
break;
}
Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
}
return Status;
} | tianocore/edk2 | C++ | Other | 4,240 |
/* Set the specified data holding register value for DAC channel1. */ | void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) | /* Set the specified data holding register value for DAC channel1. */
void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) | {
__IO uint32_t tmp = 0;
assert_param(IS_DAC_ALIGN(DAC_Align));
assert_param(IS_DAC_DATA(Data));
tmp = (uint32_t)DAC_BASE;
tmp += DHR12R1_Offset + DAC_Align;
*(__IO uint32_t *) tmp = Data;
} | ajhc/demo-cortex-m3 | C++ | null | 38 |
/* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. */ | void FLEXIO_SPI_MasterTransferAbort(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle) | /* param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. */
void FLEXIO_SPI_MasterTransferAbort(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle) | {
assert(handle != NULL);
FLEXIO_SPI_DisableInterrupts(base, (uint32_t)kFLEXIO_SPI_RxFullInterruptEnable);
FLEXIO_SPI_DisableInterrupts(base, (uint32_t)kFLEXIO_SPI_TxEmptyInterruptEnable);
handle->state = (uint32_t)kFLEXIO_SPI_Idle;
handle->rxRemainingBytes = 0;
handle->txRemainingBytes = 0;
} | eclipse-threadx/getting-started | C++ | Other | 310 |
/* set up the input pin config (depending on the given auto-pin type) */ | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, int auto_pin_type) | /* set up the input pin config (depending on the given auto-pin type) */
static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, int auto_pin_type) | {
unsigned int val = PIN_IN;
if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
unsigned int pincap;
pincap = snd_hda_query_pin_caps(codec, nid);
pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
if (pincap & AC_PINCAP_VREF_80)
val = PIN_VREF80;
else if (pincap & AC_PINCAP_VREF_50)
val = PIN_VREF50;
else if (pincap & AC_PINCAP_VREF_100)
val = PIN_VREF100;
else if (pincap & AC_PINCAP_VREF_GRD)
val = PIN_VREFGRD;
}
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
} | robutest/uclinux | C++ | GPL-2.0 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.