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
|
|---|---|---|---|---|---|---|---|
/* Task to manage an enumerated USB CDC device once connected, to print received data from the device to the serial port. */
|
void CDCHost_Task(void)
|
/* Task to manage an enumerated USB CDC device once connected, to print received data from the device to the serial port. */
void CDCHost_Task(void)
|
{
if (USB_HostState != HOST_STATE_Configured)
return;
if (CDC_Host_BytesReceived(&VirtualSerial_CDC_Interface))
{
int16_t ReceivedByte = CDC_Host_ReceiveByte(&VirtualSerial_CDC_Interface);
if (!(ReceivedByte < 0))
putchar(ReceivedByte);
}
}
|
prusa3d/Prusa-Firmware-Buddy
|
C++
|
Other
| 1,019
|
/* Change Logs: Date Author Notes airm2m first version */
|
void SystemClock_Config(void)
|
/* Change Logs: Date Author Notes airm2m first version */
void SystemClock_Config(void)
|
{
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)
;
RCC_PLLCmd(DISABLE);
AIR_RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_27, FLASH_Div_2);
RCC_PLLCmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
;
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_LSICmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
;
RCC_HSICmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET)
;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The @align_mask should be one less than a power of 2; the effect is that the bit offset of all zero areas this function finds is multiples of that power of 2. A @align_mask of 0 means no alignment is required. */
|
unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned long nr, unsigned long align_mask)
|
/* The @align_mask should be one less than a power of 2; the effect is that the bit offset of all zero areas this function finds is multiples of that power of 2. A @align_mask of 0 means no alignment is required. */
unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, unsigned long nr, unsigned long align_mask)
|
{
unsigned long index, end, i;
again:
index = find_next_zero_bit(map, size, start);
index = ALIGN_MASK(index, align_mask);
end = index + nr;
if (end > size) {
return end;
}
i = find_next_bit(map, end, index);
if (i < end) {
start = i + 1;
goto again;
}
return index;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* Stops the measurements on all channel and waits until the chip goes to sleep state. */
|
uint32_t SI1133_deInit(void)
|
/* Stops the measurements on all channel and waits until the chip goes to sleep state. */
uint32_t SI1133_deInit(void)
|
{
uint32_t retval;
retval = SI1133_paramSet( SI1133_PARAM_CH_LIST, 0x3f );
retval += SI1133_measurementPause();
retval += SI1133_waitUntilSleep();
return retval;
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
|
void HAL_Delay(__IO uint32_t Delay)
|
/* This function provides accurate delay (in milliseconds) based on SysTick counter flag. */
void HAL_Delay(__IO uint32_t Delay)
|
{
while(Delay)
{
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)
{
Delay--;
}
}
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* Return the 384-bit message digest into the user's array */
|
void ICACHE_FLASH_ATTR SHA384_Final(uint8_t *digest, SHA384_CTX *ctx)
|
/* Return the 384-bit message digest into the user's array */
void ICACHE_FLASH_ATTR SHA384_Final(uint8_t *digest, SHA384_CTX *ctx)
|
{
SHA512_Final(NULL, ctx);
if (digest != NULL)
memcpy(digest, ctx->h_dig.digest, SHA384_SIZE);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Enable and Set DAC Channel Waveform Generation.
Enable the digital to analog converter waveform generation as either pseudo-random noise or triangular wave. These signals are superimposed on existing output values in the DAC output registers. */
|
void dac_set_waveform_generation(uint32_t dac_wave_ens)
|
/* Enable and Set DAC Channel Waveform Generation.
Enable the digital to analog converter waveform generation as either pseudo-random noise or triangular wave. These signals are superimposed on existing output values in the DAC output registers. */
void dac_set_waveform_generation(uint32_t dac_wave_ens)
|
{
DAC_CR |= dac_wave_ens;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* like unpin only we have to also clear the xaction descriptor pointing the log item if we free the item. This routine duplicates unpin because efi_flags is protected by the AIL lock. Freeing the descriptor and then calling unpin would force us to drop the AIL lock which would open up a race condition. */
|
STATIC void xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
|
/* like unpin only we have to also clear the xaction descriptor pointing the log item if we free the item. This routine duplicates unpin because efi_flags is protected by the AIL lock. Freeing the descriptor and then calling unpin would force us to drop the AIL lock which would open up a race condition. */
STATIC void xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
|
{
struct xfs_ail *ailp = efip->efi_item.li_ailp;
xfs_log_item_desc_t *lidp;
spin_lock(&ailp->xa_lock);
if (efip->efi_flags & XFS_EFI_CANCELED) {
lidp = xfs_trans_find_item(tp, (xfs_log_item_t *) efip);
xfs_trans_free_item(tp, lidp);
xfs_trans_ail_delete(ailp, (xfs_log_item_t *)efip);
xfs_efi_item_free(efip);
} else {
efip->efi_flags |= XFS_EFI_COMMITTED;
spin_unlock(&ailp->xa_lock);
}
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Compare the Unicode string pointed by String to the string pointed by String2. */
|
INTN EFIAPI StriCmp(IN CHAR16 *String, IN CHAR16 *String2)
|
/* Compare the Unicode string pointed by String to the string pointed by String2. */
INTN EFIAPI StriCmp(IN CHAR16 *String, IN CHAR16 *String2)
|
{
while ((*String != L'\0') &&
(CharToUpper (*String) == CharToUpper (*String2)))
{
String++;
String2++;
}
return CharToUpper (*String) - CharToUpper (*String2);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Start ADC calibration and wait for it to finish. The ADC must have been powered down for at least 2 ADC clock cycles, then powered on before calibration starts */
|
void adc_calibrate(uint32_t adc)
|
/* Start ADC calibration and wait for it to finish. The ADC must have been powered down for at least 2 ADC clock cycles, then powered on before calibration starts */
void adc_calibrate(uint32_t adc)
|
{
adc_calibrate_async(adc);
while (adc_is_calibrating(adc));
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* If the BSP cannot be switched prior to the return from this service, then EFI_UNSUPPORTED must be returned. */
|
EFI_STATUS EFIAPI EdkiiPeiSwitchBSP(IN EDKII_PEI_MP_SERVICES2_PPI *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
|
/* If the BSP cannot be switched prior to the return from this service, then EFI_UNSUPPORTED must be returned. */
EFI_STATUS EFIAPI EdkiiPeiSwitchBSP(IN EDKII_PEI_MP_SERVICES2_PPI *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
|
{
return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get Accessibility Mode.
Get the accessibility mode of the device. */
|
ADI_BLER_RESULT adi_radio_GetMode(ADI_BLE_GAP_MODE *const pBleMode)
|
/* Get Accessibility Mode.
Get the accessibility mode of the device. */
ADI_BLER_RESULT adi_radio_GetMode(ADI_BLE_GAP_MODE *const pBleMode)
|
{
ADI_BLER_RESULT bleResult;
ASSERT(pBleMode != NULL);
ADI_BLE_LOGEVENT(LOGID_CMD_BLEGAP_GET_MODE);
ADI_BLE_RADIO_CMD_START(CMD_BLEGAP_GET_MODE);
bleResult = bler_process_cmd(CMD_BLEGAP_GET_MODE, 0u, pBleMode, sizeof(ADI_BLE_GAP_MODE));
if(bleResult == ADI_BLER_SUCCESS){
bleResult = ADI_BLE_WAIT_FOR_COMPLETION(ADI_EVENT_FLAG_RESP_SUCCESS,ADI_BLER_CMD_TIMEOUT);
}
ADI_BLE_RADIO_CMD_END();
return (bleResult);
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Set the GPIO bit data(status) for bit.
@method GPIO_SetBits */
|
void GPIO_SetBits(GPIO_TypeDef GPIOx, uint16_t GPIO_Pin)
|
/* Set the GPIO bit data(status) for bit.
@method GPIO_SetBits */
void GPIO_SetBits(GPIO_TypeDef GPIOx, uint16_t GPIO_Pin)
|
{
_ASSERT(IS_GPIO_PORT(GPIOx));
_ASSERT(IS_GPIO_PIN(GPIO_Pin));
for(uint8_t i = 0; i < GPIO_PIN_NUM; i++)
{
if(GPIO_Pin & (BIT0<<i))
{
MGPIO->CTRL.reg[GPIO_GetNum(GPIOx, (BIT0<<i))] = OUTPUT_HIGH;
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* We can choose between IRQ based or polled IO. This needs to be called before omap_mcbsp_request(). */
|
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
|
/* We can choose between IRQ based or polled IO. This needs to be called before omap_mcbsp_request(). */
int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type)
|
{
struct omap_mcbsp *mcbsp;
if (!omap_mcbsp_check_valid_id(id)) {
printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
return -ENODEV;
}
mcbsp = id_to_mcbsp_ptr(id);
spin_lock(&mcbsp->lock);
if (!mcbsp->free) {
dev_err(mcbsp->dev, "McBSP%d is currently in use\n",
mcbsp->id);
spin_unlock(&mcbsp->lock);
return -EINVAL;
}
mcbsp->io_type = io_type;
spin_unlock(&mcbsp->lock);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Sets the RF Management configuration.
Needs the I2C Password presentation to be effective. */
|
int32_t ST25DV_WriteRFMngt(ST25DV_Object_t *pObj, const uint8_t Rfmngt)
|
/* Sets the RF Management configuration.
Needs the I2C Password presentation to be effective. */
int32_t ST25DV_WriteRFMngt(ST25DV_Object_t *pObj, const uint8_t Rfmngt)
|
{
return st25dv_set_rf_mngt_all(&(pObj->Ctx), &Rfmngt);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Enables or disables the ADCx conversion through external trigger. */
|
void ADC_ExternalTrigConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
/* Enables or disables the ADCx conversion through external trigger. */
void ADC_ExternalTrigConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
|
{
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
ADCx->CR2 |= CR2_EXTTRIG_Set;
}
else
{
ADCx->CR2 &= CR2_EXTTRIG_Reset;
}
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo. */
|
BOOLEAN IsSystemFmpImage(IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader)
|
/* Return if this FMP is a system FMP or a device FMP, based upon FmpImageInfo. */
BOOLEAN IsSystemFmpImage(IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader)
|
{
GUID *Guid;
UINTN Count;
UINTN Index;
Guid = PcdGetPtr (PcdSystemFmpCapsuleImageTypeIdGuid);
Count = PcdGetSize (PcdSystemFmpCapsuleImageTypeIdGuid) / sizeof (GUID);
for (Index = 0; Index < Count; Index++, Guid++) {
if (CompareGuid (&FmpImageHeader->UpdateImageTypeId, Guid)) {
return TRUE;
}
}
return FALSE;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Check to see if the ISA is supported. ISA = Instruction Set Architecture */
|
BOOLEAN CheckIsa(IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
|
/* Check to see if the ISA is supported. ISA = Instruction Set Architecture */
BOOLEAN CheckIsa(IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
|
{
if (Isa == IsaArm) {
return TRUE;
} else {
return FALSE;
}
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enable the SPI interrupt of the specified SPI port. */
|
void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
|
/* Enable the SPI interrupt of the specified SPI port. */
void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE));
xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_IE;
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* Returns: the index of the first bit set which is higher than @nth_bit, or -1 if no higher bits are set */
|
gint() g_bit_nth_lsf(gulong mask, gint nth_bit)
|
/* Returns: the index of the first bit set which is higher than @nth_bit, or -1 if no higher bits are set */
gint() g_bit_nth_lsf(gulong mask, gint nth_bit)
|
{
return g_bit_nth_lsf_impl (mask, nth_bit);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Selects Batching Data Rate (writing frequency in FIFO) for temperature data.. */
|
int32_t lsm6dso_fifo_temp_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_t_batch_t val)
|
/* Selects Batching Data Rate (writing frequency in FIFO) for temperature data.. */
int32_t lsm6dso_fifo_temp_batch_set(lsm6dso_ctx_t *ctx, lsm6dso_odr_t_batch_t val)
|
{
lsm6dso_fifo_ctrl4_t reg;
int32_t ret;
ret = lsm6dso_read_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1);
if (ret == 0) {
reg.odr_t_batch = (uint8_t)val;
ret = lsm6dso_write_reg(ctx, LSM6DSO_FIFO_CTRL4, (uint8_t*)®, 1);
}
return ret;
}
|
alexander-g-dean/ESF
|
C++
| null | 41
|
/* Causes a blocking delay for 'delayTicks' ticks on the systick timer. For example: systickDelay(100) would cause a blocking delay for 100 ticks of the systick timer. */
|
void systickDelay(uint32_t delayTicks)
|
/* Causes a blocking delay for 'delayTicks' ticks on the systick timer. For example: systickDelay(100) would cause a blocking delay for 100 ticks of the systick timer. */
void systickDelay(uint32_t delayTicks)
|
{
uint32_t curTicks;
curTicks = systickTicks;
if (delayTicks == 0) delayTicks = 1;
if (curTicks > 0xFFFFFFFF - delayTicks)
{
while (systickTicks >= curTicks)
{
while (systickTicks < (delayTicks - (0xFFFFFFFF - curTicks)));
}
}
else
{
while ((systickTicks - curTicks) < delayTicks);
}
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* Receive a buffer of data bytes in non-blocking way. */
|
static void ECSPI_ReadNonBlocking(ECSPI_Type *base, uint32_t *buffer, size_t size)
|
/* Receive a buffer of data bytes in non-blocking way. */
static void ECSPI_ReadNonBlocking(ECSPI_Type *base, uint32_t *buffer, size_t size)
|
{
if (NULL != buffer)
{
while (size--)
{
*buffer++ = ECSPI_ReadData(base);
}
}
else
{
while (size--)
{
(void)ECSPI_ReadData(base);
}
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the functio shall return EFI_DEVICE_ERROR. */
|
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
|
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the functio shall return EFI_DEVICE_ERROR. */
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
|
{
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {
return EFI_INVALID_PARAMETER;
}
Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
if ((DeviceIndex == 0) || (DeviceIndex > Private->TrustComputingDevices)) {
return EFI_INVALID_PARAMETER;
}
DeviceData = SearchTrustComputingDeviceByIndex (Private, DeviceIndex);
if (DeviceData == NULL) {
return EFI_NOT_FOUND;
}
ASSERT ((DeviceData->IdentifyData->trusted_computing_support & BIT0) != 0);
if ((DeviceData->IdentifyData->trusted_computing_support & BIT0) == 0) {
return EFI_UNSUPPORTED;
}
return TrustTransferAtaDevice (
DeviceData,
PayloadBuffer,
SecurityProtocolId,
SecurityProtocolSpecificData,
PayloadBufferSize,
TRUE,
Timeout,
NULL
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
|
void Vector54_handler(void)
|
/* ISR handler for a specific vector index in the interrupt vector table for linking the actual interrupts vectors to the one in the user program's vector table. */
void Vector54_handler(void)
|
{
asm
{
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (54 * 2))
JMP 0,X
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* Function for dispatching a system event to interested modules.
This function is called from the System event interrupt handler after a system event has been received. */
|
static void sys_evt_dispatch(uint32_t sys_evt)
|
/* Function for dispatching a system event to interested modules.
This function is called from the System event interrupt handler after a system event has been received. */
static void sys_evt_dispatch(uint32_t sys_evt)
|
{
pstorage_sys_event_handler(sys_evt);
on_sys_evt(sys_evt);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* NOTE: we do not run the func for devices that do not appear to be PCI except for the start node which we assume (this is good because the start node is often a phb which may be missing PCI properties). We use the class-code as an indicator. If we run into one of these nodes we also assume its siblings are non-pci for performance. */
|
void* traverse_pci_devices(struct device_node *start, traverse_func pre, void *data)
|
/* NOTE: we do not run the func for devices that do not appear to be PCI except for the start node which we assume (this is good because the start node is often a phb which may be missing PCI properties). We use the class-code as an indicator. If we run into one of these nodes we also assume its siblings are non-pci for performance. */
void* traverse_pci_devices(struct device_node *start, traverse_func pre, void *data)
|
{
struct device_node *dn, *nextdn;
void *ret;
for (dn = start->child; dn; dn = nextdn) {
const u32 *classp;
u32 class;
nextdn = NULL;
classp = of_get_property(dn, "class-code", NULL);
class = classp ? *classp : 0;
if (pre && ((ret = pre(dn, data)) != NULL))
return ret;
if (dn->child && ((class >> 8) == PCI_CLASS_BRIDGE_PCI ||
(class >> 8) == PCI_CLASS_BRIDGE_CARDBUS))
nextdn = dn->child;
else if (dn->sibling)
nextdn = dn->sibling;
if (!nextdn) {
do {
dn = dn->parent;
if (dn == start)
return NULL;
} while (dn->sibling == NULL);
nextdn = dn->sibling;
}
}
return NULL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* This is the Event call back function is triggered in SMM to notify the Library the system is entering runtime phase. */
|
EFI_STATUS EFIAPI SmmCorePerformanceLibExitBootServicesCallback(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
|
/* This is the Event call back function is triggered in SMM to notify the Library the system is entering runtime phase. */
EFI_STATUS EFIAPI SmmCorePerformanceLibExitBootServicesCallback(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
|
{
mPerformanceMeasurementEnabled = FALSE;
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */
|
void SDLTest_Md5Init(SDLTest_Md5Context *mdContext)
|
/* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */
void SDLTest_Md5Init(SDLTest_Md5Context *mdContext)
|
{
if (mdContext==NULL) return;
mdContext->i[0] = mdContext->i[1] = (MD5UINT4) 0;
mdContext->buf[0] = (MD5UINT4) 0x67452301;
mdContext->buf[1] = (MD5UINT4) 0xefcdab89;
mdContext->buf[2] = (MD5UINT4) 0x98badcfe;
mdContext->buf[3] = (MD5UINT4) 0x10325476;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This routine is called to bring the HBA offline when HBA hardware error other than Port Error 6 has been detected. */
|
static void lpfc_offline_eratt(struct lpfc_hba *phba)
|
/* This routine is called to bring the HBA offline when HBA hardware error other than Port Error 6 has been detected. */
static void lpfc_offline_eratt(struct lpfc_hba *phba)
|
{
struct lpfc_sli *psli = &phba->sli;
spin_lock_irq(&phba->hbalock);
psli->sli_flag &= ~LPFC_SLI_ACTIVE;
spin_unlock_irq(&phba->hbalock);
lpfc_offline_prep(phba);
lpfc_offline(phba);
lpfc_reset_barrier(phba);
spin_lock_irq(&phba->hbalock);
lpfc_sli_brdreset(phba);
spin_unlock_irq(&phba->hbalock);
lpfc_hba_down_post(phba);
lpfc_sli_brdready(phba, HS_MBRDY);
lpfc_unblock_mgmt_io(phba);
phba->link_state = LPFC_HBA_ERROR;
return;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Wake up the HVC thread to trigger hang-up and respective HVC back-end notifier invocations. */
|
static int hvc_iucv_pm_restore_thaw(struct device *dev)
|
/* Wake up the HVC thread to trigger hang-up and respective HVC back-end notifier invocations. */
static int hvc_iucv_pm_restore_thaw(struct device *dev)
|
{
hvc_kick();
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted: */
|
u32 COMP_GetOutputLevel(COMP_Selection_TypeDef selection)
|
/* Return the output level (high or low) of the selected comparator. The output level depends on the selected polarity. If the polarity is not inverted: */
u32 COMP_GetOutputLevel(COMP_Selection_TypeDef selection)
|
{
return (((*(vu32*)(COMP_BASE + selection) & COMP_CSR_STA) != 0) ?
COMP_OutputLevel_High :
COMP_OutputLevel_Low );
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Please refer to the official documentation for function purpose and expected parameters. */
|
int ph7_value_is_float(ph7_value *pVal)
|
/* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_value_is_float(ph7_value *pVal)
|
{
return (pVal->iFlags & MEMOBJ_INT) ? TRUE : FALSE;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* This routine sets the configuration fields for an existing device's descriptor. It only works for the last device, but that's OK because that's how we use it. */
|
static void set_config(struct device *dev, unsigned len, const void *conf)
|
/* This routine sets the configuration fields for an existing device's descriptor. It only works for the last device, but that's OK because that's how we use it. */
static void set_config(struct device *dev, unsigned len, const void *conf)
|
{
if (device_config(dev) + len > devices.descpage + getpagesize())
errx(1, "Too many devices");
memcpy(device_config(dev), conf, len);
dev->desc->config_len = len;
assert(dev->desc->config_len == len);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Lock free operation, be careful of the use scheme Returns: _TRUE push success */
|
bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf)
|
/* Lock free operation, be careful of the use scheme Returns: _TRUE push success */
bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf)
|
{
if (rtw_cbuf_full(cbuf))
return _FAIL;
if (0)
DBG_871X("%s on %u\n", __func__, cbuf->write);
cbuf->bufs[cbuf->write] = buf;
cbuf->write = (cbuf->write+1)%cbuf->size;
return _SUCCESS;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* If Map is NULL, then ASSERT(). If Key is NULL, then ASSERT(). */
|
NET_MAP_ITEM* EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
|
/* If Map is NULL, then ASSERT(). If Key is NULL, then ASSERT(). */
NET_MAP_ITEM* EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
|
{
LIST_ENTRY *Entry;
NET_MAP_ITEM *Item;
ASSERT (Map != NULL && Key != NULL);
NET_LIST_FOR_EACH (Entry, &Map->Used) {
Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
if (Item->Key == Key) {
return Item;
}
}
return NULL;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* A note about the "bias" calculations: when rounding fractional values to integer, we do not want to always round 0.5 up to the next integer. If we did that, we'd introduce a noticeable bias towards larger values. Instead, this code is arranged so that 0.5 will be rounded up or down at alternate pixel locations (a simple ordered dither pattern). */
|
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
|
/* A note about the "bias" calculations: when rounding fractional values to integer, we do not want to always round 0.5 up to the next integer. If we did that, we'd introduce a noticeable bias towards larger values. Instead, this code is arranged so that 0.5 will be rounded up or down at alternate pixel locations (a simple ordered dither pattern). */
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY input_data, JSAMPARRAY output_data)
|
{
int inrow;
JDIMENSION outcol;
JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
register JSAMPROW inptr, outptr;
register int bias;
expand_right_edge(input_data, cinfo->max_v_samp_factor,
cinfo->image_width, output_cols * 2);
for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
outptr = output_data[inrow];
inptr = input_data[inrow];
bias = 0;
for (outcol = 0; outcol < output_cols; outcol++) {
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
+ bias) >> 1);
bias ^= 1;
inptr += 2;
}
}
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* If e1000_update_eeprom_checksum is not called after this function, the EEPROM will most likely contain an invalid checksum. */
|
s32 e1000_write_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
|
/* If e1000_update_eeprom_checksum is not called after this function, the EEPROM will most likely contain an invalid checksum. */
s32 e1000_write_eeprom(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
|
{
s32 ret;
spin_lock(&e1000_eeprom_lock);
ret = e1000_do_write_eeprom(hw, offset, words, data);
spin_unlock(&e1000_eeprom_lock);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* param blendedAlpha The desired blended alpha value, alpha range 0~255. param globalAlpha Calculated global alpha set to each layer register. param layerCount Total layer count. retval kStatus_Success Get successfully. retval kStatus_InvalidArgument The argument is invalid. */
|
status_t LCDIFV2_GetMultiLayerGlobalAlpha(const uint8_t blendedAlpha[], uint8_t globalAlpha[], uint8_t layerCount)
|
/* param blendedAlpha The desired blended alpha value, alpha range 0~255. param globalAlpha Calculated global alpha set to each layer register. param layerCount Total layer count. retval kStatus_Success Get successfully. retval kStatus_InvalidArgument The argument is invalid. */
status_t LCDIFV2_GetMultiLayerGlobalAlpha(const uint8_t blendedAlpha[], uint8_t globalAlpha[], uint8_t layerCount)
|
{
status_t status = kStatus_Success;
int16_t curLayer = (int16_t)layerCount - 1;
int left = 255;
int tmpAlpha;
assert((layerCount > 1U) && (layerCount <= (uint8_t)LCDIFV2_LAYER_COUNT));
globalAlpha[0] = 255U;
while (curLayer > 0)
{
tmpAlpha = (int)blendedAlpha[curLayer] * 255 / left;
if (tmpAlpha > 255)
{
status = kStatus_InvalidArgument;
break;
}
globalAlpha[curLayer] = (uint8_t)tmpAlpha;
left -= (int)blendedAlpha[curLayer];
if (left <= 0)
{
status = kStatus_InvalidArgument;
break;
}
curLayer--;
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Reads AES128 key from EEPROM Reads the AES128 key from fileID #12 in EEPROM returns an error if the key does not exist.
aes_read_key */
|
INT32 aes_read_key(UINT8 *key)
|
/* Reads AES128 key from EEPROM Reads the AES128 key from fileID #12 in EEPROM returns an error if the key does not exist.
aes_read_key */
INT32 aes_read_key(UINT8 *key)
|
{
INT32 returnValue;
returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
return returnValue;
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* This function is used to check if the Cmd and Dat buses are high. */
|
s32 XSdPs_CheckBusHigh(XSdPs *InstancePtr)
|
/* This function is used to check if the Cmd and Dat buses are high. */
s32 XSdPs_CheckBusHigh(XSdPs *InstancePtr)
|
{
u32 Timeout = 10000;
s32 Status;
u32 ReadReg;
Timeout = MAX_TIMEOUT;
do {
ReadReg = XSdPs_ReadReg(InstancePtr->Config.BaseAddress,
XSDPS_PRES_STATE_OFFSET);
Timeout = Timeout - 1;
usleep(1);
} while (((ReadReg & (XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK))
!= (XSDPS_PSR_CMD_SG_LVL_MASK | XSDPS_PSR_DAT30_SG_LVL_MASK))
&& (Timeout != 0U));
if (Timeout == 0U) {
Status = XST_FAILURE;
goto RETURN_PATH ;
}
Status = XST_SUCCESS;
RETURN_PATH:
return Status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Find a PMC slot for the freshly enabled / scheduled in event: */
|
static int x86_pmu_enable(struct perf_event *event)
|
/* Find a PMC slot for the freshly enabled / scheduled in event: */
static int x86_pmu_enable(struct perf_event *event)
|
{
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
struct hw_perf_event *hwc = &event->hw;
int idx;
idx = x86_schedule_event(cpuc, hwc);
if (idx < 0)
return idx;
perf_events_lapic_init();
x86_pmu.disable(hwc, idx);
cpuc->events[idx] = event;
set_bit(idx, cpuc->active_mask);
x86_perf_event_set_period(event, hwc, idx);
x86_pmu.enable(hwc, idx);
perf_event_update_userpage(event);
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Indicates whether DMA transfer is in progress or completed. */
|
dmacHw_TRANSFER_STATUS_e dmacHw_transferCompleted(dmacHw_HANDLE_t handle)
|
/* Indicates whether DMA transfer is in progress or completed. */
dmacHw_TRANSFER_STATUS_e dmacHw_transferCompleted(dmacHw_HANDLE_t handle)
|
{
dmacHw_CBLK_t *pCblk = dmacHw_HANDLE_TO_CBLK(handle);
if (CHANNEL_BUSY(pCblk->module, pCblk->channel)) {
return dmacHw_TRANSFER_STATUS_BUSY;
} else if (dmacHw_REG_INT_RAW_ERROR(pCblk->module) &
(0x00000001 << pCblk->channel)) {
return dmacHw_TRANSFER_STATUS_ERROR;
}
return dmacHw_TRANSFER_STATUS_DONE;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source. The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable */
|
void FLEXIO_SPI_EnableInterrupts(FLEXIO_SPI_Type *base, uint32_t mask)
|
/* param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source. The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable */
void FLEXIO_SPI_EnableInterrupts(FLEXIO_SPI_Type *base, uint32_t mask)
|
{
if ((mask & (uint32_t)kFLEXIO_SPI_TxEmptyInterruptEnable) != 0U)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[0]);
}
if ((mask & (uint32_t)kFLEXIO_SPI_RxFullInterruptEnable) != 0U)
{
FLEXIO_EnableShifterStatusInterrupts(base->flexioBase, 1UL << base->shifterIndex[1]);
}
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* @handle: EFI handle of the block device @dev: udevice of the block device Return: number of partitions created */
|
static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev)
|
/* @handle: EFI handle of the block device @dev: udevice of the block device Return: number of partitions created */
static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev)
|
{
struct blk_desc *desc;
const char *if_typename;
desc = dev_get_uclass_platdata(dev);
if_typename = blk_get_if_type_name(desc->if_type);
return efi_disk_create_partitions(handle, desc, if_typename,
desc->devnum, dev->name);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* If the Guest expects to have an Advanced Programmable Interrupt Controller, we play dumb by ignoring writes and returning 0 for reads. So it's no longer Programmable nor Controlling anything, and I don't think 8 lines of code qualifies for Advanced. It will also never interrupt anything. It does, however, allow us to get through the Linux boot code. */
|
static void lguest_safe_halt(void)
|
/* If the Guest expects to have an Advanced Programmable Interrupt Controller, we play dumb by ignoring writes and returning 0 for reads. So it's no longer Programmable nor Controlling anything, and I don't think 8 lines of code qualifies for Advanced. It will also never interrupt anything. It does, however, allow us to get through the Linux boot code. */
static void lguest_safe_halt(void)
|
{
kvm_hypercall0(LHCALL_HALT);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns 64bit Octeon IO base address for read/write */
|
static uint64_t cvmx_pcie_get_mem_base_address(int pcie_port)
|
/* Returns 64bit Octeon IO base address for read/write */
static uint64_t cvmx_pcie_get_mem_base_address(int pcie_port)
|
{
union cvmx_pcie_address pcie_addr;
pcie_addr.u64 = 0;
pcie_addr.mem.upper = 0;
pcie_addr.mem.io = 1;
pcie_addr.mem.did = 3;
pcie_addr.mem.subdid = 3 + pcie_port;
return pcie_addr.u64;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Get the vertical offset from the full / physical display */
|
lv_coord_t lv_disp_get_offset_y(lv_disp_t *disp)
|
/* Get the vertical offset from the full / physical display */
lv_coord_t lv_disp_get_offset_y(lv_disp_t *disp)
|
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) {
return 0;
}
else {
switch(disp->driver->rotated) {
case LV_DISP_ROT_90:
return disp->driver->offset_x;
case LV_DISP_ROT_180:
return lv_disp_get_physical_ver_res(disp) - disp->driver->offset_y;
case LV_DISP_ROT_270:
return lv_disp_get_physical_ver_res(disp) - disp->driver->offset_x;
default:
return disp->driver->offset_y;
}
}
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* vpif_buffer_release: This function is called from the videobuf layer to free memory allocated to the buffers */
|
static void vpif_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
/* vpif_buffer_release: This function is called from the videobuf layer to free memory allocated to the buffers */
static void vpif_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
|
{
struct vpif_fh *fh = q->priv_data;
struct channel_obj *ch = fh->channel;
struct common_obj *common;
unsigned int buf_size = 0;
common = &ch->common[VPIF_VIDEO_INDEX];
videobuf_dma_contig_free(q, vb);
vb->state = VIDEOBUF_NEEDS_INIT;
if (V4L2_MEMORY_MMAP != common->memory)
return;
buf_size = config_params.channel_bufsize[ch->channel_id];
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Returns the last ADC1, ADC2, ADC3 and ADC4 regular conversions results data in the selected dual mode. */
|
uint32_t ADC_GetDualModeConversionValue(ADC_TypeDef *ADCx)
|
/* Returns the last ADC1, ADC2, ADC3 and ADC4 regular conversions results data in the selected dual mode. */
uint32_t ADC_GetDualModeConversionValue(ADC_TypeDef *ADCx)
|
{
uint32_t tmpreg1 = 0;
assert_param(IS_ADC_ALL_PERIPH(ADCx));
if((ADCx == ADC1) || (ADCx== ADC2))
{
tmpreg1 = ADC1_2->CDR;
}
else
{
tmpreg1 = ADC3_4->CDR;
}
return (uint32_t) tmpreg1;
}
|
ajhc/demo-cortex-m3
|
C++
| null | 38
|
/* About: Purpose Implementation of the USB Interrupt Handler. Call Arbitrer, device and host interrupt handler. The IRQ functions are defined with weak and can be surcharged if needed. */
|
void USB_IrqHandler(void)
|
/* About: Purpose Implementation of the USB Interrupt Handler. Call Arbitrer, device and host interrupt handler. The IRQ functions are defined with weak and can be surcharged if needed. */
void USB_IrqHandler(void)
|
{
usb_general_interrupt();
USBD_IrqHandler();
usb_pipe_interrupt();
}
|
opentx/opentx
|
C++
|
GNU General Public License v2.0
| 2,025
|
/* Configure board USART communication with PC or other terminal. */
|
static void configure_usart(void)
|
/* Configure board USART communication with PC or other terminal. */
static void configure_usart(void)
|
{
const sam_usart_opt_t usart_console_settings = {
BOARD_USART_BAUDRATE,
US_MR_CHRL_8_BIT,
US_MR_PAR_NO,
US_MR_NBSTOP_1_BIT,
US_MR_CHMODE_NORMAL,
BOARD_USART_IRDA_FILTER
};
sysclk_enable_peripheral_clock(BOARD_ID_USART);
usart_init_irda(BOARD_USART, &usart_console_settings, sysclk_get_peripheral_hz());
usart_disable_interrupt(BOARD_USART, ALL_INTERRUPT_MASK);
usart_enable_tx(BOARD_USART);
usart_enable_rx(BOARD_USART);
NVIC_EnableIRQ(USART_IRQn);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Event handler for events from the peer_database module. */
|
static void pdb_evt_handler(pdb_evt_t const *p_event)
|
/* Event handler for events from the peer_database module. */
static void pdb_evt_handler(pdb_evt_t const *p_event)
|
{
gccm_evt_t gccm_evt;
gccm_evt.evt_id = GCCM_EVT_REMOTE_DB_STORED;
gccm_evt.peer_id = p_event->peer_id;
m_gccm.evt_handler(&gccm_evt);
}
|
labapart/polymcu
|
C++
| null | 201
|
/* ubifs_scan_destroy - destroy LEB scanning information. @sleb: scanning information to free */
|
void ubifs_scan_destroy(struct ubifs_scan_leb *sleb)
|
/* ubifs_scan_destroy - destroy LEB scanning information. @sleb: scanning information to free */
void ubifs_scan_destroy(struct ubifs_scan_leb *sleb)
|
{
struct ubifs_scan_node *node;
struct list_head *head;
head = &sleb->nodes;
while (!list_empty(head)) {
node = list_entry(head->next, struct ubifs_scan_node, list);
list_del(&node->list);
kfree(node);
}
kfree(sleb);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Read the color of a specified pixel This function is added by onelife. */
|
EMSTATUS DMD_readPixel(uint16_t x, uint16_t y, uint16_t *color)
|
/* Read the color of a specified pixel This function is added by onelife. */
EMSTATUS DMD_readPixel(uint16_t x, uint16_t y, uint16_t *color)
|
{
uint32_t statusCode;
if (!initialized){
return DMD_ERROR_DRIVER_NOT_INITIALIZED;
}
statusCode = setPixelAddress(x, y);
if (statusCode != DMD_OK){
return statusCode;
}
DMDIF_prepareDataAccess( );
*color = DMDIF_readData() & 0x0000FFFF;
return DMD_OK;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Set the palette color of an indexed image. Valid only for */
|
void lv_img_buf_set_palette(lv_img_dsc_t *dsc, uint8_t id, lv_color_t c)
|
/* Set the palette color of an indexed image. Valid only for */
void lv_img_buf_set_palette(lv_img_dsc_t *dsc, uint8_t id, lv_color_t c)
|
{
if((dsc->header.cf == LV_IMG_CF_ALPHA_1BIT && id > 1) || (dsc->header.cf == LV_IMG_CF_ALPHA_2BIT && id > 3) ||
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && id > 15) || (dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)) {
LV_LOG_WARN("lv_img_buf_set_px_alpha: invalid 'id'");
return;
}
lv_color32_t c32;
c32.full = lv_color_to32(c);
uint8_t * buf = (uint8_t *)dsc->data;
memcpy(&buf[id * sizeof(c32)], &c32, sizeof(c32));
}
|
alibaba/AliOS-Things
|
C++
|
Apache License 2.0
| 4,536
|
/* Block until a buffer comes unlocked. This doesn't stop it from becoming locked again - you have to lock it yourself if you want to preserve its state. */
|
void __wait_on_buffer(struct buffer_head *bh)
|
/* Block until a buffer comes unlocked. This doesn't stop it from becoming locked again - you have to lock it yourself if you want to preserve its state. */
void __wait_on_buffer(struct buffer_head *bh)
|
{
wait_on_bit(&bh->b_state, BH_Lock, sync_buffer, TASK_UNINTERRUPTIBLE);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Detect HART command zero from a freshly received buffer. */
|
static int32_t cn0414_process_hart_detect_command_zero(struct cn0414_dev *dev)
|
/* Detect HART command zero from a freshly received buffer. */
static int32_t cn0414_process_hart_detect_command_zero(struct cn0414_dev *dev)
|
{
uint8_t i = 1, k = 0;
i = 1;
while(i <= 20) {
if(dev->hart_buffer[i] == 0xFF) {
i++;
continue;
} else {
break;
}
}
if(i <= 20) {
for(k = 0; k < HART_COMMAND_ZERO_SIZE; k++) {
if(dev->hart_buffer[i + k] != hart_command_zero[k])
break;
}
}
if(k == HART_COMMAND_ZERO_SIZE) {
if(dev->hart_buffer[i + k] == 0xFF)
return usr_uart_write_string(dev->uart_descriptor,
(uint8_t*)"Command zero detected.\n");
}
return 0;
}
|
analogdevicesinc/EVAL-ADICUP3029
|
C++
|
Other
| 36
|
/* Check if the data transfer occurring on the specified DMA Channel is complete. */
|
uint32_t dmac_channel_is_transfer_done(Dmac *p_dmac, uint32_t ul_num)
|
/* Check if the data transfer occurring on the specified DMA Channel is complete. */
uint32_t dmac_channel_is_transfer_done(Dmac *p_dmac, uint32_t ul_num)
|
{
uint32_t status;
Assert(p_dmac);
Assert(ul_num<=3);
status = dmac_channel_get_status(p_dmac);
if (status & (DMAC_CHSR_ENA0 << ul_num)) {
return 0;
} else {
return 1;
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Open/initialize the board. This is called (in the current kernel) sometime after booting when the 'ifconfig' program is run. */
|
static int cops_open(struct net_device *dev)
|
/* Open/initialize the board. This is called (in the current kernel) sometime after booting when the 'ifconfig' program is run. */
static int cops_open(struct net_device *dev)
|
{
struct cops_local *lp = netdev_priv(dev);
if(dev->irq==0)
{
if(lp->board==TANGENT)
{
init_timer(&cops_timer);
cops_timer.function = cops_poll;
cops_timer.data = (unsigned long)dev;
cops_timer.expires = jiffies + HZ/20;
add_timer(&cops_timer);
}
else
{
printk(KERN_WARNING "%s: No irq line set\n", dev->name);
return -EAGAIN;
}
}
cops_jumpstart(dev);
netif_start_queue(dev);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets a sheet, part of the cascade. Note that the returned stylesheet is refcounted so if the caller wants to manage it's lifecycle, it must use cr_stylesheet_ref()/cr_stylesheet_unref() instead of the cr_stylesheet_destroy() method. Returns the style sheet, or NULL if it does not exist. */
|
CRStyleSheet* cr_cascade_get_sheet(CRCascade *a_this, enum CRStyleOrigin a_origin)
|
/* Gets a sheet, part of the cascade. Note that the returned stylesheet is refcounted so if the caller wants to manage it's lifecycle, it must use cr_stylesheet_ref()/cr_stylesheet_unref() instead of the cr_stylesheet_destroy() method. Returns the style sheet, or NULL if it does not exist. */
CRStyleSheet* cr_cascade_get_sheet(CRCascade *a_this, enum CRStyleOrigin a_origin)
|
{
g_return_val_if_fail (a_this
&& a_origin >= ORIGIN_UA
&& a_origin < NB_ORIGINS, NULL);
return PRIVATE (a_this)->sheets[a_origin];
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Draw a frame.
This function draws a frame with the specified thickness and color on the display, at the specified start offset from the edges. */
|
static void draw_frame(const uint8_t start, const uint8_t thickness, const gfx_color_t color)
|
/* Draw a frame.
This function draws a frame with the specified thickness and color on the display, at the specified start offset from the edges. */
static void draw_frame(const uint8_t start, const uint8_t thickness, const gfx_color_t color)
|
{
uint8_t c;
for (c = 0; c < thickness; c++) {
gfx_draw_rect(start + c, start + c,
display_w - ((start + c) * 2),
display_h - ((start + c) * 2), color);
}
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Check the busy status of the specified SPI port. */
|
xtBoolean SPIIsBusy(unsigned long ulBase)
|
/* Check the busy status of the specified SPI port. */
xtBoolean SPIIsBusy(unsigned long ulBase)
|
{
xASSERT(ulBase == SPI0_BASE);
return ((xHWREG(ulBase + SPI_SR) & SPI_SR_BUSY) ? xtrue : xfalse);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
|
UINT16 EFIAPI PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 16-bit boundary, then ASSERT(). */
UINT16 EFIAPI PciSegmentOr16(IN UINT64 Address, IN UINT16 OrData)
|
{
UINTN Count;
PCI_SEGMENT_INFO *SegmentInfo;
SegmentInfo = GetPciSegmentInfo (&Count);
return MmioOr16 (PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count), OrData);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* The SetState() function allows the input device hardware to have state settings adjusted. */
|
EFI_STATUS EFIAPI EmuGopSimpleTextInExSetState(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
|
/* The SetState() function allows the input device hardware to have state settings adjusted. */
EFI_STATUS EFIAPI EmuGopSimpleTextInExSetState(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, IN EFI_KEY_TOGGLE_STATE *KeyToggleState)
|
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
if (KeyToggleState == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
if (Private->EmuGraphicsWindow == NULL) {
return EFI_NOT_READY;
}
if (((Private->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||
((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID))
{
return EFI_UNSUPPORTED;
}
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->EmuGraphicsWindow->KeySetState (Private->EmuGraphicsWindow, KeyToggleState);
gBS->RestoreTPL (OldTpl);
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* nilfs_detach_segment_constructor() kills the segment constructor daemon, frees the struct nilfs_sc_info, and destroy the dirty file list. */
|
void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi)
|
/* nilfs_detach_segment_constructor() kills the segment constructor daemon, frees the struct nilfs_sc_info, and destroy the dirty file list. */
void nilfs_detach_segment_constructor(struct nilfs_sb_info *sbi)
|
{
struct the_nilfs *nilfs = sbi->s_nilfs;
LIST_HEAD(garbage_list);
down_write(&nilfs->ns_segctor_sem);
if (NILFS_SC(sbi)) {
nilfs_segctor_destroy(NILFS_SC(sbi));
sbi->s_sc_info = NULL;
}
spin_lock(&sbi->s_inode_lock);
if (!list_empty(&sbi->s_dirty_files)) {
list_splice_init(&sbi->s_dirty_files, &garbage_list);
nilfs_warning(sbi->s_super, __func__,
"Non empty dirty list after the last "
"segment construction\n");
}
spin_unlock(&sbi->s_inode_lock);
up_write(&nilfs->ns_segctor_sem);
nilfs_dispose_list(sbi, &garbage_list, 1);
nilfs_detach_writer(nilfs, sbi);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* i s C P U t i m e L i m i t E x c e e d e d */
|
BooleanType QProblemB_isCPUtimeLimitExceeded(QProblemB *_THIS, const real_t *const cputime, real_t starttime, int nWSR)
|
/* i s C P U t i m e L i m i t E x c e e d e d */
BooleanType QProblemB_isCPUtimeLimitExceeded(QProblemB *_THIS, const real_t *const cputime, real_t starttime, int nWSR)
|
{
real_t elapsedTime, timePerIteration;
if ( cputime == 0 )
return BT_FALSE;
if ( nWSR <= 0 )
return BT_FALSE;
elapsedTime = qpOASES_getCPUtime( ) - starttime;
timePerIteration = elapsedTime / ((real_t) nWSR);
if ( ( elapsedTime + timePerIteration*1.25 ) <= ( *cputime ) )
return BT_FALSE;
else
return BT_TRUE;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* return kStatus_Success on success kStatus_Error if we have hit the limit in terms of states used */
|
status_t SCTIMER_IncreaseState(SCT_Type *base)
|
/* return kStatus_Success on success kStatus_Error if we have hit the limit in terms of states used */
status_t SCTIMER_IncreaseState(SCT_Type *base)
|
{
status_t status = kStatus_Success;
if (s_currentState >= (uint32_t)FSL_FEATURE_SCT_NUMBER_OF_STATES)
{
status = kStatus_Fail;
}
else
{
s_currentState++;
}
return status;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return pointers to the transfer negotiation information for the specified our_id/remote_id pair. */
|
struct ahc_initiator_tinfo* ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id, u_int remote_id, struct ahc_tmode_tstate **tstate)
|
/* Return pointers to the transfer negotiation information for the specified our_id/remote_id pair. */
struct ahc_initiator_tinfo* ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id, u_int remote_id, struct ahc_tmode_tstate **tstate)
|
{
if (channel == 'B')
our_id += 8;
*tstate = ahc->enabled_targets[our_id];
return (&(*tstate)->transinfo[remote_id]);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get the SPI interrupt flag of the specified SPI port. */
|
unsigned long SPIIntFlagGet(unsigned long ulBase, xtBoolean xbMasked)
|
/* Get the SPI interrupt flag of the specified SPI port. */
unsigned long SPIIntFlagGet(unsigned long ulBase, xtBoolean xbMasked)
|
{
xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)||
(ulBase == SPI2_BASE) || (ulBase == SPI3_BASE));
xASSERT(xbMasked == xfalse);
return (xHWREG(ulBase + SPI_CNTRL) & SPI_CNTRL_IF);
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* ata_std_prereset - prepare for reset ATA link to be reset @deadline: deadline jiffies for the operation */
|
int ata_std_prereset(struct ata_link *link, unsigned long deadline)
|
/* ata_std_prereset - prepare for reset ATA link to be reset @deadline: deadline jiffies for the operation */
int ata_std_prereset(struct ata_link *link, unsigned long deadline)
|
{
struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context;
const unsigned long *timing = sata_ehc_deb_timing(ehc);
int rc;
if (ehc->i.action & ATA_EH_HARDRESET)
return 0;
if (ap->flags & ATA_FLAG_SATA) {
rc = sata_link_resume(link, timing, deadline);
if (rc && rc != -EOPNOTSUPP)
ata_link_printk(link, KERN_WARNING, "failed to resume "
"link for reset (errno=%d)\n", rc);
}
if (ata_phys_link_offline(link))
ehc->i.action &= ~ATA_EH_SOFTRESET;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Process some data. This handles the simple case where no context is required. */
|
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
/* Process some data. This handles the simple case where no context is required. */
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
{
my_main_ptr main1 = (my_main_ptr)cinfo->main;
JDIMENSION rowgroups_avail;
if (!main1->buffer_full) {
if (!(*cinfo->coef->decompress_data) (cinfo, main1->buffer))
return;
main1->buffer_full = TRUE;
}
rowgroups_avail = (JDIMENSION)cinfo->min_DCT_scaled_size;
(*cinfo->post->post_process_data) (cinfo, main1->buffer,
&main1->rowgroup_ctr, rowgroups_avail,
output_buf, out_row_ctr, out_rows_avail);
if (main1->rowgroup_ctr >= rowgroups_avail) {
main1->buffer_full = FALSE;
main1->rowgroup_ctr = 0;
}
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Returns 0 if the revalidation was successful. If the revalidation fails, either return the error returned by d_revalidate or -ESTALE if the revalidation it just returned 0. If d_revalidate returns 0, we attempt to invalidate the dentry. It's up to the caller to handle putting references to the path if necessary. */
|
static int force_reval_path(struct path *path, struct nameidata *nd)
|
/* Returns 0 if the revalidation was successful. If the revalidation fails, either return the error returned by d_revalidate or -ESTALE if the revalidation it just returned 0. If d_revalidate returns 0, we attempt to invalidate the dentry. It's up to the caller to handle putting references to the path if necessary. */
static int force_reval_path(struct path *path, struct nameidata *nd)
|
{
int status;
struct dentry *dentry = path->dentry;
if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT))
return 0;
status = dentry->d_op->d_revalidate(dentry, nd);
if (status > 0)
return 0;
if (!status) {
d_invalidate(dentry);
status = -ESTALE;
}
return status;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Determine if a menu is empty. A menu is considered empty if it contains no or only invisible entries. */
|
bool menu_is_empty(struct menu *menu)
|
/* Determine if a menu is empty. A menu is considered empty if it contains no or only invisible entries. */
bool menu_is_empty(struct menu *menu)
|
{
struct menu *child;
for (child = menu->list; child; child = child->next) {
if (menu_is_visible(child))
return(false);
}
return(true);
}
|
Nicholas3388/LuaNode
|
C++
|
Other
| 1,055
|
/* This function is the entry point for a Standalone MM Driver. This function must call ProcessLibraryConstructorList() and ProcessModuleEntryPointList(). If the return status from ProcessModuleEntryPointList() is an error status, then ProcessLibraryDestructorList() must be called. The return value from ProcessModuleEntryPointList() is returned. If _gMmRevision is not zero and SystemTable->Hdr.Revision is less than _gMmRevision, then return EFI_INCOMPATIBLE_VERSION. */
|
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
|
/* This function is the entry point for a Standalone MM Driver. This function must call ProcessLibraryConstructorList() and ProcessModuleEntryPointList(). If the return status from ProcessModuleEntryPointList() is an error status, then ProcessLibraryDestructorList() must be called. The return value from ProcessModuleEntryPointList() is returned. If _gMmRevision is not zero and SystemTable->Hdr.Revision is less than _gMmRevision, then return EFI_INCOMPATIBLE_VERSION. */
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
|
{
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
if (_gMmRevision != 0) {
if (MmSystemTable->Hdr.Revision < _gMmRevision) {
return EFI_INCOMPATIBLE_VERSION;
}
}
ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
if (_gDriverUnloadImageCount != 0) {
Status = gMmst->MmHandleProtocol (
ImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **)&LoadedImage
);
ASSERT_EFI_ERROR (Status);
LoadedImage->Unload = _DriverUnloadHandler;
}
Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
if (EFI_ERROR (Status)) {
ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Before you start, select your target, on the right of the "Load" button */
|
int main(void)
|
/* Before you start, select your target, on the right of the "Load" button */
int main(void)
|
{
while (1) {
TM_DISCO_LedToggle(LED_RED | LED_GREEN);
Delayms(100);
}
}
while (1) {
TM_HCSR04_Read(&HCSR04);
if (HCSR04.Distance < 0) {
TM_DISCO_LedOn(LED_RED);
TM_DISCO_LedOff(LED_GREEN);
} else if (HCSR04.Distance > 50) {
TM_DISCO_LedOn(LED_GREEN);
TM_DISCO_LedOff(LED_RED);
} else {
TM_DISCO_LedOff(LED_GREEN | LED_RED);
}
Delayms(100);
}
}
|
MaJerle/stm32f429
|
C++
| null | 2,036
|
/* Switch system clock configuration in run mode.
Blocks until the updated configuration takes effect. */
|
static void rv32m1_switch_sys_clk(const scg_sys_clk_config_t *cfg)
|
/* Switch system clock configuration in run mode.
Blocks until the updated configuration takes effect. */
static void rv32m1_switch_sys_clk(const scg_sys_clk_config_t *cfg)
|
{
scg_sys_clk_config_t cur_cfg;
CLOCK_SetRunModeSysClkConfig(cfg);
do {
CLOCK_GetCurSysClkConfig(&cur_cfg);
} while (cur_cfg.src != cfg->src);
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* UBIFS has so-called "reserved pool" which is flash space reserved for the superuser and for uses whose UID/GID is recorded in UBIFS superblock. This function checks whether current user is allowed to use reserved pool. Returns %1 current user is allowed to use reserved pool and %0 otherwise. */
|
static int can_use_rp(struct ubifs_info *c)
|
/* UBIFS has so-called "reserved pool" which is flash space reserved for the superuser and for uses whose UID/GID is recorded in UBIFS superblock. This function checks whether current user is allowed to use reserved pool. Returns %1 current user is allowed to use reserved pool and %0 otherwise. */
static int can_use_rp(struct ubifs_info *c)
|
{
if (uid_eq(current_fsuid(), c->rp_uid) || capable(CAP_SYS_RESOURCE) ||
(!gid_eq(c->rp_gid, GLOBAL_ROOT_GID) && in_group_p(c->rp_gid)))
return 1;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Functions to get and set the sc26198 global registers. */
|
static int stl_sc26198getglobreg(struct stlport *portp, int regnr)
|
/* Functions to get and set the sc26198 global registers. */
static int stl_sc26198getglobreg(struct stlport *portp, int regnr)
|
{
outb(regnr, (portp->ioaddr + XP_ADDR));
return inb(portp->ioaddr + XP_DATA);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Sets the attributes for a range of a BAR on a PCI controller. */
|
STATIC EFI_STATUS EFIAPI PciIoSetBarAttributes(IN EFI_PCI_IO_PROTOCOL *This, IN UINT64 Attributes, IN UINT8 BarIndex, IN OUT UINT64 *Offset, IN OUT UINT64 *Length)
|
/* Sets the attributes for a range of a BAR on a PCI controller. */
STATIC EFI_STATUS EFIAPI PciIoSetBarAttributes(IN EFI_PCI_IO_PROTOCOL *This, IN UINT64 Attributes, IN UINT8 BarIndex, IN OUT UINT64 *Offset, IN OUT UINT64 *Length)
|
{
NON_DISCOVERABLE_PCI_DEVICE *Dev;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
EFI_PCI_IO_PROTOCOL_WIDTH Width;
UINTN Count;
EFI_STATUS Status;
if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
return EFI_UNSUPPORTED;
}
if ((Offset == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
}
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
Width = EfiPciIoWidthUint8;
Count = (UINT32)*Length;
Status = GetBarResource (Dev, BarIndex, &Desc);
if (EFI_ERROR (Status)) {
return Status;
}
if (*Offset + (Count << (Width & 0x3)) > Desc->AddrLen) {
return EFI_UNSUPPORTED;
}
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeUint64ToUintn(IN UINT64 Operand, OUT UINTN *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint64ToUintn(IN UINT64 Operand, OUT UINTN *Result)
|
{
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
*Result = Operand;
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Blocks until the request is posted. Must not be called from interrupt context! */
|
err_t tcpip_callback(tcpip_callback_fn function, void *ctx)
|
/* Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Blocks until the request is posted. Must not be called from interrupt context! */
err_t tcpip_callback(tcpip_callback_fn function, void *ctx)
|
{
struct tcpip_msg *msg;
LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
if (msg == NULL) {
return ERR_MEM;
}
msg->type = TCPIP_MSG_CALLBACK;
msg->msg.cb.function = function;
msg->msg.cb.ctx = ctx;
sys_mbox_post(&tcpip_mbox, msg);
return ERR_OK;
}
|
ua1arn/hftrx
|
C++
| null | 69
|
/* Wait until all NAPI handlers are descheduled. This includes the handlers of both netdevices representing interfaces and the dummy ones for the extra queues. */
|
static void quiesce_rx(struct adapter *adap)
|
/* Wait until all NAPI handlers are descheduled. This includes the handlers of both netdevices representing interfaces and the dummy ones for the extra queues. */
static void quiesce_rx(struct adapter *adap)
|
{
int i;
for (i = 0; i < SGE_QSETS; i++)
if (adap->sge.qs[i].adap)
napi_disable(&adap->sge.qs[i].napi);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Fills each init_struct member with its default value. */
|
void ADC_StructInit(ADC_InitTypeDef *init_struct)
|
/* Fills each init_struct member with its default value. */
void ADC_StructInit(ADC_InitTypeDef *init_struct)
|
{
init_struct->ADC_Resolution = ADC_Resolution_12b;
init_struct->ADC_PRESCARE = ADC_PCLK2_PRESCARE_2;
init_struct->ADC_Mode = ADC_CR_IMM;
init_struct->ADC_ContinuousConvMode = DISABLE;
init_struct->ADC_ExternalTrigConv = ADC1_ExternalTrigConv_T1_CC1;
init_struct->ADC_DataAlign = ADC_DataAlign_Right;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
|
RETURN_STATUS EFIAPI SafeInt64ToIntn(IN INT64 Operand, OUT INTN *Result)
|
/* If the conversion results in an overflow or an underflow condition, then Result is set to INTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeInt64ToIntn(IN INT64 Operand, OUT INTN *Result)
|
{
if (Result == NULL) {
return RETURN_INVALID_PARAMETER;
}
*Result = (INTN)Operand;
return RETURN_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Converts a SYSTEMTIME value to HAL time value, with extra ticks */
|
uint64_t HAL_Time_ConvertFromSystemTimeWithTicks(const SYSTEMTIME *systemTime, const uint32_t extraTicks)
|
/* Converts a SYSTEMTIME value to HAL time value, with extra ticks */
uint64_t HAL_Time_ConvertFromSystemTimeWithTicks(const SYSTEMTIME *systemTime, const uint32_t extraTicks)
|
{
uint64_t r =
YEARS_TO_DAYS(systemTime->wYear) + MONTH_TO_DAYS(systemTime->wYear, systemTime->wMonth) + systemTime->wDay - 1;
r = (((((r * HOURS_TO_DAY) + systemTime->wHour) * MINUTES_TO_HOUR + systemTime->wMinute) * SECONDS_TO_MINUTES +
systemTime->wSecond) *
MILLISECONDS_TO_SECONDS +
systemTime->wMilliseconds) *
TIMEUNIT_TO_MILLISECONDS +
extraTicks;
return r;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* Converts a text device path node to Wi-Fi device path structure. */
|
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextWiFi(CHAR16 *TextDeviceNode)
|
/* Converts a text device path node to Wi-Fi device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextWiFi(CHAR16 *TextDeviceNode)
|
{
CHAR16 *SSIdStr;
CHAR8 AsciiStr[33];
UINTN DataLen;
WIFI_DEVICE_PATH *WiFiDp;
SSIdStr = GetNextParamStr (&TextDeviceNode);
WiFiDp = (WIFI_DEVICE_PATH *) CreateDeviceNode (
MESSAGING_DEVICE_PATH,
MSG_WIFI_DP,
(UINT16) sizeof (WIFI_DEVICE_PATH)
);
if (NULL != SSIdStr) {
DataLen = StrLen (SSIdStr);
if (StrLen (SSIdStr) > 32) {
SSIdStr[32] = L'\0';
DataLen = 32;
}
UnicodeStrToAsciiStrS (SSIdStr, AsciiStr, sizeof (AsciiStr));
memcpy (WiFiDp->SSId, AsciiStr, DataLen);
}
return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* get the state string where SSL is reading */
|
const char* SSL_rstate_string(SSL *ssl)
|
/* get the state string where SSL is reading */
const char* SSL_rstate_string(SSL *ssl)
|
{
const char *str;
SSL_ASSERT2(ssl);
switch (ssl->rlayer.rstate)
{
case SSL_ST_READ_HEADER:
str = "RH";
break;
case SSL_ST_READ_BODY:
str = "RB";
break;
case SSL_ST_READ_DONE:
str = "RD";
break;
default:
str = "unknown";
break;
}
return str;
}
|
retro-esp32/RetroESP32
|
C++
|
Creative Commons Attribution Share Alike 4.0 International
| 581
|
/* Copy bytes to an SDIO card.
Copies bytes to an SDIO card, starting from provided address. */
|
int sdio_write_addr(struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
|
/* Copy bytes to an SDIO card.
Copies bytes to an SDIO card, starting from provided address. */
int sdio_write_addr(struct sdio_func *func, uint32_t reg, uint8_t *data, uint32_t len)
|
{
int ret;
if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) {
LOG_WRN("Card does not support SDIO commands");
return -ENOTSUP;
}
ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT));
if (ret) {
LOG_WRN("Could not get SD card mutex");
return -EBUSY;
}
ret = sdio_io_rw_extended_helper(func, SDIO_IO_WRITE, reg, true,
data, len);
k_mutex_unlock(&func->card->lock);
return ret;
}
|
zephyrproject-rtos/zephyr
|
C++
|
Apache License 2.0
| 9,573
|
/* The Matrix Orbital VK204-25-USB has an invalid IN endpoint. We have to correct it if we want to read from it. */
|
static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
|
/* The Matrix Orbital VK204-25-USB has an invalid IN endpoint. We have to correct it if we want to read from it. */
static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
|
{
struct usb_host_endpoint *ep = serial->dev->ep_in[1];
struct usb_endpoint_descriptor *ep_desc = &ep->desc;
if (ep->enabled && ep_desc->wMaxPacketSize == 0) {
ep_desc->wMaxPacketSize = cpu_to_le16(0x40);
dev_info(&serial->dev->dev,
"Fixing invalid wMaxPacketSize on read pipe\n");
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This is done as an API function so that changes to the internals of the scsi mid-layer won't require wholesale changes to drivers that use this feature. */
|
void scsi_unblock_requests(struct Scsi_Host *shost)
|
/* This is done as an API function so that changes to the internals of the scsi mid-layer won't require wholesale changes to drivers that use this feature. */
void scsi_unblock_requests(struct Scsi_Host *shost)
|
{
shost->host_self_blocked = 0;
scsi_run_host_queues(shost);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* 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};
if(huart->Instance==USART2)
{
__HAL_RCC_USART2_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
}
|
feaser/openblt
|
C++
|
GNU General Public License v3.0
| 601
|
/* handler for EDAC to check if NMI type handler has asserted interrupt */
|
static int edac_mc_assert_error_check_and_clear(void)
|
/* handler for EDAC to check if NMI type handler has asserted interrupt */
static int edac_mc_assert_error_check_and_clear(void)
|
{
int old_state;
if (edac_op_state == EDAC_OPSTATE_POLL)
return 1;
old_state = edac_err_assert;
edac_err_assert = 0;
return old_state;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* No matter what, we disable RX, process, and the restart RX. */
|
static void sa1100_irda_fir_irq(struct net_device *dev)
|
/* No matter what, we disable RX, process, and the restart RX. */
static void sa1100_irda_fir_irq(struct net_device *dev)
|
{
struct sa1100_irda *si = netdev_priv(dev);
sa1100_stop_dma(si->rxdma);
if (Ser2HSSR0 & (HSSR0_FRE | HSSR0_RAB)) {
dev->stats.rx_errors++;
if (Ser2HSSR0 & HSSR0_FRE)
dev->stats.rx_frame_errors++;
Ser2HSCR0 = si->hscr0 | HSCR0_HSSP;
Ser2HSSR0 = HSSR0_FRE | HSSR0_RAB;
}
if (Ser2HSSR0 & HSSR0_EIF)
sa1100_irda_fir_error(si, dev);
sa1100_irda_rx_dma_start(si);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Write a data buffer to eNVM. Note that we need for this function to reside in RAM since it will be used to self-upgrade U-boot in eNMV. */
|
u32 __attribute__((section(".ramcode")))
|
/* Write a data buffer to eNVM. Note that we need for this function to reside in RAM since it will be used to self-upgrade U-boot in eNMV. */
u32 __attribute__((section(".ramcode")))
|
{
addr &= MSS_ENVM_PAGE_ADDR_MASK;
MSS_ENVM->status = 0xFFFFFFFF;
MSS_ENVM->control = addr | cmd;
while (MSS_ENVM->status & MSS_ENVM_STATUS_BUSY)
;
if (MSS_ENVM->status & MSS_ENVM_STATUS_ERROR_MASK) {
if ((MSS_ENVM->status & 0x180) == 0x180) {
return 0;
}
return -1;
}
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Returns: TRUE if the text was valid UTF-8 */
|
gboolean g_utf8_validate(const char *str, gssize max_len, const gchar **end)
|
/* Returns: TRUE if the text was valid UTF-8 */
gboolean g_utf8_validate(const char *str, gssize max_len, const gchar **end)
|
{
const gchar *p;
if (max_len < 0)
p = fast_validate (str);
else
p = fast_validate_len (str, max_len);
if (end)
*end = p;
if ((max_len >= 0 && p != str + max_len) ||
(max_len < 0 && *p != '\0'))
return FALSE;
else
return TRUE;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Clear CS put the chip in the reset state, where it can wait for new commands. */
|
static void reset_seeprom(struct seeprom_descriptor *sd)
|
/* Clear CS put the chip in the reset state, where it can wait for new commands. */
static void reset_seeprom(struct seeprom_descriptor *sd)
|
{
uint8_t temp;
temp = sd->sd_MS;
SEEPROM_OUTB(sd, temp);
CLOCK_PULSE(sd, sd->sd_RDY);
SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
CLOCK_PULSE(sd, sd->sd_RDY);
SEEPROM_OUTB(sd, temp);
CLOCK_PULSE(sd, sd->sd_RDY);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This service executes a caller provided function on all enabled APs. */
|
EFI_STATUS EFIAPI MpInitLibStartupAllAPs(IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
|
/* This service executes a caller provided function on all enabled APs. */
EFI_STATUS EFIAPI MpInitLibStartupAllAPs(IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
|
{
if (WaitEvent != NULL) {
return EFI_UNSUPPORTED;
}
return StartupAllCPUsWorker (
Procedure,
SingleThread,
TRUE,
NULL,
TimeoutInMicroseconds,
ProcedureArgument,
FailedCpuList
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* returns 1 if the anchor has no urbs associated with it */
|
int usb_anchor_empty(struct usb_anchor *anchor)
|
/* returns 1 if the anchor has no urbs associated with it */
int usb_anchor_empty(struct usb_anchor *anchor)
|
{
return list_empty(&anchor->urb_list);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
|
EFI_STATUS EFIAPI PeiServicesFfsFindFileByName(IN CONST EFI_GUID *FileName, IN CONST EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
|
/* This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface Specification for details. */
EFI_STATUS EFIAPI PeiServicesFfsFindFileByName(IN CONST EFI_GUID *FileName, IN CONST EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle)
|
{
ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.