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
/* For pcap_offline_read(): wait and yield between printing packets to simulate the pace packets where actually recorded. */
void pcap_set_wait(pcap_t *p, void(*yield)(void), int wait)
/* For pcap_offline_read(): wait and yield between printing packets to simulate the pace packets where actually recorded. */ void pcap_set_wait(pcap_t *p, void(*yield)(void), int wait)
{ if (p) { struct pcap_dos *pd = p->priv; pd->wait_proc = yield; p->opt.timeout = wait; } }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* @handle: handle of the loaded image @systable: system table */
static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
/* @handle: handle of the loaded image @systable: system table */ static int setup(const efi_handle_t handle, const struct efi_system_table *systable)
{ efi_status_t ret; boottime = systable->boottime; ret = boottime->locate_protocol(&hii_database_protocol_guid, NULL, (void **)&hii_database_protocol); if (ret != EFI_SUCCESS) { hii_database_protocol = NULL; efi_st_error("HII database protocol is not available.\n"); return EFI_ST_FAILURE; } ret = boott...
4ms/stm32mp1-baremetal
C++
Other
137
/* Retrieve the supported language ID table from the device. */
EFI_STATUS EFIAPI UsbIoGetSupportedLanguages(IN EFI_USB_IO_PROTOCOL *This, OUT UINT16 **LangIDTable, OUT UINT16 *TableSize)
/* Retrieve the supported language ID table from the device. */ EFI_STATUS EFIAPI UsbIoGetSupportedLanguages(IN EFI_USB_IO_PROTOCOL *This, OUT UINT16 **LangIDTable, OUT UINT16 *TableSize)
{ USB_DEVICE *Dev; USB_INTERFACE *UsbIf; EFI_TPL OldTpl; OldTpl = gBS->RaiseTPL (USB_BUS_TPL); UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; *LangIDTable = Dev->LangId; *TableSize = (UINT16)(Dev->TotalLangId * sizeof (UINT16)); gBS->RestoreTPL (OldTpl); return EFI_SUC...
tianocore/edk2
C++
Other
4,240
/* Retuns the USB status depending on the HAL status: */
USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status)
/* Retuns the USB status depending on the HAL status: */ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status)
{ case HAL_OK: usb_status = USBH_OK; break; case HAL_ERROR: usb_status = USBH_FAIL; break; case HAL_BUSY: usb_status = USBH_BUSY; break; case HAL_TIMEOUT: usb_status = USBH_FAIL; break; default: usb_status = USBH_FAIL; b...
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* One notified function to stop the Host Controller when gBS->ExitBootServices() called. */
VOID EFIAPI XhcExitBootService(EFI_EVENT Event, VOID *Context)
/* One notified function to stop the Host Controller when gBS->ExitBootServices() called. */ VOID EFIAPI XhcExitBootService(EFI_EVENT Event, VOID *Context)
{ USB_XHCI_INSTANCE *Xhc; EFI_PCI_IO_PROTOCOL *PciIo; Xhc = (USB_XHCI_INSTANCE *)Context; PciIo = Xhc->PciIo; gBS->SetTimer (Xhc->PollTimer, TimerCancel, 0); XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT); if (Xhc->PollTimer != NULL) { gBS->CloseEvent (Xhc->PollTimer); } XhcClearBiosOwnership (Xhc); ...
tianocore/edk2
C++
Other
4,240
/* Checks whether the specified TIM flag is set or not. */
FlagStatus TIM_GetCCENStatus(TIM_Module *TIMx, uint32_t TIM_CCEN)
/* Checks whether the specified TIM flag is set or not. */ FlagStatus TIM_GetCCENStatus(TIM_Module *TIMx, uint32_t TIM_CCEN)
{ INTStatus bitstatus = RESET; assert_param(IsTimList3Module(TIMx)); if (TIMx==TIM1 || TIMx==TIM8){ assert_param(IsAdvancedTimCCENFlag(TIM_CCEN)); if ((TIMx->CCEN & TIM_CCEN) != (uint32_t)RESET) { bitstatus = SET; } else { bitstatus = R...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get the peripheral clock speed for the SPI device at base specified. */
uint32_t rcc_get_spi_clk_freq(uint32_t spi)
/* Get the peripheral clock speed for the SPI device at base specified. */ uint32_t rcc_get_spi_clk_freq(uint32_t spi)
{ return rcc_apb2_frequency; } else { return rcc_apb1_frequency; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* megasas_read_fw_status_reg_xscale - returns the current FW status value @regs: MFI register set */
static u32 megasas_read_fw_status_reg_xscale(struct megasas_register_set __iomem *regs)
/* megasas_read_fw_status_reg_xscale - returns the current FW status value @regs: MFI register set */ static u32 megasas_read_fw_status_reg_xscale(struct megasas_register_set __iomem *regs)
{ return readl(&(regs)->outbound_msg_0); }
robutest/uclinux
C++
GPL-2.0
60
/* Fast approximation to the trigonometric cosine function for Q15 data. */
q15_t arm_cos_q15(q15_t x)
/* Fast approximation to the trigonometric cosine function for Q15 data. */ q15_t arm_cos_q15(q15_t x)
{ q15_t sinVal; int32_t index; q15_t a, b; q15_t fract; x += 0x2000; if(x < 0) { x = x + 0x8000; } index = (uint32_t)x >> FAST_MATH_Q15_SHIFT; fract = (x - (index << FAST_MATH_Q15_SHIFT)) << 9; a = sinTable_q15[index]; b = sinTable_q15[index+1]; sinVal = (q31_t)(0x8000-fract)*a >> 16; ...
MaJerle/stm32f429
C++
null
2,036
/* Looks at the direction the string is currently being scrolled in, and moves the index into the portion of the string that can be seen on the display either forward or backward as appropriate. */
static prvScrollString(unsigned char *pucDirection, unsigned short *pusPosition, size_t xStringLength)
/* Looks at the direction the string is currently being scrolled in, and moves the index into the portion of the string that can be seen on the display either forward or backward as appropriate. */ static prvScrollString(unsigned char *pucDirection, unsigned short *pusPosition, size_t xStringLength)
{ if( *pucDirection == lcdRIGHT_TO_LEFT ) { ( *pusPosition )++; if( ( *pusPosition ) == ( xStringLength - ( lcdSTRING_LEN - 1 ) ) ) { *pucDirection = lcdLEFT_TO_RIGHT; ( *pusPosition )--; } } else { ( *pusPosition )--; if( *pusPosition == 0U ) { *pucDirection = lcdRIGHT_TO_LEFT; } } }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Start a new transfer. This is called both by the idle state for the first transfer in a message, and by the wait state when the previous transfer in a message is complete. */
static void mpc52xx_spi_start_transfer(struct mpc52xx_spi *ms)
/* Start a new transfer. This is called both by the idle state for the first transfer in a message, and by the wait state when the previous transfer in a message is complete. */ static void mpc52xx_spi_start_transfer(struct mpc52xx_spi *ms)
{ ms->rx_buf = ms->transfer->rx_buf; ms->tx_buf = ms->transfer->tx_buf; ms->len = ms->transfer->len; if (ms->cs_change) mpc52xx_spi_chipsel(ms, 1); ms->cs_change = ms->transfer->cs_change; ms->wcol_tx_timestamp = get_tbl(); if (ms->tx_buf) out_8(ms->regs + SPI_DATA, *ms->tx_buf++); else out_8(ms->regs + S...
robutest/uclinux
C++
GPL-2.0
60
/* Performs a case-insensitive comparison of two Null-terminated Unicode strings. */
INTN FatStriCmp(IN CHAR16 *S1, IN CHAR16 *S2)
/* Performs a case-insensitive comparison of two Null-terminated Unicode strings. */ INTN FatStriCmp(IN CHAR16 *S1, IN CHAR16 *S2)
{ ASSERT (StrSize (S1) != 0); ASSERT (StrSize (S2) != 0); ASSERT (mUnicodeCollationInterface != NULL); return mUnicodeCollationInterface->StriColl ( mUnicodeCollationInterface, S1, S2 ...
tianocore/edk2
C++
Other
4,240
/* Set WM8731 power mode to line in record only. */
void wm8731_power_mode_adc_line_in(void)
/* Set WM8731 power mode to line in record only. */ void wm8731_power_mode_adc_line_in(void)
{ g_us_wm8731_reg_power_down_control_value = 0x1A; wm8731_write_register(WM8731_REG_POWER_DOWN_CONTROL, g_us_wm8731_reg_power_down_control_value); }
remotemcu/remcu-chip-sdks
C++
null
436
/* param base FLEXSPI peripheral base address. param handle pointer to flexspi_handle_t structure which stores the transfer state */
void FLEXSPI_TransferAbort(FLEXSPI_Type *base, flexspi_handle_t *handle)
/* param base FLEXSPI peripheral base address. param handle pointer to flexspi_handle_t structure which stores the transfer state */ void FLEXSPI_TransferAbort(FLEXSPI_Type *base, flexspi_handle_t *handle)
{ assert(handle); FLEXSPI_DisableInterrupts(base, kIrqFlags); handle->state = kFLEXSPI_Idle; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Out of reset, the low-level assembly code calls this routine to initialize the mcf5206e for this board. A temporary stack has been setup in the internal SRAM, and the stack pointer will be changed to point to DRAM once this routine returns. */
void __initialize_hardware(void)
/* Out of reset, the low-level assembly code calls this routine to initialize the mcf5206e for this board. A temporary stack has been setup in the internal SRAM, and the stack pointer will be changed to point to DRAM once this routine returns. */ void __initialize_hardware(void)
{ asm { move.l #__IPSBAR,d0 andi.l #0xC0000000,d0 add.l #0x1,d0 move.l d0,0x40000000 move.l #__FLASHBAR,d0 andi.l #0xFFF80000,d0 add.l #0x61,d0 movec d0,FLASHBAR } MCF_CLOCK_RTCDR = 48000000; pll_init(); scm_init(); initialize_exceptions(); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Returns CR_OK upon successful completion, an error code otherwise. */
enum CRStatus cr_font_size_set_relative_font_size(CRFontSize *a_this, enum CRRelativeFontSize a_relative)
/* Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_font_size_set_relative_font_size(CRFontSize *a_this, enum CRRelativeFontSize a_relative)
{ g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR) ; g_return_val_if_fail (a_relative >= FONT_SIZE_LARGER && a_relative < NB_RELATIVE_FONT_SIZE, CR_BAD_PARAM_ERROR) ; a_this->type = RELATIVE_FONT_SIZE ; a_this->value.relative =...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Configure the FT5336 device to stop generating IT on the given INT pin connected to MCU as EXTI. */
void ft5336_TS_DisableIT(uint16_t DeviceAddr)
/* Configure the FT5336 device to stop generating IT on the given INT pin connected to MCU as EXTI. */ void ft5336_TS_DisableIT(uint16_t DeviceAddr)
{ uint8_t regValue = 0; regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT; TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue); }
eclipse-threadx/getting-started
C++
Other
310
/* Change Logs: Date Author Notes 勤为本 first version */
void pin_set_purpose(unsigned int gpio, pin_purpose_t purpose)
/* Change Logs: Date Author Notes 勤为本 first version */ void pin_set_purpose(unsigned int gpio, pin_purpose_t purpose)
{ volatile unsigned int *gpio_cfgx; unsigned int pin = GPIO_GET_PIN(gpio); gpio_cfgx = gpio_get_cfg_reg(gpio); if (PIN_PURPOSE_GPIO == purpose) { reg_set_one_bit(gpio_cfgx, pin); } else { reg_clr_one_bit(gpio_cfgx, pin); } return ; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This access is abstracted from the PCD services to enforce that the PCD be FixedAtBuild in the Standalone MM build of this driver. */
UINT32 GetCpuMaxLogicalProcessorNumber(VOID)
/* This access is abstracted from the PCD services to enforce that the PCD be FixedAtBuild in the Standalone MM build of this driver. */ UINT32 GetCpuMaxLogicalProcessorNumber(VOID)
{ return PcdGet32 (PcdCpuMaxLogicalProcessorNumber); }
tianocore/edk2
C++
Other
4,240
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */
unsigned long xI2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
/* Write a data to the slave when the bus is idle, and waiting for all bus transmiton complete.(Write Step1) This function is always used in thread mode. */ unsigned long xI2CMasterWriteS1(unsigned long ulBase, unsigned char ucSlaveAddr, unsigned char ucData, xtBoolean bEndTransmition)
{ unsigned long ulStatus; xASSERT((ulBase == I2C0_BASE)); xASSERT(!(ucSlaveAddr & 0x80)); xI2CMasterWriteRequestS1(ulBase, ucSlaveAddr, ucData, xfalse); while (!(xHWREG(ulBase + I2C_CON) & I2C_CON_SI)); ulStatus = xHWREG(ulBase + I2C_STATUS) & I2C_STATUS_M; if(!(ulStatus == I2C_I2STAT_M_TX_D...
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Hosts that support power saving can use the 'enable' and 'disable' methods to exit and enter power saving states. For more information see comments for struct mmc_host_ops. */
int mmc_host_disable(struct mmc_host *host)
/* Hosts that support power saving can use the 'enable' and 'disable' methods to exit and enter power saving states. For more information see comments for struct mmc_host_ops. */ int mmc_host_disable(struct mmc_host *host)
{ int err; if (!(host->caps & MMC_CAP_DISABLE)) return 0; if (host->en_dis_recurs) return 0; if (--host->nesting_cnt) return 0; if (!host->enabled) return 0; err = mmc_host_do_disable(host, 0); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate service buffer and tell card about it */
static int __devinit service_buffer_allocate(struct lanai_dev *lanai)
/* Allocate service buffer and tell card about it */ static int __devinit service_buffer_allocate(struct lanai_dev *lanai)
{ lanai_buf_allocate(&lanai->service, SERVICE_ENTRIES * 4, 8, lanai->pci); if (unlikely(lanai->service.start == NULL)) return -ENOMEM; DPRINTK("allocated service buffer at 0x%08lX, size %Zu(%d)\n", (unsigned long) lanai->service.start, lanai_buf_size(&lanai->service), lanai_buf_size_cardorder(&...
robutest/uclinux
C++
GPL-2.0
60
/* get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of the specified bus in HZ. */
static ulong get_PLLCLK(int pllreg)
/* get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of the specified bus in HZ. */ static ulong get_PLLCLK(int pllreg)
{ ulong r, m, p, s; switch (pllreg) { case APLL: r = APLL_CON_REG; break; case MPLL: r = MPLL_CON_REG; break; case EPLL: r = EPLL_CON0_REG; break; default: hang(); } m = (r >> 16) & 0x3ff; p = (r >> 8) & 0x3f; s = r & 0x7; return m * (CONFIG_SYS_CLK_FREQ / (p * (1 << s))); }
EmcraftSystems/u-boot
C++
Other
181
/* Check whether the timestamp is valid by comparing the signing time and the revocation time. */
BOOLEAN CompareTimestamp(IN EFI_TIME *SigningTime, IN EFI_TIME *RevocationTime)
/* Check whether the timestamp is valid by comparing the signing time and the revocation time. */ BOOLEAN CompareTimestamp(IN EFI_TIME *SigningTime, IN EFI_TIME *RevocationTime)
{ if (SigningTime->Year != RevocationTime->Year) { return (BOOLEAN)(SigningTime->Year < RevocationTime->Year); } else if (SigningTime->Month != RevocationTime->Month) { return (BOOLEAN)(SigningTime->Month < RevocationTime->Month); } else if (SigningTime->Day != RevocationTime->Day) { return (BOOLEAN)(...
tianocore/edk2
C++
Other
4,240
/* This function will read the EEPROM location for the SAN MAC address pointer, and returns the value at that location. This is used in both get and set mac_addr routines. */
static s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw, u16 *san_mac_offset)
/* This function will read the EEPROM location for the SAN MAC address pointer, and returns the value at that location. This is used in both get and set mac_addr routines. */ static s32 ixgbe_get_san_mac_addr_offset_82599(struct ixgbe_hw *hw, u16 *san_mac_offset)
{ hw->eeprom.ops.read(hw, IXGBE_SAN_MAC_ADDR_PTR, san_mac_offset); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Called when the ADC core selects (or deslects) us as a client. */
static void s3c24xx_ts_select(struct s3c_adc_client *client, unsigned select)
/* Called when the ADC core selects (or deslects) us as a client. */ static void s3c24xx_ts_select(struct s3c_adc_client *client, unsigned select)
{ if (select) { writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, ts.io + S3C2410_ADCTSC); } else { mod_timer(&touch_timer, jiffies+1); writel(WAIT4INT | INT_UP, ts.io + S3C2410_ADCTSC); } }
robutest/uclinux
C++
GPL-2.0
60
/* RCC Set the Source for the RTC clock. */
void rcc_set_rtc_clock_source(enum rcc_osc clk)
/* RCC Set the Source for the RTC clock. */ void rcc_set_rtc_clock_source(enum rcc_osc clk)
{ switch (clk) { case RCC_HSE: RCC_BDCR = (RCC_BDCR & ~RCC_BDCR_RTCSEL) | RCC_BDCR_RTCSEL_HSE; break; case RCC_LSE: RCC_BDCR = (RCC_BDCR & ~RCC_BDCR_RTCSEL) | RCC_BDCR_RTCSEL_LSE; break; case RCC_LSI: RCC_BDCR = (RCC_BDCR & ~RCC_BDCR_RTCSEL) | RCC_BDCR_RTCSEL_LSI; break; default: break; } }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Get a reference to an existing device structure. This will automatically increment the reference count. */
struct tape_device* tape_get_device(struct tape_device *device)
/* Get a reference to an existing device structure. This will automatically increment the reference count. */ struct tape_device* tape_get_device(struct tape_device *device)
{ int count; count = atomic_inc_return(&device->ref_count); DBF_EVENT(4, "tape_get_device(%p) = %i\n", device, count); return device; }
robutest/uclinux
C++
GPL-2.0
60
/* Read MM I/O Instructions for the iSeries On MM I/O error, all ones are returned and iSeries_pci_IoError is cal else, data is returned in Big Endian format. */
static u8 iseries_readb(const volatile void __iomem *addr)
/* Read MM I/O Instructions for the iSeries On MM I/O error, all ones are returned and iSeries_pci_IoError is cal else, data is returned in Big Endian format. */ static u8 iseries_readb(const volatile void __iomem *addr)
{ u64 bar_offset; u64 dsa; int retry = 0; struct HvCallPci_LoadReturn ret; struct device_node *dn = xlate_iomm_address(addr, &dsa, &bar_offset, "read_byte"); if (dn == NULL) return 0xff; do { HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, bar_offset, 0); } while (check_return_code("RDB", dn, &retry, ret.rc) !...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Format the data in the tvb from offset for length ... */
gchar* tvb_format_text_wsp(tvbuff_t *tvb, const gint offset, const gint size)
/* Format the data in the tvb from offset for length ... */ gchar* tvb_format_text_wsp(tvbuff_t *tvb, const gint offset, const gint size)
{ const guint8 *ptr; gint len; len = (size > 0) ? size : 0; ptr = ensure_contiguous(tvb, offset, size); return format_text_wsp(ptr, len); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* 6.. FMS Write (Confirmed Service Id = 3) 6..1. Request Message Parameters */
static void dissect_ff_msg_fms_write_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
/* 6.. FMS Write (Confirmed Service Id = 3) 6..1. Request Message Parameters */ static void dissect_ff_msg_fms_write_req(tvbuff_t *tvb, gint offset, guint32 length, packet_info *pinfo, proto_tree *tree)
{ proto_tree *sub_tree; col_set_str(pinfo->cinfo, COL_INFO, "FMS Write Request"); if (!tree) { return; } sub_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_ff_fms_write_req, NULL, "FMS Write Request"); proto_tree_add_item(sub_tree, hf_ff_fms_write_req_idx, tvb, offs...
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Increments the reference count of the current instance of #CRInput. */
void cr_input_ref(CRInput *a_this)
/* Increments the reference count of the current instance of #CRInput. */ void cr_input_ref(CRInput *a_this)
{ g_return_if_fail (a_this && PRIVATE (a_this)); PRIVATE (a_this)->ref_count++; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* This function handles External line 2 interrupt request. */
void EXTI2_IRQHandler(void)
/* This function handles External line 2 interrupt request. */ void EXTI2_IRQHandler(void)
{ HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Sync the HW-blocking state of all rfkill switches, do notice it causes the rfkill core to schedule uevents */
static void tpacpi_rfk_update_hwblock_state(bool blocked)
/* Sync the HW-blocking state of all rfkill switches, do notice it causes the rfkill core to schedule uevents */ static void tpacpi_rfk_update_hwblock_state(bool blocked)
{ unsigned int i; struct tpacpi_rfk *tp_rfk; for (i = 0; i < TPACPI_RFK_SW_MAX; i++) { tp_rfk = tpacpi_rfkill_switches[i]; if (tp_rfk) { if (rfkill_set_hw_state(tp_rfk->rfkill, blocked)) { } } } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Return the 'period' to use for this qset. The minimum interval for the endpoint is used so whatever urbs are submitted the device is polled often enough. */
static int qset_get_period(struct whc *whc, struct whc_qset *qset)
/* Return the 'period' to use for this qset. The minimum interval for the endpoint is used so whatever urbs are submitted the device is polled often enough. */ static int qset_get_period(struct whc *whc, struct whc_qset *qset)
{ uint8_t bInterval = qset->ep->desc.bInterval; if (bInterval < 6) bInterval = 6; if (bInterval > 10) bInterval = 10; return bInterval - 6; }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the RTC clock to be output through the relative pin. */
void RTC_CalibOutputCmd(FunctionalState NewState)
/* Enables or disables the RTC clock to be output through the relative pin. */ void RTC_CalibOutputCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); RTC_WriteProtectionCmd(DISABLE); if (NewState != DISABLE) { RTC->CR3 |= (uint8_t)RTC_CR3_COE; } else { RTC->CR3 &= (uint8_t)~RTC_CR3_COE; } RTC_WriteProtectionCmd(ENABLE); }
remotemcu/remcu-chip-sdks
C++
null
436
/* This bit allows the bootrom to configure the IOs after a warm reset. */
void sysmgr_config_warmrstcfgio(int enable)
/* This bit allows the bootrom to configure the IOs after a warm reset. */ void sysmgr_config_warmrstcfgio(int enable)
{ if (enable) setbits_le32(&sysmgr_regs->romcodegrp_ctrl, SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO); else clrbits_le32(&sysmgr_regs->romcodegrp_ctrl, SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Checks whether the specified flash flag is set or not. */
uint8_t FMC_ReadStatusFlag(FMC_FLAG_T flag)
/* Checks whether the specified flash flag is set or not. */ uint8_t FMC_ReadStatusFlag(FMC_FLAG_T flag)
{ uint8_t status; if (flag & 0xff) { status = FMC->STS & flag; } else { status = FMC->OBCS & flag; } if (status) { return SET; } return RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Reads and returns the current value of GS. This function is only available on IA-32 and x64. */
UINT16 EFIAPI AsmReadGs(VOID)
/* Reads and returns the current value of GS. This function is only available on IA-32 and x64. */ UINT16 EFIAPI AsmReadGs(VOID)
{ __asm { xor eax, eax mov ax, gs } }
tianocore/edk2
C++
Other
4,240
/* The main OpcUa dissector functions. It uses tcp_dissect_pdus from packet-tcp.h to reassemble the TCP data. */
static int dissect_opcua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
/* The main OpcUa dissector functions. It uses tcp_dissect_pdus from packet-tcp.h to reassemble the TCP data. */ static int dissect_opcua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{ tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN, get_opcua_message_len, dissect_opcua_message, data); return tvb_reported_length(tvb); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* reads the first character of file 'f' and skips an optional BOM mark in its beginning plus its first line if it starts with '#'. Returns true if it skipped the first line. In any case, '*cp' has the first "valid" character of the file (after the optional BOM and a first-line comment). */
static int skipcomment(LoadF *lf, int *cp)
/* reads the first character of file 'f' and skips an optional BOM mark in its beginning plus its first line if it starts with '#'. Returns true if it skipped the first line. In any case, '*cp' has the first "valid" character of the file (after the optional BOM and a first-line comment). */ static int skipcomment(Load...
{ do { c = lua_getc(lf->f); } while (c != EOF && c != '\n') ; *cp = lua_getc(lf->f); return 1; } else return 0; }
opentx/opentx
C++
GNU General Public License v2.0
2,025
/* Returns: the name of the application for @appinfo. */
const char* g_app_info_get_name(GAppInfo *appinfo)
/* Returns: the name of the application for @appinfo. */ const char* g_app_info_get_name(GAppInfo *appinfo)
{ GAppInfoIface *iface; g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL); iface = G_APP_INFO_GET_IFACE (appinfo); return (* iface->get_name) (appinfo); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset.. */
int32_t iis2mdc_mag_user_offset_set(stmdev_ctx_t *ctx, int16_t *val)
/* These registers comprise a 3 group of 16-bit number and represent hard-iron offset in order to compensate environmental effects. Data format is the same of output data raw: two’s complement with 1LSb = 1.5mG. These values act on the magnetic output data value in order to delete the environmental offset.. */ int32_t...
{ uint8_t buff[6]; int32_t ret; buff[1] = (uint8_t) ((uint16_t)val[0] / 256U); buff[0] = (uint8_t) ((uint16_t)val[0] - (buff[1] * 256U)); buff[3] = (uint8_t) ((uint16_t)val[1] / 256U); buff[2] = (uint8_t) ((uint16_t)val[1] - (buff[3] * 256U)); buff[5] = (uint8_t) ((uint16_t)val[2] / 256U); buff[4] = (ui...
eclipse-threadx/getting-started
C++
Other
310
/* This function reserves GTM timer for later use. It returns gtm_timer structure to use with the rest of GTM API, you should use timer->irq to manage timer interrupt. */
struct gtm_timer* gtm_get_specific_timer16(struct gtm *gtm, unsigned int timer)
/* This function reserves GTM timer for later use. It returns gtm_timer structure to use with the rest of GTM API, you should use timer->irq to manage timer interrupt. */ struct gtm_timer* gtm_get_specific_timer16(struct gtm *gtm, unsigned int timer)
{ struct gtm_timer *ret = ERR_PTR(-EBUSY); if (timer > 3) return ERR_PTR(-EINVAL); spin_lock_irq(&gtm->lock); if (gtm->timers[timer].requested) goto out; ret = &gtm->timers[timer]; ret->requested = true; out: spin_unlock_irq(&gtm->lock); return ret; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The caller must take care not to invoke this function if the engine is not currently ready to receive payload bytes to send. */
static void sendpld_flush(br_ssl_engine_context *rc, int force)
/* The caller must take care not to invoke this function if the engine is not currently ready to receive payload bytes to send. */ static void sendpld_flush(br_ssl_engine_context *rc, int force)
{ size_t xlen; unsigned char *buf; if (rc->oxa == rc->oxb) { return; } xlen = rc->oxa - rc->oxc; if (xlen == 0 && !force) { return; } buf = rc->out.vtable->encrypt(&rc->out.vtable, rc->record_type_out, rc->version_out, rc->obuf + rc->oxc, &xlen); rc->oxb = rc->oxa = (size_t)(buf - rc->obuf); rc->oxc =...
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Reads a block of data from the L3GD20. */
void L3GD20_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
/* Reads a block of data from the L3GD20. */ void L3GD20_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead)
{ if(NumByteToRead > 0x01) { ReadAddr |= (uint8_t)(READWRITE_CMD | MULTIPLEBYTE_CMD); } else { ReadAddr |= (uint8_t)READWRITE_CMD; } L3GD20_CS_LOW(); L3GD20_SendByte(ReadAddr); while(NumByteToRead > 0x00) { *pBuffer = L3GD20_SendByte(DUMMY_BYTE); NumByteToRead--; pBuffer++; }...
remotemcu/remcu-chip-sdks
C++
null
436
/* UART MSP Initialization This function configures the hardware resources used in this example. */
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/* UART MSP Initialization This function configures the hardware resources used in this example. */ void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(huart->Instance==LPUART1) { PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1; PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enumerate the child dev array parsed from VBT to check whether the integrated TV is present. If it is present, return 1. If it is not present, return false. If no child dev is parsed from VBT, it assumes that the TV is present. */
static int tv_is_present_in_vbt(struct drm_device *dev)
/* Enumerate the child dev array parsed from VBT to check whether the integrated TV is present. If it is present, return 1. If it is not present, return false. If no child dev is parsed from VBT, it assumes that the TV is present. */ static int tv_is_present_in_vbt(struct drm_device *dev)
{ struct drm_i915_private *dev_priv = dev->dev_private; struct child_device_config *p_child; int i, ret; if (!dev_priv->child_dev_num) return 1; ret = 0; for (i = 0; i < dev_priv->child_dev_num; i++) { p_child = dev_priv->child_dev + i; if (p_child->device_type != DEVICE_TYPE_INT_TV && p_child->device_ty...
robutest/uclinux
C++
GPL-2.0
60
/* Returns 0 on success or a negative error code. */
int rtnl_link_register(struct rtnl_link_ops *ops)
/* Returns 0 on success or a negative error code. */ int rtnl_link_register(struct rtnl_link_ops *ops)
{ int err; rtnl_lock(); err = __rtnl_link_register(ops); rtnl_unlock(); return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* FLEXIO UART EDMA send finished callback function. This function is called when FLEXIO UART EDMA send finished. It disables the UART TX EDMA request and sends kStatus_FLEXIO_UART_TxIdle to FLEXIO UART callback. */
static void FLEXIO_UART_TransferSendEDMACallback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
/* FLEXIO UART EDMA send finished callback function. This function is called when FLEXIO UART EDMA send finished. It disables the UART TX EDMA request and sends kStatus_FLEXIO_UART_TxIdle to FLEXIO UART callback. */ static void FLEXIO_UART_TransferSendEDMACallback(edma_handle_t *handle, void *param, bool transferDone,...
{ flexio_uart_edma_private_handle_t *uartPrivateHandle = (flexio_uart_edma_private_handle_t *)param; assert(uartPrivateHandle->handle); handle = handle; tcds = tcds; if (transferDone) { FLEXIO_UART_TransferAbortSendEDMA(uartPrivateHandle->base, uartPrivateHandle->handle); if (uar...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Allocates and initializes one RSA context for subsequent use. */
VOID* EFIAPI RsaNew(VOID)
/* Allocates and initializes one RSA context for subsequent use. */ VOID* EFIAPI RsaNew(VOID)
{ CALL_CRYPTO_SERVICE (RsaNew, (), NULL); }
tianocore/edk2
C++
Other
4,240
/* tipc_log_resize - change the size of the TIPC log buffer @log_size: print buffer size to use */
int tipc_log_resize(int log_size)
/* tipc_log_resize - change the size of the TIPC log buffer @log_size: print buffer size to use */ int tipc_log_resize(int log_size)
{ int res = 0; spin_lock_bh(&print_lock); if (TIPC_LOG->buf) { kfree(TIPC_LOG->buf); TIPC_LOG->buf = NULL; } if (log_size) { if (log_size < TIPC_PB_MIN_SIZE) log_size = TIPC_PB_MIN_SIZE; res = TIPC_LOG->echo; tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC), log_size); TIPC_LOG->ech...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Remove all references to a driver from the core driver. The low level driver must have removed all its ports via the uart_remove_one_port() if it registered them with uart_add_one_port(). (ie, drv->port == NULL) */
void uart_unregister_driver(struct uart_driver *drv)
/* Remove all references to a driver from the core driver. The low level driver must have removed all its ports via the uart_remove_one_port() if it registered them with uart_add_one_port(). (ie, drv->port == NULL) */ void uart_unregister_driver(struct uart_driver *drv)
{ struct tty_driver *p = drv->tty_driver; tty_unregister_driver(p); put_tty_driver(p); kfree(drv->state); drv->tty_driver = NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Programs a word at a specified address in data memory. */
FLASH_Status DATA_EEPROM_FastProgramWord(uint32_t Address, uint32_t Data)
/* Programs a word at a specified address in data memory. */ FLASH_Status DATA_EEPROM_FastProgramWord(uint32_t Address, uint32_t Data)
{ FLASH_Status status = FLASH_COMPLETE; assert_param(IS_FLASH_DATA_ADDRESS(Address)); status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT); if(status == FLASH_COMPLETE) { FLASH->PECR &= (uint32_t)(~((uint32_t)FLASH_PECR_FTDW)); *(__IO uint32_t *)Address = Data; status = FLASH_WaitForLastO...
avem-labs/Avem
C++
MIT License
1,752
/* Optimised routine to draw a horizontal line faster than setting individual pixels. */
void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color)
/* Optimised routine to draw a horizontal line faster than setting individual pixels. */ void lcdDrawHLine(uint16_t x0, uint16_t x1, uint16_t y, uint16_t color)
{ uint16_t x, pixels; if (x1 < x0) { x = x1; x1 = x0; x0 = x; } if (x1 >= lcdGetWidth()) { x1 = lcdGetWidth() - 1; } if (x0 >= lcdGetWidth()) { x0 = lcdGetWidth() - 1; } hx8347gSetCursor(x0, y); hx8347gWriteCommand(HX8347G_CMD_SRAMWRITECONTROL); for (pixels = 0; pixels < x1...
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* This function validates that the Physical Range address or length is not zero and is 64K aligned. */
STATIC VOID EFIAPI ValidatePhysicalRange(IN UINT8 *Ptr, IN VOID *Context)
/* This function validates that the Physical Range address or length is not zero and is 64K aligned. */ STATIC VOID EFIAPI ValidatePhysicalRange(IN UINT8 *Ptr, IN VOID *Context)
{ UINT64 Value; Value = *(UINT64 *)Ptr; if ((Value == 0) || ((Value & (SIZE_64KB - 1)) != 0)) { IncrementErrorCount (); Print (L"\nERROR: Physical Range must be 64K aligned and cannot be zero."); } }
tianocore/edk2
C++
Other
4,240
/* Perform basic hardware initialization. Initialize the interrupt controller device drivers. Also initialize the timer device driver, if required. */
static int imxrt_init(void)
/* Perform basic hardware initialization. Initialize the interrupt controller device drivers. Also initialize the timer device driver, if required. */ static int imxrt_init(void)
{ sys_cache_instr_enable(); sys_cache_data_enable(); clock_init(); return 0; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* Given the parent's rate and the divider in 7.1 format, this works out the resulting peripheral clock rate. */
static unsigned long get_rate_from_divider(unsigned long parent_rate, int divider)
/* Given the parent's rate and the divider in 7.1 format, this works out the resulting peripheral clock rate. */ static unsigned long get_rate_from_divider(unsigned long parent_rate, int divider)
{ u64 rate; rate = (u64)parent_rate * 2; do_div(rate, divider + 2); return rate; }
4ms/stm32mp1-baremetal
C++
Other
137
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
/* I2C MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
{ if(hi2c->Instance==I2C3) { __HAL_RCC_I2C3_CLK_DISABLE(); HAL_GPIO_DeInit(I2C3_SDA_GPIO_Port, I2C3_SDA_Pin); HAL_GPIO_DeInit(I2C3_SCL_GPIO_Port, I2C3_SCL_Pin); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Writes a byte array to the on-chip EEPROM memory. */
RAMFUNC err_t writeEEPROM(uint8_t *eeAddress, uint8_t *buffAddress, uint32_t byteCount)
/* Writes a byte array to the on-chip EEPROM memory. */ RAMFUNC err_t writeEEPROM(uint8_t *eeAddress, uint8_t *buffAddress, uint32_t byteCount)
{ unsigned int command[5], result[4]; command[0] = 61; command[1] = (uint32_t) eeAddress; command[2] = (uint32_t) buffAddress; command[3] = byteCount; command[4] = (uint32_t) (SystemCoreClock/1000); __disable_irq(); iap_entry(command, result); __enable_irq(); if (0 != result[0]) { return ERROR...
microbuilder/LPC11U_LPC13U_CodeBase
C++
Other
54
/* Set boot file name to check. If the boot file name is specified, the default check list will be disabled. */
void media_set_file_name(const char *name)
/* Set boot file name to check. If the boot file name is specified, the default check list will be disabled. */ void media_set_file_name(const char *name)
{ file_names[0] = (char*)name; if (name) { dbg_print("media: boot file name %s\r\n", name); } }
remotemcu/remcu-chip-sdks
C++
null
436
/* gelic_card_free_chain - free descriptor chain @card: card structure @descr_in: address of desc */
static void gelic_card_free_chain(struct gelic_card *card, struct gelic_descr *descr_in)
/* gelic_card_free_chain - free descriptor chain @card: card structure @descr_in: address of desc */ static void gelic_card_free_chain(struct gelic_card *card, struct gelic_descr *descr_in)
{ struct gelic_descr *descr; for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) { dma_unmap_single(ctodev(card), descr->bus_addr, GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL); descr->bus_addr = 0; } }
robutest/uclinux
C++
GPL-2.0
60
/* Returns: TRUE if the date is the last day of the month */
gboolean g_date_is_last_of_month(const GDate *d)
/* Returns: TRUE if the date is the last day of the month */ gboolean g_date_is_last_of_month(const GDate *d)
{ gint idx; g_return_val_if_fail (g_date_valid (d), FALSE); if (!d->dmy) g_date_update_dmy (d); g_return_val_if_fail (d->dmy, FALSE); idx = g_date_is_leap_year (d->year) ? 1 : 0; if (d->day == days_in_months[idx][d->month]) return TRUE; else return FALSE; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Starts the TIMER one pulse signal generation on the complementary output. */
void ald_timer_one_pulse_n_start(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
/* Starts the TIMER one pulse signal generation on the complementary output. */ void ald_timer_one_pulse_n_start(ald_timer_handle_t *hperh, ald_timer_channel_t ch)
{ ald_timer_ocn_start(hperh, ch); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function Initializes the interrupt frequency of the SysTick. */
__WEAKDEF int32_t SysTick_Init(uint32_t u32Freq)
/* This function Initializes the interrupt frequency of the SysTick. */ __WEAKDEF int32_t SysTick_Init(uint32_t u32Freq)
{ int32_t i32Ret = LL_ERR; if ((0UL != u32Freq) && (u32Freq <= 1000UL)) { m_u32TickStep = 1000UL / u32Freq; if (0UL == SysTick_Config(HCLK_VALUE / u32Freq)) { i32Ret = LL_OK; } } return i32Ret; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get USI UART RX DMA dummy flag . */
u32 USI_UARTGetRxDMADummyFlag(USI_TypeDef *USIx)
/* Get USI UART RX DMA dummy flag . */ u32 USI_UARTGetRxDMADummyFlag(USI_TypeDef *USIx)
{ if(USIx->UART_RXDMA_FLOW_CTRL & USI_UART_RXDMA_DUMMY_FLAG) { return 1; } else { return 0; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Internal function gets the start pointer of opcode buffer. */
UINT8* EFIAPI InternalHiiOpCodeHandleBuffer(IN VOID *OpCodeHandle)
/* Internal function gets the start pointer of opcode buffer. */ UINT8* EFIAPI InternalHiiOpCodeHandleBuffer(IN VOID *OpCodeHandle)
{ return ((HII_LIB_OPCODE_BUFFER *)OpCodeHandle)->Buffer; }
tianocore/edk2
C++
Other
4,240
/* Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer. */
CHAR8* InternalPrintLibValueToString(IN OUT CHAR8 *Buffer, IN INT64 Value, IN UINTN Radix)
/* Print worker function that converts a decimal or hexadecimal number to an ASCII string in Buffer. */ CHAR8* InternalPrintLibValueToString(IN OUT CHAR8 *Buffer, IN INT64 Value, IN UINTN Radix)
{ UINT32 Remainder; *Buffer = 0; do { Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder); *(++Buffer) = mHexStr[Remainder]; } while (Value != 0); return Buffer; }
tianocore/edk2
C++
Other
4,240
/* For the address range [start,end), write back the data from the D-cache and invalidate the corresponding region of the I-cache for the current process. Used to flush signal trampolines on the stack to make them executable. */
static void sh5_flush_cache_sigtramp(void *vaddr)
/* For the address range [start,end), write back the data from the D-cache and invalidate the corresponding region of the I-cache for the current process. Used to flush signal trampolines on the stack to make them executable. */ static void sh5_flush_cache_sigtramp(void *vaddr)
{ unsigned long end = (unsigned long)vaddr + L1_CACHE_BYTES; __flush_wback_region(vaddr, L1_CACHE_BYTES); wmb(); sh64_icache_inv_current_user_range((unsigned long)vaddr, end); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* In Linux each process has its own kernel stack, so this happens a lot: we change stacks on each context switch. */
void guest_set_stack(struct lg_cpu *cpu, u32 seg, u32 esp, unsigned int pages)
/* In Linux each process has its own kernel stack, so this happens a lot: we change stacks on each context switch. */ void guest_set_stack(struct lg_cpu *cpu, u32 seg, u32 esp, unsigned int pages)
{ if ((seg & 0x3) != GUEST_PL) kill_guest(cpu, "bad stack segment %i", seg); if (pages > 2) kill_guest(cpu, "bad stack pages %u", pages); cpu->ss1 = seg; cpu->esp1 = esp; cpu->lg->stack_pages = pages; pin_stack_pages(cpu); }
robutest/uclinux
C++
GPL-2.0
60
/* Change Logs: Date Author Notes charlown first version */
void rt_hw_us_delay(rt_uint32_t us)
/* Change Logs: Date Author Notes charlown first version */ void rt_hw_us_delay(rt_uint32_t us)
{ rt_uint32_t start, now, delta, reload, us_tick; start = SysTick->VAL; reload = SysTick->LOAD; us_tick = SystemCoreClock / 1000000UL; do { now = SysTick->VAL; delta = start > now ? start - now : reload + start - now; } while (delta < us_tick * us); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* DMA Stream Set Peripheral Flow Control. Ensure that the stream is disabled otherwise the setting will not be changed. */
void dma_set_peripheral_flow_control(uint32_t dma, uint8_t stream)
/* DMA Stream Set Peripheral Flow Control. Ensure that the stream is disabled otherwise the setting will not be changed. */ void dma_set_peripheral_flow_control(uint32_t dma, uint8_t stream)
{ DMA_SCR(dma, stream) |= DMA_SxCR_PFCTRL; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Returns the USB Host Speed from the Low Level Driver. */
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
/* Returns the USB Host Speed from the Low Level Driver. */ USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
{ USBH_SpeedTypeDef speed = USBH_SPEED_FULL; switch (HAL_HCD_GetCurrentSpeed(phost->pData)) { case 0: speed = USBH_SPEED_HIGH; break; case 1: speed = USBH_SPEED_FULL; break; case 2: speed = USBH_SPEED_LOW; break; default: speed = USBH_SPEED_FULL; break; ...
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Check if the requested element is in storage. */
BOOLEAN ElementValidation(IN HII_FORMSET_STORAGE *Storage, IN CHAR16 *RequestElement)
/* Check if the requested element is in storage. */ BOOLEAN ElementValidation(IN HII_FORMSET_STORAGE *Storage, IN CHAR16 *RequestElement)
{ return StrStr (Storage->ConfigRequest, RequestElement) != NULL ? TRUE : FALSE; }
tianocore/edk2
C++
Other
4,240
/* File Name : yc_gpio.c Author : Yichip Version : V1.0 Date : Description : gpio encapsulation. */
void GPIO_Config(GPIO_TypeDef GPIOx, uint16_t GPIO_Pin, GPIO_FunTypeDef function)
/* File Name : yc_gpio.c Author : Yichip Version : V1.0 Date : Description : gpio encapsulation. */ void GPIO_Config(GPIO_TypeDef GPIOx, uint16_t GPIO_Pin, GPIO_FunTypeDef function)
{ _ASSERT(ISGPIOGROUP(GPIOx)); _ASSERT(IS_GET_GPIO_PIN(GPIO_Pin)); int i; for (i = 0; i < GPIO_PIN_NUM; i++) { if (GPIO_Pin & 1 << i) GPIO_CONFIG(GPIOx * GPIO_PIN_NUM + i) = function; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
EFI_STATUS EFIAPI ConSplitterComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does no...
{ return LookupUnicodeString2 ( Language, This->SupportedLanguages, mConSplitterDriverNameTable, DriverName, (BOOLEAN)((This == &gConSplitterConInComponentName) || (This == &gConSplitterSimplePointerComponentName) || (Thi...
tianocore/edk2
C++
Other
4,240
/* The hardware priority mechanism only looks at the upper N bits of the priority level (where N is 3 for the Tiva C and E Series family), so any prioritization must be performed in those bits. */
void IntPriorityMaskSet(uint32_t ui32PriorityMask)
/* The hardware priority mechanism only looks at the upper N bits of the priority level (where N is 3 for the Tiva C and E Series family), so any prioritization must be performed in those bits. */ void IntPriorityMaskSet(uint32_t ui32PriorityMask)
{ CPUbasepriSet(ui32PriorityMask); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* If Context is NULL, then ASSERT(). If CpuIndex == BspIndex, then ASSERT(). If BspIndex or CpuIndex exceed the range of all CPUs in the system, then ASSERT(). */
VOID EFIAPI SmmCpuSyncReleaseOneAp(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN CpuIndex, IN UINTN BspIndex)
/* If Context is NULL, then ASSERT(). If CpuIndex == BspIndex, then ASSERT(). If BspIndex or CpuIndex exceed the range of all CPUs in the system, then ASSERT(). */ VOID EFIAPI SmmCpuSyncReleaseOneAp(IN OUT SMM_CPU_SYNC_CONTEXT *Context, IN UINTN CpuIndex, IN UINTN BspIndex)
{ ASSERT (Context != NULL); ASSERT (BspIndex != CpuIndex); ASSERT (CpuIndex < Context->NumberOfCpus); ASSERT (BspIndex < Context->NumberOfCpus); InternalReleaseSemaphore (Context->CpuSem[CpuIndex].Run); }
tianocore/edk2
C++
Other
4,240
/* Enable the interrupt to get timestamping interrupt. This enables the host to get the interrupt when (1) system time is greater or equal to the target time high and low register or (2) there is a overflow in th esecond register. */
void synopGMAC_TS_int_enable(synopGMACdevice *gmacdev)
/* Enable the interrupt to get timestamping interrupt. This enables the host to get the interrupt when (1) system time is greater or equal to the target time high and low register or (2) there is a overflow in th esecond register. */ void synopGMAC_TS_int_enable(synopGMACdevice *gmacdev)
{ synopGMACClearBits(gmacdev->MacBase,GmacInterruptMask,GmacPmtIntMask); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* When the timer frequency is 1MHz, each tick corresponds to 1 microsecond. Therefore, the nanosecond delay will be rounded up to the nearest 1 microsecond. */
UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
/* When the timer frequency is 1MHz, each tick corresponds to 1 microsecond. Therefore, the nanosecond delay will be rounded up to the nearest 1 microsecond. */ UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
{ UINTN MicroSeconds; MicroSeconds = NanoSeconds / 1000; MicroSeconds += ((NanoSeconds % 1000) == 0) ? 0 : 1; MicroSecondDelay (MicroSeconds); return NanoSeconds; }
tianocore/edk2
C++
Other
4,240
/* Safely get string from stdin. Function ignores all nonprintable characters. String may be finished by CR or NL. */
static void safe_gets(char *str, size_t nmax)
/* Safely get string from stdin. Function ignores all nonprintable characters. String may be finished by CR or NL. */ static void safe_gets(char *str, size_t nmax)
{ int c; char cstr[2] = {0, 0}; while (1) { c = NRF_LOG_GETCHAR(); if (isprint(c)) { *str++ = (char)c; cstr[0] = c; NRF_LOG_RAW_INFO("%s", nrf_log_push(cstr)); NRF_LOG_FLUSH(); if (0 == --nmax) break; ...
remotemcu/remcu-chip-sdks
C++
null
436
/* Disable kmemleak. No memory allocation/freeing will be traced once this function is called. Disabling kmemleak is an irreversible operation. */
static void kmemleak_disable(void)
/* Disable kmemleak. No memory allocation/freeing will be traced once this function is called. Disabling kmemleak is an irreversible operation. */ static void kmemleak_disable(void)
{ if (atomic_cmpxchg(&kmemleak_error, 0, 1)) return; atomic_set(&kmemleak_early_log, 0); atomic_set(&kmemleak_enabled, 0); if (atomic_read(&kmemleak_initialized)) schedule_work(&cleanup_work); pr_info("Kernel memory leak detector disabled\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* Enables or disables the TIMx peripheral Preload register on CCRx. */
void RTIM_OCxPreloadConfig(RTIM_TypeDef *TIMx, u32 TIM_OCProtection, u16 TIM_Channel)
/* Enables or disables the TIMx peripheral Preload register on CCRx. */ void RTIM_OCxPreloadConfig(RTIM_TypeDef *TIMx, u32 TIM_OCProtection, u16 TIM_Channel)
{ u32 tmpccmr = 0; assert_param(IS_TIM_PWM_TIM(TIMx)); assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCProtection)); assert_param(IS_TIM_CHANNEL(TIM_Channel)); tmpccmr = TIMx->CCMRx[TIM_Channel]; tmpccmr &= ~(TIM_OCER_CCxPE); tmpccmr |= TIM_OCProtection; TIMx->CCMRx[TIM_Channel] = tmpccmr; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* This function is used to enable the Timer frequency counter function. */
void TIMER_EnableFreqCounter(TIMER_T *timer, uint32_t u32DropCount, uint32_t u32Timeout, uint32_t u32EnableInt)
/* This function is used to enable the Timer frequency counter function. */ void TIMER_EnableFreqCounter(TIMER_T *timer, uint32_t u32DropCount, uint32_t u32Timeout, uint32_t u32EnableInt)
{ TIMER_T *t; t = (timer == TIMER0) ? TIMER1 : TIMER3; t->CMP = 0xFFFFFFUL; t->EXTCTL = u32EnableInt ? TIMER_EXTCTL_CAPIEN_Msk : 0UL; timer->CTL = TIMER_CTL_INTRGEN_Msk | TIMER_CTL_CNTEN_Msk; return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* brief Return Frequency of I3C function clock return Frequency of I3C function Clock */
uint32_t CLOCK_GetI3cClkFreq(void)
/* brief Return Frequency of I3C function clock return Frequency of I3C function Clock */ uint32_t CLOCK_GetI3cClkFreq(void)
{ uint32_t freq = 0U; switch (SYSCON->I3CFCLKSEL) { case 0U: freq = CLOCK_GetCoreSysClkFreq(); break; case 1U: freq = CLOCK_GetPllClkDivFreq(); break; default: freq = 0U; break; } return freq / ((SYSCON->...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This API reads the data from the given register address of the sensor. */
int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme280_dev *dev)
/* This API reads the data from the given register address of the sensor. */ int8_t bme280_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint16_t len, struct bme280_dev *dev)
{ int8_t rslt; rslt = null_ptr_check(dev); if ((rslt == BME280_OK) && (reg_data != NULL)) { if (dev->intf != BME280_I2C_INTF) { reg_addr = reg_addr | 0x80; } dev->intf_rslt = dev->read(reg_addr, reg_data, len, dev->intf_ptr); if (dev->intf_rslt != BME2...
eclipse-threadx/getting-started
C++
Other
310
/* This function is called for suspend and resume. */
static int vmwdt_power_event(struct notifier_block *this, unsigned long event, void *ptr)
/* This function is called for suspend and resume. */ static int vmwdt_power_event(struct notifier_block *this, unsigned long event, void *ptr)
{ switch (event) { case PM_POST_HIBERNATION: case PM_POST_SUSPEND: return vmwdt_resume(); case PM_HIBERNATION_PREPARE: case PM_SUSPEND_PREPARE: return vmwdt_suspend(); default: return NOTIFY_DONE; } }
robutest/uclinux
C++
GPL-2.0
60
/* Receives data from the TCP/IP server in a blocking manner. */
bool NetAccessReceive(uint8_t *data, uint32_t *length, uint32_t timeout)
/* Receives data from the TCP/IP server in a blocking manner. */ bool NetAccessReceive(uint8_t *data, uint32_t *length, uint32_t timeout)
{ bool result = false; int tv; int receivedLen; assert(data != NULL); assert(length != NULL); assert(timeout > 0); if ( (data != NULL) && (length != NULL) && (timeout > 0) && (winsockInitialized) ) { if (netAccessSocket != INVALID_SOCKET) { tv = (int)timeout; if (setsockopt(ne...
feaser/openblt
C++
GNU General Public License v3.0
601
/* Determins if the specified Generic Clock channel is locked. */
bool system_gclk_chan_is_locked(const uint8_t channel)
/* Determins if the specified Generic Clock channel is locked. */ bool system_gclk_chan_is_locked(const uint8_t channel)
{ bool locked; system_interrupt_enter_critical_section(); *((uint8_t*)&GCLK->CLKCTRL.reg) = channel; locked = GCLK->CLKCTRL.bit.WRTLOCK; system_interrupt_leave_critical_section(); return locked; }
memfault/zero-to-main
C++
null
200
/* The user Entry Point for module EmmcDxe. The user code starts with this function. */
EFI_STATUS EFIAPI InitializeEmmcDxe(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The user Entry Point for module EmmcDxe. The user code starts with this function. */ EFI_STATUS EFIAPI InitializeEmmcDxe(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gEmmcDxeDriverBinding, ImageHandle, &gEmmcDxeComponentName, &gEmmcDxeComponentName2 ); ASSERT_EFI_ERROR (Status); return...
tianocore/edk2
C++
Other
4,240
/* Used to catch tasks that attempt to return from their implementing function. */
static void prvTaskExitError(void)
/* Used to catch tasks that attempt to return from their implementing function. */ static void prvTaskExitError(void)
{ volatile uint32_t ulDummy = 0UL; configASSERT( ulCriticalNesting == ~0UL ); portDISABLE_INTERRUPTS(); while( ulDummy == 0 ) { } }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* copy from fs while checksumming, otherwise like csum_partial */
__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err)
/* copy from fs while checksumming, otherwise like csum_partial */ __wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *csum_err)
{ if (csum_err) *csum_err = 0; memcpy(dst, (__force const void *)src, len); return csum_partial(dst, len, sum); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* This function is used to set whether to inverse the capture input. */
int tls_pwm_capture_inverse_cmd(u8 channel, bool en)
/* This function is used to set whether to inverse the capture input. */ int tls_pwm_capture_inverse_cmd(u8 channel, bool en)
{ if (channel != 0 && channel != 4) return WM_FAILED; if (channel == 0) { if (ENABLE == en) tls_reg_write32(HR_PWM_CTL, tls_reg_read32(HR_PWM_CTL) | BIT(25)); else tls_reg_write32(HR_PWM_CTL, tls_reg_read32(HR_PWM_CTL) & (~BIT(25))); } else { ...
Nicholas3388/LuaNode
C++
Other
1,055
/* sparc_execve() executes a new program after the asm stub has set things up for us. This should basically do what I want it to. */
asmlinkage int sparc_execve(struct pt_regs *regs)
/* sparc_execve() executes a new program after the asm stub has set things up for us. This should basically do what I want it to. */ asmlinkage int sparc_execve(struct pt_regs *regs)
{ int error, base = 0; char *filename; if(regs->u_regs[UREG_G1] == 0) base = 1; filename = getname((char __user *)regs->u_regs[base + UREG_I0]); error = PTR_ERR(filename); if(IS_ERR(filename)) goto out; error = do_execve(filename, (char __user * __user *)regs->u_regs[base + UREG_I1], (char __user *...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Create a data segment, pad it, and calculate the CRC if needed. */
NET_BUF* IScsiNewDataSegment(IN UINT8 *Data, IN UINT32 Len, IN BOOLEAN DataDigest)
/* Create a data segment, pad it, and calculate the CRC if needed. */ NET_BUF* IScsiNewDataSegment(IN UINT8 *Data, IN UINT32 Len, IN BOOLEAN DataDigest)
{ NET_FRAGMENT Fragment[2]; UINT32 FragmentCount; UINT32 PadLen; NET_BUF *DataSeg; Fragment[0].Len = Len; Fragment[0].Bulk = Data; PadLen = ISCSI_GET_PAD_LEN (Len); if (PadLen != 0) { Fragment[1].Len = PadLen; Fragment[1].Bulk = (UINT8 *)&mDataSegPad; FragmentCount = 2...
tianocore/edk2
C++
Other
4,240
/* ccdc_restore_defaults() This function will write defaults to all CCDC registers */
static void ccdc_restore_defaults(void)
/* ccdc_restore_defaults() This function will write defaults to all CCDC registers */ static void ccdc_restore_defaults(void)
{ int i; ccdc_enable(0); for (i = 4; i <= 0x94; i += 4) regw(0, i); regw(CCDC_NO_CULLING, CCDC_CULLING); regw(CCDC_GAMMA_BITS_11_2, CCDC_ALAW); }
robutest/uclinux
C++
GPL-2.0
60
/* This records that previously allocated bandwidth has been released. Bandwidth is released when endpoints are removed from the host controller's periodic schedule. */
void usb_release_bandwidth(struct usb_host_virt_dev *dev, struct urb *urb, int isoc)
/* This records that previously allocated bandwidth has been released. Bandwidth is released when endpoints are removed from the host controller's periodic schedule. */ void usb_release_bandwidth(struct usb_host_virt_dev *dev, struct urb *urb, int isoc)
{ dev->bus->bandwidth_allocated -= urb->bandwidth; if (isoc) { dev->bus->bandwidth_isoc_reqs--; } else { dev->bus->bandwidth_int_reqs--; } urb->bandwidth = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* I2C MSP Initialization This function configures the hardware resources used in this example. */
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
/* I2C MSP Initialization This function configures the hardware resources used in this example. */ void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hi2c->Instance==I2C1) { __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks whether the Tamper Pin Interrupt has occurred or not. */
ITStatus BKP_GetITStatus(void)
/* Checks whether the Tamper Pin Interrupt has occurred or not. */ ITStatus BKP_GetITStatus(void)
{ return (ITStatus)(*(__IO uint32_t *) CSR_TIF_BB); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables or disables the selected DAC channel wave generation. */
void DAC_WaveGenerationCmd(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
/* Enables or disables the selected DAC channel wave generation. */ void DAC_WaveGenerationCmd(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState)
{ assert_param(IS_DAC_LIST1_PERIPH(DACx)); assert_param(IS_DAC_CHANNEL(DAC_Channel)); assert_param(IS_DAC_WAVE(DAC_Wave)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { DACx->CR |= DAC_Wave << DAC_Channel; } else { DACx->CR &= ~(DAC_Wave << DAC_Channel); } }
avem-labs/Avem
C++
MIT License
1,752