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
/* Configures a periodic timer to generate timer interrupt just once after certain time interval. This function initializes a periodic timer to generate a single ticks after certain time interval in millisecond */
tmrHw_INTERVAL_t tmrHw_setOneshotTimerInterval(tmrHw_ID_t timerId, tmrHw_INTERVAL_t msec)
/* Configures a periodic timer to generate timer interrupt just once after certain time interval. This function initializes a periodic timer to generate a single ticks after certain time interval in millisecond */ tmrHw_INTERVAL_t tmrHw_setOneshotTimerInterval(tmrHw_ID_t timerId, tmrHw_INTERVAL_t msec)
{ ResetTimer(timerId); pTmrHw[timerId].Control |= tmrHw_CONTROL_PERIODIC; pTmrHw[timerId].Control |= tmrHw_CONTROL_ONESHOT; return SetTimerPeriod(timerId, msec); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This is the default timeout function which does the most necessary. Upper layers can implement their own timeout function, say to free resources they have with this SCB, and then call this one at the end of their timeout function. To do this, one should initialize the ascb->timer.{function, data, expires} prior to calling the post funcion. The timer is started by the post function. */
void asd_ascb_timedout(unsigned long data)
/* This is the default timeout function which does the most necessary. Upper layers can implement their own timeout function, say to free resources they have with this SCB, and then call this one at the end of their timeout function. To do this, one should initialize the ascb->timer.{function, data, expires} prior to calling the post funcion. The timer is started by the post function. */ void asd_ascb_timedout(unsigned long data)
{ struct asd_ascb *ascb = (void *) data; struct asd_seq_data *seq = &ascb->ha->seq; unsigned long flags; ASD_DPRINTK("scb:0x%x timed out\n", ascb->scb->header.opcode); spin_lock_irqsave(&seq->pend_q_lock, flags); seq->pending--; list_del_init(&ascb->list); spin_unlock_irqrestore(&seq->pend_q_lock, flags); asd_ascb_free(ascb); }
robutest/uclinux
C++
GPL-2.0
60
/* We cannot support shared io contexts, as we have no mean to support two tasks with the same ioc in two different groups without major rework of the main cic data structures. For now we allow a task to change its cgroup only if it's the only owner of its ioc. */
static int blkiocg_can_attach(struct cgroup_subsys *subsys, struct cgroup *cgroup, struct task_struct *tsk, bool threadgroup)
/* We cannot support shared io contexts, as we have no mean to support two tasks with the same ioc in two different groups without major rework of the main cic data structures. For now we allow a task to change its cgroup only if it's the only owner of its ioc. */ static int blkiocg_can_attach(struct cgroup_subsys *subsys, struct cgroup *cgroup, struct task_struct *tsk, bool threadgroup)
{ struct io_context *ioc; int ret = 0; task_lock(tsk); ioc = tsk->io_context; if (ioc && atomic_read(&ioc->nr_tasks) > 1) ret = -EINVAL; task_unlock(tsk); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Read uncompressed id lookup table indexes from disk into memory */
__le64* squashfs_read_id_index_table(struct super_block *sb, u64 id_table_start, unsigned short no_ids)
/* Read uncompressed id lookup table indexes from disk into memory */ __le64* squashfs_read_id_index_table(struct super_block *sb, u64 id_table_start, unsigned short no_ids)
{ unsigned int length = SQUASHFS_ID_BLOCK_BYTES(no_ids); __le64 *id_table; int err; TRACE("In read_id_index_table, length %d\n", length); id_table = kmalloc(length, GFP_KERNEL); if (id_table == NULL) { ERROR("Failed to allocate id index table\n"); return ERR_PTR(-ENOMEM); } err = squashfs_read_table(sb, id_table, id_table_start, length); if (err < 0) { ERROR("unable to read id index table\n"); kfree(id_table); return ERR_PTR(err); } return id_table; }
robutest/uclinux
C++
GPL-2.0
60
/* Calculate offset of the n-th key in a btree block. */
STATIC size_t xfs_btree_key_offset(struct xfs_btree_cur *cur, int n)
/* Calculate offset of the n-th key in a btree block. */ STATIC size_t xfs_btree_key_offset(struct xfs_btree_cur *cur, int n)
{ return xfs_btree_block_len(cur) + (n - 1) * cur->bc_ops->key_len; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */
EFI_STATUS EFIAPI EfiShellRegisterGuidName(IN CONST EFI_GUID *Guid, IN CONST CHAR16 *GuidName)
/* This function is only available when the major and minor versions in the EfiShellProtocol are greater than or equal to 2 and 1, respectively. */ EFI_STATUS EFIAPI EfiShellRegisterGuidName(IN CONST EFI_GUID *Guid, IN CONST CHAR16 *GuidName)
{ return (AddNewGuidNameMapping (Guid, GuidName, NULL)); }
tianocore/edk2
C++
Other
4,240
/* If no format string is specified the Format must be NULL. */
VOID EFIAPI Dump6Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
/* If no format string is specified the Format must be NULL. */ VOID EFIAPI Dump6Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
{ Print ( (Format != NULL) ? Format : L"%c%c%c%c%c%c", Ptr[0], Ptr[1], Ptr[2], Ptr[3], Ptr[4], Ptr[5] ); }
tianocore/edk2
C++
Other
4,240
/* Function for getting the state of a flag. */
static __INLINE bool sdk_mapped_flags_get_by_index(sdk_mapped_flags_t flags, uint16_t index)
/* Function for getting the state of a flag. */ static __INLINE bool sdk_mapped_flags_get_by_index(sdk_mapped_flags_t flags, uint16_t index)
{ return ((flags & (1 << index)) != 0); }
labapart/polymcu
C++
null
201
/* A bram is used as a configuration memory cache. One frame of data can be stored in this "storage buffer". */
static void buffer_icap_set_bram(void __iomem *base_address, u32 offset, u32 data)
/* A bram is used as a configuration memory cache. One frame of data can be stored in this "storage buffer". */ static void buffer_icap_set_bram(void __iomem *base_address, u32 offset, u32 data)
{ out_be32(base_address + (offset << 2), data); }
robutest/uclinux
C++
GPL-2.0
60
/* Get the timeout period of the WatchDog Timer in microseconds. */
uint32_t wdt_get_us_timeout_period(Wdt *p_wdt, uint32_t ul_sclk)
/* Get the timeout period of the WatchDog Timer in microseconds. */ uint32_t wdt_get_us_timeout_period(Wdt *p_wdt, uint32_t ul_sclk)
{ return WDT_MR_WDV(p_wdt->WDT_MR) * WDT_SLCK_DIV / ul_sclk * 1000000; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Name the device, we use the device tree node name. This can be overwritten by MDIO class code if device-name property is present. */
static int mvmdio_bind(struct udevice *dev)
/* Name the device, we use the device tree node name. This can be overwritten by MDIO class code if device-name property is present. */ static int mvmdio_bind(struct udevice *dev)
{ if (ofnode_valid(dev->node)) device_set_name(dev, ofnode_get_name(dev->node)); return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* This function returns the output voltage of the LDO when the device is in deep-sleep mode, as specified by the control register. */
uint32_t SysCtlLDODeepSleepGet(void)
/* This function returns the output voltage of the LDO when the device is in deep-sleep mode, as specified by the control register. */ uint32_t SysCtlLDODeepSleepGet(void)
{ return(HWREG(SYSCTL_LDODPCTL)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the boards on-board LEDs. The green LED is connected to pin PA5 */
static void leds_init(void)
/* Initialize the boards on-board LEDs. The green LED is connected to pin PA5 */ static void leds_init(void)
{ RCC->AHBENR |= RCC_AHBENR_GPIOAEN; LED_GREEN_PORT->OSPEEDR |= 0x00000c00; LED_GREEN_PORT->OTYPER &= ~(0x00000020); LED_GREEN_PORT->MODER &= ~(0x00000c00); LED_GREEN_PORT->MODER |= 0x00000400; LED_GREEN_PORT->PUPDR &= ~(0x00000c00); LED_GREEN_PORT->BRR = 0x00c0; }
labapart/polymcu
C++
null
201
/* Set physical memory to a particular value when the whole region fits on one page. */
static void x86_phys_memset_page(phys_addr_t map_addr, uintptr_t offset, int c, unsigned size)
/* Set physical memory to a particular value when the whole region fits on one page. */ static void x86_phys_memset_page(phys_addr_t map_addr, uintptr_t offset, int c, unsigned size)
{ const uintptr_t window = LARGE_PAGE_SIZE; assert(window + LARGE_PAGE_SIZE < gd->relocaddr - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_STACK_SIZE); x86_phys_map_page(window, map_addr, 1); memset((void *)(window + offset), c, size); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Check the CRTC we're going to map each output to vs. its current CRTC. If they don't match, we have to disable the output and the CRTC since the driver will have to re-route things. */
static void drm_crtc_prepare_encoders(struct drm_device *dev)
/* Check the CRTC we're going to map each output to vs. its current CRTC. If they don't match, we have to disable the output and the CRTC since the driver will have to re-route things. */ static void drm_crtc_prepare_encoders(struct drm_device *dev)
{ struct drm_encoder_helper_funcs *encoder_funcs; struct drm_encoder *encoder; list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { encoder_funcs = encoder->helper_private; if (encoder->crtc == NULL) (*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF); if (encoder_funcs->get_crtc && encoder->crtc != (*encoder_funcs->get_crtc)(encoder)) (*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF); } }
robutest/uclinux
C++
GPL-2.0
60
/* HW models shall call this function to "awake the CPU" when they are raising an interrupt */
void posix_interrupt_raised(void)
/* HW models shall call this function to "awake the CPU" when they are raising an interrupt */ void posix_interrupt_raised(void)
{ nce_wake_cpu(nce_st); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Returns: 1 if in-sync, 0 if not-in-sync, -EWOULDBLOCK */
static int userspace_in_sync(struct dm_dirty_log *log, region_t region, int can_block)
/* Returns: 1 if in-sync, 0 if not-in-sync, -EWOULDBLOCK */ static int userspace_in_sync(struct dm_dirty_log *log, region_t region, int can_block)
{ int r; uint64_t region64 = region; int64_t in_sync; size_t rdata_size; struct log_c *lc = log->context; if (!can_block) return -EWOULDBLOCK; rdata_size = sizeof(in_sync); r = userspace_do_request(lc, lc->uuid, DM_ULOG_IN_SYNC, (char *)&region64, sizeof(region64), (char *)&in_sync, &rdata_size); return (r) ? 0 : (int)in_sync; }
robutest/uclinux
C++
GPL-2.0
60
/* Note: We have to give the extra credits for the caller. */
static int ocfs2_xattr_bucket_post_refcount(struct inode *inode, handle_t *handle, void *para)
/* Note: We have to give the extra credits for the caller. */ static int ocfs2_xattr_bucket_post_refcount(struct inode *inode, handle_t *handle, void *para)
{ int ret; struct ocfs2_xattr_bucket *bucket = (struct ocfs2_xattr_bucket *)para; ret = ocfs2_xattr_bucket_journal_access(handle, bucket, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { mlog_errno(ret); return ret; } ocfs2_xattr_bucket_journal_dirty(handle, bucket); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Message: ServiceURLStatMessage Opcode: 0x012f Type: RegistrationAndManagement Direction: pbx2dev VarLength: no */
static void handle_ServiceURLStatMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: ServiceURLStatMessage Opcode: 0x012f Type: RegistrationAndManagement Direction: pbx2dev VarLength: no */ static void handle_ServiceURLStatMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_serviceURLIndex, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_serviceURL, 256, ENC_ASCII|ENC_NA); ptvcursor_add(cursor, hf_skinny_serviceURLDisplayName, 40, ENC_ASCII|ENC_NA); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Sets the host clock to the highest possible frequency that is below "hz". */
void mmcsd_set_clock(struct rt_mmcsd_host *host, rt_uint32_t clk)
/* Sets the host clock to the highest possible frequency that is below "hz". */ void mmcsd_set_clock(struct rt_mmcsd_host *host, rt_uint32_t clk)
{ if (clk < host->freq_min) { rt_kprintf("clock too low\n"); } host->io_cfg.clock = clk; mmcsd_set_iocfg(host); }
armink/FreeModbus_Slave-Master-RTT-STM32
C++
Other
1,477
/* Simply check for errors and toggle the onboard LED. */
static void prvErrorChecks(void *pvParameters)
/* Simply check for errors and toggle the onboard LED. */ static void prvErrorChecks(void *pvParameters)
{ portTickType xDelay = mainNO_ERROR_DELAY; ( void ) pvParameters; for( ;; ) { vTaskDelay( xDelay ); prvMainCheckOtherTasksAreStillRunning(); if( lErrorInTask ) { xDelay = mainERROR_DELAY; } prvToggleOnBoardLED(); } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Called when a group is no longer interested in getting events. This can be used if a group is misbehaving or if for some reason a group should no longer get any filesystem events. */
void fsnotify_evict_group(struct fsnotify_group *group)
/* Called when a group is no longer interested in getting events. This can be used if a group is misbehaving or if for some reason a group should no longer get any filesystem events. */ void fsnotify_evict_group(struct fsnotify_group *group)
{ mutex_lock(&fsnotify_grp_mutex); __fsnotify_evict_group(group); mutex_unlock(&fsnotify_grp_mutex); }
robutest/uclinux
C++
GPL-2.0
60
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */
void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */ void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
{ assert(handle); SPDIF_DisableInterrupts(base, kSPDIF_TxFIFOEmpty); handle->state = kSPDIF_Idle; memset(handle->spdifQueue, 0, sizeof(spdif_transfer_t) * SPDIF_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Validate k_wakeup() Create 3 threads with main thread with priority 0 and other threads with -1, 0 ,+1 priority. Now -1 priority thread gets executed and it is made to sleep for 10 sec. Now, wake up the -1 priority thread and check if it starts executing. */
ZTEST(threads_scheduling, test_sleep_wakeup_preemptible)
/* Validate k_wakeup() Create 3 threads with main thread with priority 0 and other threads with -1, 0 ,+1 priority. Now -1 priority thread gets executed and it is made to sleep for 10 sec. Now, wake up the -1 priority thread and check if it starts executing. */ ZTEST(threads_scheduling, test_sleep_wakeup_preemptible)
{ init_prio = 0; setup_threads(); spawn_threads(10 * 1000); for (int i = 0; i < THREADS_NUM; i++) { zassert_true(tdata[i].executed == 0); } k_wakeup(tdata[0].tid); zassert_true(tdata[0].executed == 1); teardown_threads(); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Converts the Unicode string to ASCII string to a new allocated buffer. */
CHAR8* UnicodeStrDupToAsciiStr(CONST CHAR16 *String)
/* Converts the Unicode string to ASCII string to a new allocated buffer. */ CHAR8* UnicodeStrDupToAsciiStr(CONST CHAR16 *String)
{ CHAR8 *AsciiStr; UINTN BufLen; EFI_STATUS Status; BufLen = StrLen (String) + 1; AsciiStr = AllocatePool (BufLen); if (AsciiStr == NULL) { return NULL; } Status = UnicodeStrToAsciiStrS (String, AsciiStr, BufLen); if (EFI_ERROR (Status)) { return NULL; } return AsciiStr; }
tianocore/edk2
C++
Other
4,240
/* Writes the current value of MM1. This function is only available on IA32 and X64. */
VOID EFIAPI AsmWriteMm1(IN UINT64 Value)
/* Writes the current value of MM1. This function is only available on IA32 and X64. */ VOID EFIAPI AsmWriteMm1(IN UINT64 Value)
{ __asm__ __volatile__ ( "movd %0, %%mm1" : : "m" (Value) ); }
tianocore/edk2
C++
Other
4,240
/* Returns effective policy for a VMA at specified address. Falls back to @task or system default policy, as necessary. Current or other task's task mempolicy and non-shared vma policies are protected by the task's mmap_sem, which must be held for read by the caller. Shared policies require an extra reference count */
static struct mempolicy* get_vma_policy(struct task_struct *task, struct vm_area_struct *vma, unsigned long addr)
/* Returns effective policy for a VMA at specified address. Falls back to @task or system default policy, as necessary. Current or other task's task mempolicy and non-shared vma policies are protected by the task's mmap_sem, which must be held for read by the caller. Shared policies require an extra reference count */ static struct mempolicy* get_vma_policy(struct task_struct *task, struct vm_area_struct *vma, unsigned long addr)
{ struct mempolicy *pol = task->mempolicy; if (vma) { if (vma->vm_ops && vma->vm_ops->get_policy) { struct mempolicy *vpol = vma->vm_ops->get_policy(vma, addr); if (vpol) pol = vpol; } else if (vma->vm_policy) pol = vma->vm_policy; } if (!pol) pol = &default_policy; return pol; }
robutest/uclinux
C++
GPL-2.0
60
/* Requests the target to program the specified data to memory. Note that it is the responsibility of the application to make sure the memory range was erased beforehand. */
LIBOPENBLT_EXPORT uint32_t BltSessionWriteData(uint32_t address, uint32_t len, uint8_t const *data)
/* Requests the target to program the specified data to memory. Note that it is the responsibility of the application to make sure the memory range was erased beforehand. */ LIBOPENBLT_EXPORT uint32_t BltSessionWriteData(uint32_t address, uint32_t len, uint8_t const *data)
{ uint32_t result = BLT_RESULT_ERROR_GENERIC; assert(data != NULL); assert(len > 0); if ( (data != NULL) && (len > 0) ) { if (SessionWriteData(address, len, data)) { result = BLT_RESULT_OK; } } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* For use by UI code that sets preferences. */
void prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
/* For use by UI code that sets preferences. */ void prefs_set_string_like_value(pref_t *pref, const gchar *value, gboolean *changed)
{ if (*pref->varp.string) { if (strcmp(*pref->varp.string, value) != 0) { *changed = TRUE; g_free(*pref->varp.string); *pref->varp.string = g_strdup(value); } } else if (value) { *pref->varp.string = g_strdup(value); } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Command response callback function for sd_ble_gap_lesc_oob_data_get BLE command. Callback for decoding the output parameters and the command response return code. */
static uint32_t gap_lesc_oob_data_get_rsp_dec(const uint8_t *p_buffer, uint16_t length)
/* Command response callback function for sd_ble_gap_lesc_oob_data_get BLE command. Callback for decoding the output parameters and the command response return code. */ static uint32_t gap_lesc_oob_data_get_rsp_dec(const uint8_t *p_buffer, uint16_t length)
{ uint32_t result_code = 0; const uint32_t err_code = ble_gap_lesc_oob_data_get_rsp_dec(p_buffer, length, (ble_gap_lesc_oob_data_t **) &mp_out_params[0], &result_code); APP_ERROR_CHECK(err_code); return result_code; }
labapart/polymcu
C++
null
201
/* Add an extension, and all compressed versions thereof, to a GSList of extensions. */
static GSList* add_extensions(GSList *extensions, const gchar *extension, const char **compressed_file_extensions)
/* Add an extension, and all compressed versions thereof, to a GSList of extensions. */ static GSList* add_extensions(GSList *extensions, const gchar *extension, const char **compressed_file_extensions)
{ const char **compressed_file_extensionp; extensions = g_slist_append(extensions, g_strdup(extension)); for (compressed_file_extensionp = compressed_file_extensions; *compressed_file_extensionp != NULL; compressed_file_extensionp++) { extensions = g_slist_append(extensions, g_strdup_printf("%s.%s", extension, *compressed_file_extensionp)); } return extensions; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Get the setup packet buffer. This function provides the buffer for setup packet. */
usb_status_t USB_DeviceGetSetupBuffer(usb_device_handle handle, usb_setup_struct_t **setupBuffer)
/* Get the setup packet buffer. This function provides the buffer for setup packet. */ usb_status_t USB_DeviceGetSetupBuffer(usb_device_handle handle, usb_setup_struct_t **setupBuffer)
{ static uint32_t cdcVcomSetup[2]; if (NULL == setupBuffer) { return kStatus_USB_InvalidParameter; } *setupBuffer = (usb_setup_struct_t *)&cdcVcomSetup; return kStatus_USB_Success; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the NOR memory to Read mode and resets the errors in the NOR memory Status Register. */
NOR_Status NOR_Reset(void)
/* Returns the NOR memory to Read mode and resets the errors in the NOR memory Status Register. */ NOR_Status NOR_Reset(void)
{ NOR_WRITE(ADDR_SHIFT(0x00555), 0x00AA); NOR_WRITE(ADDR_SHIFT(0x002AA), 0x0055); NOR_WRITE(Bank1_NOR2_ADDR, 0x00F0); return (NOR_SUCCESS); }
avem-labs/Avem
C++
MIT License
1,752
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM16) { __HAL_RCC_TIM16_CLK_DISABLE(); } else if(htim_base->Instance==TIM17) { __HAL_RCC_TIM17_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Retrieve exception handler from IDT table by ExceptionNum. */
VOID* GetExceptionHandlerInIdtEntry(IN UINTN ExceptionNum)
/* Retrieve exception handler from IDT table by ExceptionNum. */ VOID* GetExceptionHandlerInIdtEntry(IN UINTN ExceptionNum)
{ IA32_IDT_GATE_DESCRIPTOR *IdtEntry; IA32_DESCRIPTOR IdtDescriptor; AsmReadIdtr (&IdtDescriptor); IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor.Base; return (VOID *)(IdtEntry[ExceptionNum].Bits.OffsetLow | (((UINTN)IdtEntry[ExceptionNum].Bits.OffsetHigh) << 16) | (((UINTN)IdtEntry[ExceptionNum].Bits.OffsetUpper) << 32)); }
tianocore/edk2
C++
Other
4,240
/* Return value: ibmvfc_target struct / NULL if not found */
static struct ibmvfc_target* __ibmvfc_get_target(struct scsi_target *starget)
/* Return value: ibmvfc_target struct / NULL if not found */ static struct ibmvfc_target* __ibmvfc_get_target(struct scsi_target *starget)
{ struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); struct ibmvfc_host *vhost = shost_priv(shost); struct ibmvfc_target *tgt; list_for_each_entry(tgt, &vhost->targets, queue) if (tgt->target_id == starget->id) { kref_get(&tgt->kref); return tgt; } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Command response callback function for sd_ble_gatts_sys_attr_set BLE command. Callback for decoding the command response return code. */
static uint32_t gatts_sys_attr_set_rsp_dec(const uint8_t *p_buffer, uint16_t length)
/* Command response callback function for sd_ble_gatts_sys_attr_set BLE command. Callback for decoding the command response return code. */ static uint32_t gatts_sys_attr_set_rsp_dec(const uint8_t *p_buffer, uint16_t length)
{ uint32_t result_code; const uint32_t err_code = ble_gatts_sys_attr_set_rsp_dec(p_buffer, length, &result_code); APP_ERROR_CHECK(err_code); return result_code; }
labapart/polymcu
C++
null
201
/* Enable or disable the PWR Ultra Low Power (ULP) function. */
void PWR_UltraLowPowerCmd(FunctionalState NewState)
/* Enable or disable the PWR Ultra Low Power (ULP) function. */ void PWR_UltraLowPowerCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { PWR->CSR2 |= PWR_CSR2_ULP; } else { PWR->CSR2 &= (uint8_t)(~PWR_CSR2_ULP); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* As well as checking the version compatibility this always copies the kernel interface version out. */
static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
/* As well as checking the version compatibility this always copies the kernel interface version out. */ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
{ uint32_t version[3]; int r = 0; if (copy_from_user(version, user->version, sizeof(version))) return -EFAULT; if ((DM_VERSION_MAJOR != version[0]) || (DM_VERSION_MINOR < version[1])) { DMWARN("ioctl interface mismatch: " "kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)", DM_VERSION_MAJOR, DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL, version[0], version[1], version[2], cmd); r = -EINVAL; } version[0] = DM_VERSION_MAJOR; version[1] = DM_VERSION_MINOR; version[2] = DM_VERSION_PATCHLEVEL; if (copy_to_user(user->version, version, sizeof(version))) return -EFAULT; return r; }
robutest/uclinux
C++
GPL-2.0
60
/* ccw_device_get_path_mask() - get currently available paths @cdev: ccw device to be queried Returns: %0 if no subchannel for the device is available, else the mask of currently available paths for the ccw device's subchannel. */
__u8 ccw_device_get_path_mask(struct ccw_device *cdev)
/* ccw_device_get_path_mask() - get currently available paths @cdev: ccw device to be queried Returns: %0 if no subchannel for the device is available, else the mask of currently available paths for the ccw device's subchannel. */ __u8 ccw_device_get_path_mask(struct ccw_device *cdev)
{ struct subchannel *sch; if (!cdev->dev.parent) return 0; sch = to_subchannel(cdev->dev.parent); return sch->lpm; }
robutest/uclinux
C++
GPL-2.0
60
/* Decode DTMF tones, queue result in separate sk_buf for later examination. Parameters: s = pointer to state-struct. buf = input audio data len = size of audio data. fmt = audio data format (0 = ulaw, 1 = alaw) */
void isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt)
/* Decode DTMF tones, queue result in separate sk_buf for later examination. Parameters: s = pointer to state-struct. buf = input audio data len = size of audio data. fmt = audio data format (0 = ulaw, 1 = alaw) */ void isdn_audio_calc_dtmf(modem_info *info, unsigned char *buf, int len, int fmt)
{ dtmf_state *s = info->dtmf_state; int i; int c; while (len) { c = DTMF_NPOINTS - s->idx; if (c > len) c = len; if (c <= 0) break; for (i = 0; i < c; i++) { if (fmt) s->buf[s->idx++] = isdn_audio_alaw_to_s16[*buf++] >> (15 - AMP_BITS); else s->buf[s->idx++] = isdn_audio_ulaw_to_s16[*buf++] >> (15 - AMP_BITS); } if (s->idx == DTMF_NPOINTS) { isdn_audio_goertzel(s->buf, info); s->idx = 0; } len -= c; } }
robutest/uclinux
C++
GPL-2.0
60
/* These functions return kernel virtual addresses instead of device bus addresses since the driver uses the CPU to copy data instead of using hardware DMA. */
static int ipath_mapping_error(struct ib_device *dev, u64 dma_addr)
/* These functions return kernel virtual addresses instead of device bus addresses since the driver uses the CPU to copy data instead of using hardware DMA. */ static int ipath_mapping_error(struct ib_device *dev, u64 dma_addr)
{ return dma_addr == BAD_DMA_ADDRESS; }
robutest/uclinux
C++
GPL-2.0
60
/* Returns the current operating mode for the UART transmit interrupt. */
uint32_t UARTTxIntModeGet(uint32_t ui32Base)
/* Returns the current operating mode for the UART transmit interrupt. */ uint32_t UARTTxIntModeGet(uint32_t ui32Base)
{ ASSERT(_UARTBaseValid(ui32Base)); return (HWREG(ui32Base + UART_O_CTL) & (UART_TXINT_MODE_EOT | UART_TXINT_MODE_FIFO)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* brief Return Frequency of Adc Clock return Frequency of Adc. */
uint32_t CLOCK_GetAdcClkFreq(void)
/* brief Return Frequency of Adc Clock return Frequency of Adc. */ uint32_t CLOCK_GetAdcClkFreq(void)
{ uint32_t freq = 0U; switch (SYSCON->ADCCLKSEL) { case 0U: freq = CLOCK_GetCoreSysClkFreq(); break; case 1U: freq = CLOCK_GetPll0OutFreq(); break; case 2U: freq = CLOCK_GetFroHfFreq(); break; case 7U: freq = 0U; break; default: assert(false); break; } return freq / ((SYSCON->ADCCLKDIV & SYSCON_ADCCLKDIV_DIV_MASK) + 1U); }
ARMmbed/DAPLink
C++
Apache License 2.0
2,140
/* Register the polled keys virtual device after the PCA9532 device is probed. Otherwise the */
static int ea_lpc1788_pca9532_setup(unsigned gpio, unsigned ngpio)
/* Register the polled keys virtual device after the PCA9532 device is probed. Otherwise the */ static int ea_lpc1788_pca9532_setup(unsigned gpio, unsigned ngpio)
{ if (platform_device_register(&pca9532_polled_keys) < 0) pr_err("%s: pca9532_polled_keys not registered.\n", __func__); return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Check if a color format has alpha channel or not */
bool lv_img_cf_has_alpha(lv_img_cf_t cf)
/* Check if a color format has alpha channel or not */ bool lv_img_cf_has_alpha(lv_img_cf_t cf)
{ bool has_alpha = false; switch(cf) { case LV_IMG_CF_TRUE_COLOR_ALPHA: case LV_IMG_CF_RAW_ALPHA: case LV_IMG_CF_INDEXED_1BIT: case LV_IMG_CF_INDEXED_2BIT: case LV_IMG_CF_INDEXED_4BIT: case LV_IMG_CF_INDEXED_8BIT: case LV_IMG_CF_ALPHA_1BIT: case LV_IMG_CF_ALPHA_2BIT: case LV_IMG_CF_ALPHA_4BIT: case LV_IMG_CF_ALPHA_8BIT: has_alpha = true; break; default: has_alpha = false; break; } return has_alpha; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function traces the GAS structure as described by the GasParser. */
VOID EFIAPI DumpGas(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
/* This function traces the GAS structure as described by the GasParser. */ VOID EFIAPI DumpGas(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
{ DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE)); }
tianocore/edk2
C++
Other
4,240
/* Converts a text device path node to SCSI device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextScsi(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to SCSI device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextScsi(IN CHAR16 *TextDeviceNode)
{ CHAR16 *PunStr; CHAR16 *LunStr; SCSI_DEVICE_PATH *Scsi; PunStr = GetNextParamStr (&TextDeviceNode); LunStr = GetNextParamStr (&TextDeviceNode); Scsi = (SCSI_DEVICE_PATH *)CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_SCSI_DP, (UINT16)sizeof (SCSI_DEVICE_PATH) ); Scsi->Pun = (UINT16)Strtoi (PunStr); Scsi->Lun = (UINT16)Strtoi (LunStr); return (EFI_DEVICE_PATH_PROTOCOL *)Scsi; }
tianocore/edk2
C++
Other
4,240
/* @twsi: The MVTWSI register structure to use. @expected_status: The I2C bus status expected to be asserted after the operation completion. @tick: The duration of a clock cycle at the current I2C speed. */
static int twsi_start(struct mvtwsi_registers *twsi, int expected_status, uint tick)
/* @twsi: The MVTWSI register structure to use. @expected_status: The I2C bus status expected to be asserted after the operation completion. @tick: The duration of a clock cycle at the current I2C speed. */ static int twsi_start(struct mvtwsi_registers *twsi, int expected_status, uint tick)
{ writel(MVTWSI_CONTROL_TWSIEN | MVTWSI_CONTROL_START | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control); return twsi_wait(twsi, expected_status, tick); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Returns the CRC Polynomial register value for the specified SPI. */
uint16_t SPI_GetCRCPolynomial(SPI_TypeDef *SPIx)
/* Returns the CRC Polynomial register value for the specified SPI. */ uint16_t SPI_GetCRCPolynomial(SPI_TypeDef *SPIx)
{ assert_param(IS_SPI_ALL_PERIPH(SPIx)); return SPIx->CRCPR; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Reads requested amount of data from the SPI. This function will return after reading requested amount of data */
enum status_code spi_read_buffer_wait(struct spi_module *const module, uint8_t *rx_data, uint16_t length, uint8_t dummy)
/* Reads requested amount of data from the SPI. This function will return after reading requested amount of data */ enum status_code spi_read_buffer_wait(struct spi_module *const module, uint8_t *rx_data, uint16_t length, uint8_t dummy)
{ module->tx_dummy_byte = dummy; return spi_transceive_buffer_wait(module, NULL, rx_data, length); }
memfault/zero-to-main
C++
null
200
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */
void xI2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
/* Send a master data receive request when the master have obtained control of the bus.(Write Step2) For this function returns immediately, it is always using in the interrupt hander. */ void xI2CMasterReadRequestS2(unsigned long ulBase, xtBoolean bEndTransmition)
{ xASSERT((ulBase == I2C0_BASE)); if(bEndTransmition) { xHWREG(ulBase + I2C_CON) &= ~I2C_CON_AA; I2CStopSend(ulBase); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* __vxge_hw_fifo_reset - Resets the fifo This function resets the fifo during vpath reset operation */
enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
/* __vxge_hw_fifo_reset - Resets the fifo This function resets the fifo during vpath reset operation */ enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
{ enum vxge_hw_status status = VXGE_HW_OK; __vxge_hw_fifo_abort(fifo); status = __vxge_hw_channel_reset(&fifo->channel); return status; }
robutest/uclinux
C++
GPL-2.0
60
/* Delete card's pending timers, send STOP to linklevel */
static void isdnloop_stopcard(isdnloop_card *card)
/* Delete card's pending timers, send STOP to linklevel */ static void isdnloop_stopcard(isdnloop_card *card)
{ unsigned long flags; isdn_ctrl cmd; spin_lock_irqsave(&card->isdnloop_lock, flags); if (card->flags & ISDNLOOP_FLAGS_RUNNING) { card->flags &= ~ISDNLOOP_FLAGS_RUNNING; del_timer(&card->st_timer); del_timer(&card->rb_timer); del_timer(&card->c_timer[0]); del_timer(&card->c_timer[1]); cmd.command = ISDN_STAT_STOP; cmd.driver = card->myid; card->interface.statcallb(&cmd); } spin_unlock_irqrestore(&card->isdnloop_lock, flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_parser_set_tknzr(CRParser *a_this, CRTknzr *a_tknzr)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_set_tknzr(CRParser *a_this, CRTknzr *a_tknzr)
{ g_return_val_if_fail (a_this && PRIVATE (a_this), CR_BAD_PARAM_ERROR); if (PRIVATE (a_this)->tknzr) { cr_tknzr_unref (PRIVATE (a_this)->tknzr); } PRIVATE (a_this)->tknzr = a_tknzr; if (a_tknzr) cr_tknzr_ref (a_tknzr); return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Initializes the TCP protocol handler, clearing the port and connection state tables. This must be called before TCP packets are processed. */
void TCP_Init(void)
/* Initializes the TCP protocol handler, clearing the port and connection state tables. This must be called before TCP packets are processed. */ void TCP_Init(void)
{ for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++) PortStateTable[PTableEntry].State = TCP_Port_Closed; for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++) ConnectionStateTable[CSTableEntry].State = TCP_Connection_Closed; }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Attribute write call back for the Value V5 attribute. */
static ssize_t write_value_v5(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
/* Attribute write call back for the Value V5 attribute. */ static ssize_t write_value_v5(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
{ uint8_t *value = attr->user_data; if (offset >= sizeof(value_v5_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); if (offset + len > sizeof(value_v5_value)) return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN); if (!bAuthorized) return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION); memcpy(value + offset, buf, len); return len; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Enables generator and fault interrupts for a PWM module. */
void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault)
/* Enables generator and fault interrupts for a PWM module. */ void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault)
{ ASSERT((ulBase == PWM0_BASE) || (ulBase == PWM1_BASE)); ASSERT((ulGenFault & ~(PWM_INT_GEN_0 | PWM_INT_GEN_1 | PWM_INT_GEN_2 | PWM_INT_GEN_3 | PWM_INT_FAULT0 | PWM_INT_FAULT1 | PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0); HWREG(ulBase + PWM_O_INTEN) |= ulGenFault; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set the prescaler for the specified programmable clock. */
void pmc_pck_set_prescaler(uint32_t ul_id, uint32_t ul_pres)
/* Set the prescaler for the specified programmable clock. */ void pmc_pck_set_prescaler(uint32_t ul_id, uint32_t ul_pres)
{ PMC->PMC_PCK[ul_id] = (PMC->PMC_PCK[ul_id] & ~PMC_PCK_PRES_Msk) | ul_pres; while ((PMC->PMC_SCER & (PMC_SCER_PCK0 << ul_id)) && !(PMC->PMC_SR & (PMC_SR_PCKRDY0 << ul_id))); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Draws a number of pixels of the same color to the display. */
EMSTATUS DMD_writeColor(uint16_t x, uint16_t y, uint8_t red, uint8_t green, uint8_t blue, uint32_t numPixels)
/* Draws a number of pixels of the same color to the display. */ EMSTATUS DMD_writeColor(uint16_t x, uint16_t y, uint8_t red, uint8_t green, uint8_t blue, uint32_t numPixels)
{ uint16_t color; uint16_t xStart = x; uint16_t *pixelPointer = (uint16_t *) ((uint32_t) frameBuffer + (uint32_t) ((y+dimensions.yClipStart)*dimensions.xSize*sizeof(uint16_t)) + (uint32_t) ((x+dimensions.xClipStart)*sizeof(uint16_t))); color = colorTransform24ToRGB565(red,green,blue); while(numPixels--) { x++; *pixelPointer++ = color; if (x>=dimensions.clipWidth) { x = xStart; pixelPointer = (uint16_t *) ((uint32_t) frameBuffer + (uint32_t) (((++y)+dimensions.yClipStart)*dimensions.xSize*sizeof(uint16_t)) + (uint32_t) ((xStart+dimensions.xClipStart)*sizeof(uint16_t))); } } return DMD_OK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Calculate the lease time by the algorithm defined in rfc. */
VOID Dhcp6CalculateLeaseTime(IN DHCP6_IA_CB *IaCb)
/* Calculate the lease time by the algorithm defined in rfc. */ VOID Dhcp6CalculateLeaseTime(IN DHCP6_IA_CB *IaCb)
{ UINT32 MinLt; UINT32 MaxLt; UINTN Index; ASSERT (IaCb->Ia->IaAddressCount > 0); MinLt = (UINT32)(-1); MaxLt = 0; for (Index = 0; Index < IaCb->Ia->IaAddressCount; Index++) { MinLt = MIN (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime); MaxLt = MAX (MinLt, IaCb->Ia->IaAddress[Index].ValidLifetime); } IaCb->T1 = (IaCb->T1 != 0) ? IaCb->T1 : (UINT32)(MinLt * 5 / 10); IaCb->T2 = (IaCb->T2 != 0) ? IaCb->T2 : (UINT32)(MinLt * 8 / 10); IaCb->AllExpireTime = MaxLt; IaCb->LeaseTime = 0; }
tianocore/edk2
C++
Other
4,240
/* Overwrites data length in the descriptor. This function overwrites data length in the descriptor */
void dmacHw_setDataLength(dmacHw_CONFIG_t *pConfig, void *pDescriptor, size_t dataLen)
/* Overwrites data length in the descriptor. This function overwrites data length in the descriptor */ void dmacHw_setDataLength(dmacHw_CONFIG_t *pConfig, void *pDescriptor, size_t dataLen)
{ dmacHw_DESC_t *pProg; dmacHw_DESC_t *pHead; int srcTs = 0; int srcTrSize = 0; pHead = (dmacHw_GET_DESC_RING(pDescriptor))->pHead; pProg = pHead; srcTrSize = dmacHw_GetTrWidthInBytes(pConfig->srcMaxTransactionWidth); srcTs = dataLen / srcTrSize; do { pProg->ctl.hi = srcTs & dmacHw_REG_CTL_BLOCK_TS_MASK; pProg = (dmacHw_DESC_t *) pProg->llp; } while (pProg != pHead); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to EFI_IFR_TYPE_BUFFER when do the value compare. */
BOOLEAN IsTypeInBuffer(IN EFI_HII_VALUE *Value)
/* EFI_IFR_TYPE_REF, EFI_IFR_TYPE_DATE and EFI_IFR_TYPE_TIME are converted to EFI_IFR_TYPE_BUFFER when do the value compare. */ BOOLEAN IsTypeInBuffer(IN EFI_HII_VALUE *Value)
{ if (Value == NULL) { return FALSE; } switch (Value->Type) { case EFI_IFR_TYPE_BUFFER: case EFI_IFR_TYPE_DATE: case EFI_IFR_TYPE_TIME: case EFI_IFR_TYPE_REF: return TRUE; default: return FALSE; } }
tianocore/edk2
C++
Other
4,240
/* Handler for unknown V2 protocol commands. This discards all sent data and returns a STATUS_CMD_UNKNOWN status back to the host. */
static void V2Protocol_UnknownCommand(const uint8_t V2Command)
/* Handler for unknown V2 protocol commands. This discards all sent data and returns a STATUS_CMD_UNKNOWN status back to the host. */ static void V2Protocol_UnknownCommand(const uint8_t V2Command)
{ while (Endpoint_BytesInEndpoint() == AVRISP_DATA_EPSIZE) { Endpoint_ClearOUT(); Endpoint_WaitUntilReady(); } Endpoint_ClearOUT(); Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPADDR); Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN); Endpoint_Write_8(V2Command); Endpoint_Write_8(STATUS_CMD_UNKNOWN); Endpoint_ClearIN(); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* Call func for each cic attached to this ioc. */
static void call_for_each_cic(struct io_context *ioc, void(*func)(struct io_context *, struct cfq_io_context *))
/* Call func for each cic attached to this ioc. */ static void call_for_each_cic(struct io_context *ioc, void(*func)(struct io_context *, struct cfq_io_context *))
{ rcu_read_lock(); __call_for_each_cic(ioc, func); rcu_read_unlock(); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clear the status of the specified analog watchdog flag. */
void ADC_AWD_ClearStatus(CM_ADC_TypeDef *ADCx, uint32_t u32Flag)
/* Clear the status of the specified analog watchdog flag. */ void ADC_AWD_ClearStatus(CM_ADC_TypeDef *ADCx, uint32_t u32Flag)
{ DDL_ASSERT(IS_ADC_AWD_FLAG(ADCx, u32Flag)); CLR_REG32_BIT(ADCx->AWDSR, u32Flag); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and @error will be set. */
gint g_file_open_tmp(const gchar *tmpl, gchar **name_used, GError **error)
/* Returns: A file handle (as from open()) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should be closed with close(). In case of errors, -1 is returned and @error will be set. */ gint g_file_open_tmp(const gchar *tmpl, gchar **name_used, GError **error)
{ gchar *fulltemplate; gint result; result = g_get_tmp_name (tmpl, &fulltemplate, wrap_g_open, O_CREAT | O_EXCL | O_RDWR | O_BINARY, 0600, error); if (result != -1) { if (name_used) *name_used = fulltemplate; else g_free (fulltemplate); } return result; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Insert one byte raw data into the Raw Data FIFO. */
BOOLEAN RawFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT8 Input)
/* Insert one byte raw data into the Raw Data FIFO. */ BOOLEAN RawFiFoInsertOneKey(TERMINAL_DEV *TerminalDevice, UINT8 Input)
{ UINT8 Tail; Tail = TerminalDevice->RawFiFo->Tail; if (IsRawFiFoFull (TerminalDevice)) { return FALSE; } TerminalDevice->RawFiFo->Data[Tail] = Input; TerminalDevice->RawFiFo->Tail = (UINT8)((Tail + 1) % (RAW_FIFO_MAX_NUMBER + 1)); return TRUE; }
tianocore/edk2
C++
Other
4,240
/* extract_val(): Extract value from a key=value pair list (comma separated). Only value for the given key is returend. Function allocates memory for the value, remember to free! */
static char* extract_val(const char *str, const char *key)
/* extract_val(): Extract value from a key=value pair list (comma separated). Only value for the given key is returend. Function allocates memory for the value, remember to free! */ static char* extract_val(const char *str, const char *key)
{ char *v, *k; char *s, *strcopy; char *new = NULL; strcopy = strdup(str); if (strcopy == NULL) return NULL; s = strcopy; while (s) { v = strsep(&s, ","); if (!v) break; k = strsep(&v, "="); if (!k) break; if (strcmp(k, key) == 0) { new = strdup(v); break; } } free(strcopy); return new; }
4ms/stm32mp1-baremetal
C++
Other
137
/* ADC MSP Initialization This function configures the hardware resources used in this example: */
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
/* ADC MSP Initialization This function configures the hardware resources used in this example: */ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
{ GPIO_InitTypeDef GPIO_InitStruct; ADCx_CLK_ENABLE(); ADCx_REG_CHANNEL_GPIO_CLK_ENABLE(); ADCx_INJ_CHANNEL_GPIO_CLK_ENABLE(); GPIO_InitStruct.Pin = ADCx_REG_CHANNEL_PIN; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ADCx_REG_CHANNEL_GPIO_PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = ADCx_INJ_CHANNEL_PIN; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ADCx_INJ_CHANNEL_GPIO_PORT, &GPIO_InitStruct); HAL_NVIC_SetPriority(ADCx_IRQn, 15, 0); HAL_NVIC_EnableIRQ(ADCx_IRQn); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* ps3_repository_read_num_be - Number of physical BE processors in the system. */
int ps3_repository_read_num_be(unsigned int *num_be)
/* ps3_repository_read_num_be - Number of physical BE processors in the system. */ int ps3_repository_read_num_be(unsigned int *num_be)
{ int result; u64 v1; result = read_node(PS3_LPAR_ID_PME, make_first_field("ben", 0), 0, 0, 0, &v1, NULL); *num_be = v1; return result; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Place for general cpu/SoC FDT fixups. Board specific fixups should remain in the board files which is where this function should be called from. */
void ft_cpu_setup(void *fdt, bd_t *bd)
/* Place for general cpu/SoC FDT fixups. Board specific fixups should remain in the board files which is where this function should be called from. */ void ft_cpu_setup(void *fdt, bd_t *bd)
{ ft_hs_fixups(fdt, bd); }
4ms/stm32mp1-baremetal
C++
Other
137
/* If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocatePageTableMemory(IN UINTN Pages)
/* If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */ VOID* EFIAPI AllocatePageTableMemory(IN UINTN Pages)
{ VOID *Buffer; if (Pages == 0) { return NULL; } if ((mPageTablePool == NULL) || (Pages > mPageTablePool->FreePages)) { if (!InitializePageTablePool (Pages)) { return NULL; } } Buffer = (UINT8 *)mPageTablePool + mPageTablePool->Offset; mPageTablePool->Offset += EFI_PAGES_TO_SIZE (Pages); mPageTablePool->FreePages -= Pages; return Buffer; }
tianocore/edk2
C++
Other
4,240
/* If Password or Salt or OutKey is NULL, then return FALSE. If the hash algorithm could not be determined, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI CryptoServicePkcs5HashPassword(IN UINTN PasswordLength, IN CONST CHAR8 *Password, IN UINTN SaltLength, IN CONST UINT8 *Salt, IN UINTN IterationCount, IN UINTN DigestSize, IN UINTN KeyLength, OUT UINT8 *OutKey)
/* If Password or Salt or OutKey is NULL, then return FALSE. If the hash algorithm could not be determined, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI CryptoServicePkcs5HashPassword(IN UINTN PasswordLength, IN CONST CHAR8 *Password, IN UINTN SaltLength, IN CONST UINT8 *Salt, IN UINTN IterationCount, IN UINTN DigestSize, IN UINTN KeyLength, OUT UINT8 *OutKey)
{ return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Routine to return a Wiretap error code (0 for no error, an errno for a file error, or a WTAP_ERR_ code for other errors) for an I/O stream. Also returns an error string for some errors. */
int file_error(FILE_T fh, gchar **err_info)
/* Routine to return a Wiretap error code (0 for no error, an errno for a file error, or a WTAP_ERR_ code for other errors) for an I/O stream. Also returns an error string for some errors. */ int file_error(FILE_T fh, gchar **err_info)
{ if (fh->err!=0 && err_info) { *err_info = g_strdup(fh->err_info); } return fh->err; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This file is part of the Simba project. */
static ssize_t find(const char *buf_p, ssize_t pos, ssize_t size, char value)
/* This file is part of the Simba project. */ static ssize_t find(const char *buf_p, ssize_t pos, ssize_t size, char value)
{ while (pos < size) { if (*buf_p == value) { return (pos); } pos++; buf_p++; } return (-1); }
eerimoq/simba
C++
Other
337
/* Gets the selected ADC Software start conversion Status. */
FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef *adc)
/* Gets the selected ADC Software start conversion Status. */ FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef *adc)
{ return (((adc->ADCR & ADC_CR_ADST) != (u32)RESET) ? SET : RESET); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable card status IRQs on (re-)initialisation. This can be called at initialisation, power management event, or pcmcia event. */
static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
/* Enable card status IRQs on (re-)initialisation. This can be called at initialisation, power management event, or pcmcia event. */ static void assabet_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
{ ASSABET_BCR_clear(ASSABET_BCR_CF_BUS_OFF); soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); }
robutest/uclinux
C++
GPL-2.0
60
/* Initialize a GPIO controller. Perform basic initialization of a GPIO controller */
static int gpio_sifive_init(const struct device *dev)
/* Initialize a GPIO controller. Perform basic initialization of a GPIO controller */ static int gpio_sifive_init(const struct device *dev)
{ volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev); gpio->in_en = 0U; gpio->out_en = 0U; gpio->pue = 0U; gpio->rise_ie = 0U; gpio->fall_ie = 0U; gpio->high_ie = 0U; gpio->low_ie = 0U; gpio->iof_en = 0U; gpio->iof_sel = 0U; gpio->invert = 0U; cfg->gpio_cfg_func(); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Attempt to get mutex, return immediately, no error info because users expect some failures when using this API. */
PUBLIC IX_STATUS ixOsalMutexTryLock(IxOsalMutex *mutex)
/* Attempt to get mutex, return immediately, no error info because users expect some failures when using this API. */ PUBLIC IX_STATUS ixOsalMutexTryLock(IxOsalMutex *mutex)
{ if (drv_mutex_trylock(mutex)) return IX_SUCCESS; return IX_FAIL; }
EmcraftSystems/u-boot
C++
Other
181
/* Stops audio stream playing on the used Media. */
static void Audio_MAL_Stop(void)
/* Stops audio stream playing on the used Media. */ static void Audio_MAL_Stop(void)
{ DMA_Cmd(AUDIO_MAL_DMA_STREAM, DISABLE); DMA_ClearFlag(AUDIO_MAL_DMA_STREAM, AUDIO_MAL_DMA_FLAG_TC |AUDIO_MAL_DMA_FLAG_HT | \ AUDIO_MAL_DMA_FLAG_FE | AUDIO_MAL_DMA_FLAG_TE); I2S_Cmd(CODEC_I2S, DISABLE); }
remotemcu/remcu-chip-sdks
C++
null
436
/* If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). */
VOID EFIAPI SetLocalApicBaseAddress(IN UINTN BaseAddress)
/* If BaseAddress is not aligned on a 4KB boundary, then ASSERT(). */ VOID EFIAPI SetLocalApicBaseAddress(IN UINTN BaseAddress)
{ MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr; ASSERT ((BaseAddress & (SIZE_4KB - 1)) == 0); if (!LocalApicBaseAddressMsrSupported ()) { return; } ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE); ApicBaseMsr.Bits.ApicBase = (UINT32)(BaseAddress >> 12); ApicBaseMsr.Bits.ApicBaseHi = (UINT32)(RShiftU64 ((UINT64)BaseAddress, 32)); AsmWriteMsr64 (MSR_IA32_APIC_BASE, ApicBaseMsr.Uint64); }
tianocore/edk2
C++
Other
4,240
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */
gboolean _g_freedesktop_dbus_call_release_name_sync(_GFreedesktopDBus *proxy, const gchar *arg_name, guint *out_value, GCancellable *cancellable, GError **error)
/* Returns: (skip): TRUE if the call succeded, FALSE if @error is set. */ gboolean _g_freedesktop_dbus_call_release_name_sync(_GFreedesktopDBus *proxy, const gchar *arg_name, guint *out_value, GCancellable *cancellable, GError **error)
{ GVariant *_ret; _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy), "ReleaseName", g_variant_new ("(s)", arg_name), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error); if (_ret == NULL) goto _out; g_variant_get (_ret, "(u)", out_value); g_variant_unref (_ret); _out: return _ret != NULL; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Set the slave select pins of the specified SPI port. The */
void SPISSSet(unsigned long ulBase, unsigned long ulSlaveSel)
/* Set the slave select pins of the specified SPI port. The */ void SPISSSet(unsigned long ulBase, unsigned long ulSlaveSel)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); xASSERT((ulSlaveSel == SPI_SS_NONE) || (ulSlaveSel == SPI_SS0) || (ulSlaveSel == SPI_SS1) || (ulSlaveSel == SPI_SS0_SS1)); xHWREG(ulBase + SPI_SSR) &= ~SPI_SSR_SSR_M; xHWREG(ulBase + SPI_SSR) |= ulSlaveSel; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Release the semaphore. Unlike mutexes, up() may be called from any context and even by tasks which have never called down(). */
void up(struct semaphore *sem)
/* Release the semaphore. Unlike mutexes, up() may be called from any context and even by tasks which have never called down(). */ void up(struct semaphore *sem)
{ unsigned long flags; spin_lock_irqsave(&sem->lock, flags); if (likely(list_empty(&sem->wait_list))) sem->count++; else __up(sem); spin_unlock_irqrestore(&sem->lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI AsmMsrBitFieldWrite64(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 Value)
/* If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT64 EFIAPI AsmMsrBitFieldWrite64(IN UINT32 Index, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 Value)
{ return AsmWriteMsr64 ( Index, BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value) ); }
tianocore/edk2
C++
Other
4,240
/* Returns an array of pointers to strings which are split out from @str. This is performed by strictly splitting on white-space; no quote processing is performed. Multiple whitespace characters are considered to be a single argument separator. The returned array is always NULL-terminated. Returns NULL on memory allocation failure. */
char** argv_split(const char *str, int *argcp)
/* Returns an array of pointers to strings which are split out from @str. This is performed by strictly splitting on white-space; no quote processing is performed. Multiple whitespace characters are considered to be a single argument separator. The returned array is always NULL-terminated. Returns NULL on memory allocation failure. */ char** argv_split(const char *str, int *argcp)
{ int argc = count_argc(str); char **argv = zalloc(sizeof(*argv) * (argc+1)); char **argvp; if (argv == NULL) goto out; if (argcp) *argcp = argc; argvp = argv; while (*str) { str = skip_sep(str); if (*str) { const char *p = str; char *t; str = skip_arg(str); t = strndup(p, str-p); if (t == NULL) goto fail; *argvp++ = t; } } *argvp = NULL; out: return argv; fail: argv_free(argv); return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The code below is used to pick up a mode in check_var and set_var. It should be made generic This is used when looking for modes. We assign a "distance" value to a mode in the modedb depending how "close" it is from what we are looking for. Currently, we don't compare that much, we could do better but the current fbcon doesn't quite mind ;) */
static int radeon_compare_modes(const struct fb_var_screeninfo *var, const struct fb_videomode *mode)
/* The code below is used to pick up a mode in check_var and set_var. It should be made generic This is used when looking for modes. We assign a "distance" value to a mode in the modedb depending how "close" it is from what we are looking for. Currently, we don't compare that much, we could do better but the current fbcon doesn't quite mind ;) */ static int radeon_compare_modes(const struct fb_var_screeninfo *var, const struct fb_videomode *mode)
{ int distance = 0; distance = mode->yres - var->yres; distance += (mode->xres - var->xres)/2; return distance; }
robutest/uclinux
C++
GPL-2.0
60
/* When CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is not set, set_pageblock_order() and pageblock_default_order() are unused as pageblock_order is set at compile-time. See include/linux/pageblock-flags.h for the values of pageblock_order based on the kernel config */
static int pageblock_default_order(unsigned int order)
/* When CONFIG_HUGETLB_PAGE_SIZE_VARIABLE is not set, set_pageblock_order() and pageblock_default_order() are unused as pageblock_order is set at compile-time. See include/linux/pageblock-flags.h for the values of pageblock_order based on the kernel config */ static int pageblock_default_order(unsigned int order)
{ return MAX_ORDER-1; } #define set_pageblock_order(x) do {}
robutest/uclinux
C++
GPL-2.0
60
/* This file is part of the Simba project. */
int mock_write_socket_module_init(int res)
/* This file is part of the Simba project. */ int mock_write_socket_module_init(int res)
{ harness_mock_write("socket_module_init()", NULL, 0); harness_mock_write("socket_module_init(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) This function is always used in thread mode. */
unsigned long xI2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave, when the master have obtained control of the bus, and waiting for all bus transmiton complete.(Write Step2) This function is always used in thread mode. */ unsigned long xI2CMasterWriteS2(unsigned long ulBase, unsigned char ucData, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE) || (ulBase == I2C1_BASE)); xI2CMasterWriteRequestS2(ulBase, ucData, xfalse); while (!(xHWREG(ulBase + I2C_CON) & I2C_CON_SI)); ulStatus = xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M; if(!(ulStatus == I2C_I2STAT_M_TX_DAT_ACK)) { ulStatus = xI2CMasterError(ulBase); I2CStopSend(ulBase); return ulStatus; } if(bEndTransmition) { I2CStopSend(ulBase); } return xI2C_MASTER_ERR_NONE; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* When reading the value in TC74 registers through I2C0,we can set I2C0 Master transfer setup data structure using this API. */
unsigned char TC74RegRead(unsigned char ucReg)
/* When reading the value in TC74 registers through I2C0,we can set I2C0 Master transfer setup data structure using this API. */ unsigned char TC74RegRead(unsigned char ucReg)
{ xtI2CMasterTransferCfg Cfg; unsigned char ucSendBuf[1] = {0}; unsigned long ulSendLength = 1; unsigned char ucReceiveBuf[1] = {0}; unsigned long ulReceiveLength = 1; ucSendBuf[0] = ucReg; Cfg.ulSlave = TC74Address; Cfg.pvWBuf = ucSendBuf; Cfg.ulWLen = ulSendLength; Cfg.ulWCount = 0; Cfg.pvRBuf = ucReceiveBuf; Cfg.ulRLen = ulReceiveLength; Cfg.ulRCount = 0; I2CMasterTransfer(I2C_BASE, &Cfg, I2C_TRANSFER_POLLING); return ucReceiveBuf[0]; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Lock the watchdog configuration. If the LFRCO or LFXO clocks are used to clock the watchdog, one should consider using the option of inhibiting those clocks to be disabled, please see the */
void WDOG_Lock(void)
/* Lock the watchdog configuration. If the LFRCO or LFXO clocks are used to clock the watchdog, one should consider using the option of inhibiting those clocks to be disabled, please see the */ void WDOG_Lock(void)
{ while (WDOG->SYNCBUSY & WDOG_SYNCBUSY_CTRL) ; BITBAND_Peripheral(&(WDOG->CTRL), _WDOG_CTRL_LOCK_SHIFT, 1); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Make sure that @bdata->disable_lock is locked when entering this function to avoid races when concurrent threads are disabling buttons at the same time. */
static void gpio_keys_disable_button(struct gpio_button_data *bdata)
/* Make sure that @bdata->disable_lock is locked when entering this function to avoid races when concurrent threads are disabling buttons at the same time. */ static void gpio_keys_disable_button(struct gpio_button_data *bdata)
{ if (!bdata->disabled) { disable_irq(gpio_to_irq(bdata->button->gpio)); if (bdata->button->debounce_interval) del_timer_sync(&bdata->timer); bdata->disabled = true; } }
robutest/uclinux
C++
GPL-2.0
60
/* atl1e_tx_timeout - Respond to a Tx Hang @netdev: network interface device structure */
static void atl1e_tx_timeout(struct net_device *netdev)
/* atl1e_tx_timeout - Respond to a Tx Hang @netdev: network interface device structure */ static void atl1e_tx_timeout(struct net_device *netdev)
{ struct atl1e_adapter *adapter = netdev_priv(netdev); schedule_work(&adapter->reset_task); }
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes Jiaxun Yang Initial version This is the timer interrupt service routine. */
void rt_hw_timer_handler(void)
/* Change Logs: Date Author Notes Jiaxun Yang Initial version This is the timer interrupt service routine. */ void rt_hw_timer_handler(void)
{ unsigned int count; count = read_c0_compare(); write_c0_compare(count); write_c0_count(0); rt_tick_increase(); }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function allocates and initializes a nand_bbt_descr for BBM detection based on the properties of @this. The new descriptor is stored in this->badblock_pattern. Thus, this->badblock_pattern should be NULL when passed to this function. */
static int nand_create_badblock_pattern(struct nand_chip *this)
/* This function allocates and initializes a nand_bbt_descr for BBM detection based on the properties of @this. The new descriptor is stored in this->badblock_pattern. Thus, this->badblock_pattern should be NULL when passed to this function. */ static int nand_create_badblock_pattern(struct nand_chip *this)
{ struct nand_bbt_descr *bd; if (this->badblock_pattern) { pr_warn("Bad block pattern already allocated; not replacing\n"); return -EINVAL; } bd = kzalloc(sizeof(*bd), GFP_KERNEL); if (!bd) return -ENOMEM; bd->options = this->bbt_options & BADBLOCK_SCAN_MASK; bd->offs = this->badblockpos; bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1; bd->pattern = scan_ff_pattern; bd->options |= NAND_BBT_DYNAMICSTRUCT; this->badblock_pattern = bd; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Fills each RTC_AlarmStruct member with its default value (Time = 00d:00h:00mn:20sec / Date = 1st day of the month/Mask = all fields are masked except Alarm Seconds field). */
void RTC_AlarmStructInit(RTC_AlarmTypeDef *RTC_AlarmStruct)
/* Fills each RTC_AlarmStruct member with its default value (Time = 00d:00h:00mn:20sec / Date = 1st day of the month/Mask = all fields are masked except Alarm Seconds field). */ void RTC_AlarmStructInit(RTC_AlarmTypeDef *RTC_AlarmStruct)
{ RTC_AlarmStruct->RTC_AlarmTime.RTC_H12_PMAM = RTC_H12_AM; RTC_AlarmStruct->RTC_AlarmTime.RTC_Hours = 0; RTC_AlarmStruct->RTC_AlarmTime.RTC_Minutes = 0; RTC_AlarmStruct->RTC_AlarmTime.RTC_Seconds = 20; RTC_AlarmStruct->RTC_AlarmTime.RTC_Days = 0; RTC_AlarmStruct->RTC_AlarmMask = RTC_AlarmMask_Hours | RTC_AlarmMask_Minutes; RTC_AlarmStruct->RTC_Alarm2Mask = RTC_Alarm2Mask_Days; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* ppc440spe_desc_set_byte_count - set number of data bytes involved into the operation */
static void ppc440spe_desc_set_byte_count(struct ppc440spe_adma_desc_slot *desc, struct ppc440spe_adma_chan *chan, u32 byte_count)
/* ppc440spe_desc_set_byte_count - set number of data bytes involved into the operation */ static void ppc440spe_desc_set_byte_count(struct ppc440spe_adma_desc_slot *desc, struct ppc440spe_adma_chan *chan, u32 byte_count)
{ struct dma_cdb *dma_hw_desc; struct xor_cb *xor_hw_desc; switch (chan->device->id) { case PPC440SPE_DMA0_ID: case PPC440SPE_DMA1_ID: dma_hw_desc = desc->hw_desc; dma_hw_desc->cnt = cpu_to_le32(byte_count); break; case PPC440SPE_XOR_ID: xor_hw_desc = desc->hw_desc; xor_hw_desc->cbbc = byte_count; break; } }
robutest/uclinux
C++
GPL-2.0
60
/* Writes bits at positions specified by mask to an OV51x reg. Bits that are in the same position as 1's in "mask" are cleared and set to "value". Bits that are in the same position as 0's in "mask" are preserved, regardless of their respective state in "value". */
static int reg_w_mask(struct sd *sd, __u16 index, __u8 value, __u8 mask)
/* Writes bits at positions specified by mask to an OV51x reg. Bits that are in the same position as 1's in "mask" are cleared and set to "value". Bits that are in the same position as 0's in "mask" are preserved, regardless of their respective state in "value". */ static int reg_w_mask(struct sd *sd, __u16 index, __u8 value, __u8 mask)
{ int ret; __u8 oldval; if (mask != 0xff) { value &= mask; ret = reg_r(sd, index); if (ret < 0) return ret; oldval = ret & ~mask; value |= oldval; } return reg_w(sd, index, value); }
robutest/uclinux
C++
GPL-2.0
60