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
/* The internal oscillator verification timer is only available on Sandstorm-class devices. */
void SysCtlIOSCVerificationSet(tBoolean bEnable)
/* The internal oscillator verification timer is only available on Sandstorm-class devices. */ void SysCtlIOSCVerificationSet(tBoolean bEnable)
{ if(bEnable) { HWREG(SYSCTL_RCC) |= SYSCTL_RCC_IOSCVER; } else { HWREG(SYSCTL_RCC) &= ~(SYSCTL_RCC_IOSCVER); } }
watterott/WebRadio
C++
null
71
/* Output: none Return: u4Byte Return the shift bit bit position of the mask */
static u32 phy_CalculateBitShift(u32 BitMask)
/* Output: none Return: u4Byte Return the shift bit bit position of the mask */ static u32 phy_CalculateBitShift(u32 BitMask)
{ u32 i; for(i=0; i<=31; i++) { if ( ((BitMask>>i) & 0x1 ) == 1) break; } return (i); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* 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==USART3) { __HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF7_USART3; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This API is used to enable Autonomous QTouch Sensor that can be used to Wakeup the CPU from Deep-Sleep modes. */
touch_ret_t touch_autonomous_sensor_enable(void)
/* This API is used to enable Autonomous QTouch Sensor that can be used to Wakeup the CPU from Deep-Sleep modes. */ touch_ret_t touch_autonomous_sensor_enable(void)
{ touch_ret_t touch_ret = TOUCH_SUCCESS; touch_ret = touch_at_sensor_enable( &touch_config ); if (touch_ret != TOUCH_SUCCESS) { while (1); } return (touch_ret); }
remotemcu/remcu-chip-sdks
C++
null
436
/* vmbus_child_device_unregister - Remove the specified child device from the vmbus. */
static void vmbus_child_device_unregister(struct hv_device *child_device_obj)
/* vmbus_child_device_unregister - Remove the specified child device from the vmbus. */ static void vmbus_child_device_unregister(struct hv_device *child_device_obj)
{ struct device_context *device_ctx = to_device_context(device_obj); DPRINT_ENTER(VMBUS_DRV); DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)", &device_ctx->device); device_unregister(&device_ctx->device); DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered", &device_ctx->device); DPRINT_EXIT(VMBUS_DRV); }
robutest/uclinux
C++
GPL-2.0
60
/* This function is the entry point of this Generic Status Code Driver. It installs eport Stataus Code Handler Protocol and Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. */
EFI_STATUS EFIAPI GenericStatusCodeRuntimeDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* This function is the entry point of this Generic Status Code Driver. It installs eport Stataus Code Handler Protocol and Status Code Runtime Protocol, and registers event for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. */ EFI_STATUS EFIAPI GenericStatusCodeRuntimeDxeEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; Status = gBS->InstallMultipleProtocolInterfaces ( &mHandle, &gEfiRscHandlerProtocolGuid, &mRscHandlerProtocol, &gEfiStatusCodeRuntimeProtocolGuid, &mStatusCodeProtocol, NULL ); ASSERT_EFI_ERROR (Status); Status = gBS->CreateEventEx ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY, VirtualAddressChangeCallBack, NULL, &gEfiEventVirtualAddressChangeGuid, &mVirtualAddressChangeEvent ); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */
USBD_Status USBD_CtlContinueSendData(USB_OTG_CORE_HANDLE *pdev, uint8_t *pbuf, uint16_t len)
/* USBD_CtlContinueSendData continue sending data on the ctl pipe. */ USBD_Status USBD_CtlContinueSendData(USB_OTG_CORE_HANDLE *pdev, uint8_t *pbuf, uint16_t len)
{ USBD_Status ret = USBD_OK; DCD_EP_Tx (pdev, 0, pbuf, len); return ret; }
MaJerle/stm32f429
C++
null
2,036
/* For another derivation of the same result, using Singular Value Decomposition, see doc/tutorial/src/singular.c. */
double _cairo_matrix_transformed_circle_major_axis(const cairo_matrix_t *matrix, double radius)
/* For another derivation of the same result, using Singular Value Decomposition, see doc/tutorial/src/singular.c. */ double _cairo_matrix_transformed_circle_major_axis(const cairo_matrix_t *matrix, double radius)
{ double a, b, c, d, f, g, h, i, j; if (_cairo_matrix_has_unity_scale (matrix)) return radius; _cairo_matrix_get_affine (matrix, &a, &b, &c, &d, NULL, NULL); i = a*a + b*b; j = c*c + d*d; f = 0.5 * (i + j); g = 0.5 * (i - j); h = a*c + b*d; return radius * sqrt (f + hypot (g, h)); }
xboot/xboot
C++
MIT License
779
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM1) { __HAL_RCC_TIM1_CLK_DISABLE(); } else if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_DISABLE(); } else if(htim_base->Instance==TIM3) { __HAL_RCC_TIM3_CLK_DISABLE(); } else if(htim_base->Instance==TIM4) { __HAL_RCC_TIM4_CLK_DISABLE(); } else if(htim_base->Instance==TIM9) { __HAL_RCC_TIM9_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read a 32 bit IO APIC register. This routine reads the specified IO APIC register using indirect addressing. */
static __pinned_func uint32_t __IoApicGet(int32_t offset)
/* Read a 32 bit IO APIC register. This routine reads the specified IO APIC register using indirect addressing. */ static __pinned_func uint32_t __IoApicGet(int32_t offset)
{ uint32_t value; unsigned int key; key = irq_lock(); *((volatile uint32_t *) (IOAPIC_REG + IOAPIC_IND)) = (unsigned char)offset; value = *((volatile uint32_t *)(IOAPIC_REG + IOAPIC_DATA)); irq_unlock(key); return value; }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* sh64_next_free_dtlb_entry - Find the next available DTLB entry */
unsigned long long sh64_next_free_dtlb_entry(void)
/* sh64_next_free_dtlb_entry - Find the next available DTLB entry */ unsigned long long sh64_next_free_dtlb_entry(void)
{ return cpu_data->dtlb.next; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* get the PPP protocol header and pull skb retval < 0 -> discard packet silently */
static int isdn_ppp_strip_proto(struct sk_buff *skb)
/* get the PPP protocol header and pull skb retval < 0 -> discard packet silently */ static int isdn_ppp_strip_proto(struct sk_buff *skb)
{ int proto; if (skb->len < 1) return -1; if (skb->data[0] & 0x1) { proto = skb->data[0]; skb_pull(skb, 1); } else { if (skb->len < 2) return -1; proto = ((int) skb->data[0] << 8) + skb->data[1]; skb_pull(skb, 2); } return proto; }
robutest/uclinux
C++
GPL-2.0
60
/* Writes a value in a register of the device through BUS in using DMA mode. */
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
/* Writes a value in a register of the device through BUS in using DMA mode. */ static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
{ HAL_StatusTypeDef status = HAL_OK; status = HAL_I2C_Mem_Write(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000); if(status != HAL_OK) { I2Cx_Error(i2c_handler, Addr); } return status; }
eclipse-threadx/getting-started
C++
Other
310
/* Change Logs: Date Author Notes bernard the first version */
int em_init(void)
/* Change Logs: Date Author Notes bernard the first version */ int em_init(void)
{ int count = 5; char *em_cmd = "/services/em.elf &"; while (count --) { int fd; fd = open("/services/em.elf", O_RDONLY); if (fd >= 0) { close(fd); msh_exec(em_cmd, rt_strlen(em_cmd) + 1); return 0; } else { rt_thread_mdelay(500); } } if (count <= 0) { printf("open em failed!\n"); } return -1; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If the end of the current ioend is beyond the current EOF, return the new EOF value, otherwise zero. */
STATIC xfs_fsize_t xfs_ioend_new_eof(xfs_ioend_t *ioend)
/* If the end of the current ioend is beyond the current EOF, return the new EOF value, otherwise zero. */ STATIC xfs_fsize_t xfs_ioend_new_eof(xfs_ioend_t *ioend)
{ xfs_inode_t *ip = XFS_I(ioend->io_inode); xfs_fsize_t isize; xfs_fsize_t bsize; bsize = ioend->io_offset + ioend->io_size; isize = MAX(ip->i_size, ip->i_new_size); isize = MIN(isize, bsize); return isize > ip->i_d.di_size ? isize : 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Command response callback function for sd_ble_gap_keypress_notify BLE command. Callback for decoding the output parameters and the command response return code. */
static uint32_t gap_keypress_notify_rsp_dec(const uint8_t *p_buffer, uint16_t length)
/* Command response callback function for sd_ble_gap_keypress_notify BLE command. Callback for decoding the output parameters and the command response return code. */ static uint32_t gap_keypress_notify_rsp_dec(const uint8_t *p_buffer, uint16_t length)
{ uint32_t result_code = 0; const uint32_t err_code = ble_gap_keypress_notify_rsp_dec(p_buffer, length, &result_code); APP_ERROR_CHECK(err_code); return result_code; }
labapart/polymcu
C++
null
201
/* select card driver strength select card driver strength */
static status_t SD_SetDriverStrength(sd_card_t *card, sd_driver_strength_t driverStrength)
/* select card driver strength select card driver strength */ static status_t SD_SetDriverStrength(sd_card_t *card, sd_driver_strength_t driverStrength)
{ assert(card); status_t error; uint32_t strength = driverStrength; error = SD_SelectFunction(card, kSD_GroupDriverStrength, strength); return error; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example. */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM7) { __HAL_RCC_TIM7_CLK_DISABLE(); } else if(htim_base->Instance==TIM15) { __HAL_RCC_TIM15_CLK_DISABLE(); } else if(htim_base->Instance==TIM16) { __HAL_RCC_TIM16_CLK_DISABLE(); } else if(htim_base->Instance==TIM17) { __HAL_RCC_TIM17_CLK_DISABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Release the resources that where claimed for the hardware window, such as the framebuffer instance and any memory claimed for it. */
static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
/* Release the resources that where claimed for the hardware window, such as the framebuffer instance and any memory claimed for it. */ static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
{ if (win->fbinfo) { unregister_framebuffer(win->fbinfo); fb_dealloc_cmap(&win->fbinfo->cmap); s3c_fb_free_memory(sfb, win); framebuffer_release(win->fbinfo); } }
robutest/uclinux
C++
GPL-2.0
60
/* abort a call, sending an ABORT packet to the peer */
static void rxrpc_send_abort(struct rxrpc_call *call, u32 abort_code)
/* abort a call, sending an ABORT packet to the peer */ static void rxrpc_send_abort(struct rxrpc_call *call, u32 abort_code)
{ write_lock_bh(&call->state_lock); if (call->state <= RXRPC_CALL_COMPLETE) { call->state = RXRPC_CALL_LOCALLY_ABORTED; call->abort_code = abort_code; set_bit(RXRPC_CALL_ABORT, &call->events); del_timer_sync(&call->resend_timer); del_timer_sync(&call->ack_timer); clear_bit(RXRPC_CALL_RESEND_TIMER, &call->events); clear_bit(RXRPC_CALL_ACK, &call->events); clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags); rxrpc_queue_call(call); } write_unlock_bh(&call->state_lock); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* omap_hwecc_init - Initialize the Hardware ECC for NAND flash in GPMC controller @mtd: MTD device structure */
static void omap_hwecc_init(struct nand_chip *chip)
/* omap_hwecc_init - Initialize the Hardware ECC for NAND flash in GPMC controller @mtd: MTD device structure */ static void omap_hwecc_init(struct nand_chip *chip)
{ writel(ECCCLEAR | ECCRESULTREG1, &gpmc_cfg->ecc_control); writel(ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL, &gpmc_cfg->ecc_size_config); }
EmcraftSystems/u-boot
C++
Other
181
/* Description: Invoke request handling on this queue, if it has pending work to do. May be used to restart queueing when a request has completed. */
void blk_run_queue(struct request_queue *q)
/* Description: Invoke request handling on this queue, if it has pending work to do. May be used to restart queueing when a request has completed. */ void blk_run_queue(struct request_queue *q)
{ unsigned long flags; spin_lock_irqsave(q->queue_lock, flags); __blk_run_queue(q); spin_unlock_irqrestore(q->queue_lock, flags); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* execute the _STA method. note that present does not imply that we are docked. */
static int dock_present(struct dock_station *ds)
/* execute the _STA method. note that present does not imply that we are docked. */ static int dock_present(struct dock_station *ds)
{ unsigned long long sta; acpi_status status; if (ds) { status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta); if (ACPI_SUCCESS(status) && sta) return 1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Post FSP-S HOB process (not Memory Resource Descriptor). */
EFI_STATUS EFIAPI PostFspsHobProcess(IN VOID *FspHobList)
/* Post FSP-S HOB process (not Memory Resource Descriptor). */ EFI_STATUS EFIAPI PostFspsHobProcess(IN VOID *FspHobList)
{ if (PcdGet8 (PcdFspModeSelection) == 1) { ASSERT (FspHobList != NULL); ProcessFspHobList (FspHobList); } return EFI_SUCCESS; }
tianocore/edk2
C++
Other
4,240
/* Converts the block memory pointer, which points to the start of the block's allocated memory, to the pointer where the actual block data starts. */
static void * TbxMemPoolBlockGetDataPtr(void *memPtr)
/* Converts the block memory pointer, which points to the start of the block's allocated memory, to the pointer where the actual block data starts. */ static void * TbxMemPoolBlockGetDataPtr(void *memPtr)
{ void * result = NULL; size_t * blockSizeArray; void * dataPtr; TBX_ASSERT(memPtr != NULL); if (memPtr != NULL) { blockSizeArray = memPtr; dataPtr = &blockSizeArray[1U]; result = dataPtr; } return result; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* onenand_interrupt_wait - wait until the command is done */
static int onenand_interrupt_wait(struct mtd_info *mtd, int state)
/* onenand_interrupt_wait - wait until the command is done */ static int onenand_interrupt_wait(struct mtd_info *mtd, int state)
{ struct onenand_chip *this = mtd->priv; wait_for_completion(&this->complete); return onenand_wait(mtd, state); }
robutest/uclinux
C++
GPL-2.0
60
/* If 64-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI S3IoBitFieldOr64(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 OrData)
/* If 64-bit I/O port operations are not supported, then ASSERT(). If StartBit is greater than 63, then ASSERT(). If EndBit is greater than 63, then ASSERT(). If EndBit is less than StartBit, then ASSERT(). If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT64 EFIAPI S3IoBitFieldOr64(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 OrData)
{ return InternalSaveIoWrite64ValueToBootScript (Port, IoBitFieldOr64 (Port, StartBit, EndBit, OrData)); }
tianocore/edk2
C++
Other
4,240
/* This function exists solely so we can avoid casting &AsciiStrCmp to ORDERED_COLLECTION_USER_COMPARE and ORDERED_COLLECTION_KEY_COMPARE. */
STATIC INTN EFIAPI AsciiStringCompare(IN CONST VOID *AsciiString1, IN CONST VOID *AsciiString2)
/* This function exists solely so we can avoid casting &AsciiStrCmp to ORDERED_COLLECTION_USER_COMPARE and ORDERED_COLLECTION_KEY_COMPARE. */ STATIC INTN EFIAPI AsciiStringCompare(IN CONST VOID *AsciiString1, IN CONST VOID *AsciiString2)
{ return AsciiStrCmp (AsciiString1, AsciiString2); }
tianocore/edk2
C++
Other
4,240
/* em28xx_read_ac97() write a 16 bit value to the specified AC97 address (LSB first!) */
int em28xx_read_ac97(struct em28xx *dev, u8 reg)
/* em28xx_read_ac97() write a 16 bit value to the specified AC97 address (LSB first!) */ int em28xx_read_ac97(struct em28xx *dev, u8 reg)
{ int ret; u8 addr = (reg & 0x7f) | 0x80; u16 val; ret = em28xx_is_ac97_ready(dev); if (ret < 0) return ret; ret = em28xx_write_regs(dev, EM28XX_R42_AC97ADDR, &addr, 1); if (ret < 0) return ret; ret = dev->em28xx_read_reg_req_len(dev, 0, EM28XX_R40_AC97LSB, (u8 *)&val, sizeof(val)); if (ret < 0) return ret; return le16_to_cpu(val); }
robutest/uclinux
C++
GPL-2.0
60
/* Fills each EXTI_InitStruct member with its reset value. */
void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
/* Fills each EXTI_InitStruct member with its reset value. */ void EXTI_StructInit(EXTI_InitTypeDef *EXTI_InitStruct)
{ EXTI_InitStruct->EXTI_Line = EXTI_LINENONE; EXTI_InitStruct->EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStruct->EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStruct->EXTI_LineCmd = DISABLE; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Submit a USB get HID protocol request for the USB device specified by UsbIo and Interface and return the protocol retrieved in Protocol. If UsbIo is NULL, then ASSERT(). If Protocol is NULL, then ASSERT(). */
EFI_STATUS EFIAPI UsbGetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT UINT8 *Protocol)
/* Submit a USB get HID protocol request for the USB device specified by UsbIo and Interface and return the protocol retrieved in Protocol. If UsbIo is NULL, then ASSERT(). If Protocol is NULL, then ASSERT(). */ EFI_STATUS EFIAPI UsbGetProtocolRequest(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT8 Interface, OUT UINT8 *Protocol)
{ UINT32 Status; EFI_STATUS Result; EFI_USB_DEVICE_REQUEST Request; ASSERT (UsbIo != NULL); ASSERT (Protocol != NULL); Request.RequestType = USB_HID_CLASS_GET_REQ_TYPE; Request.Request = EFI_USB_GET_PROTOCOL_REQUEST; Request.Value = 0; Request.Index = Interface; Request.Length = 1; Result = UsbIo->UsbControlTransfer ( UsbIo, &Request, EfiUsbDataIn, PcdGet32 (PcdUsbTransferTimeoutValue), Protocol, sizeof (UINT8), &Status ); return Result; }
tianocore/edk2
C++
Other
4,240
/* Enables simultaneously the two DAC channels software triggers. */
void DAC_EnableDualSoftwareTrigger(void)
/* Enables simultaneously the two DAC channels software triggers. */ void DAC_EnableDualSoftwareTrigger(void)
{ DAC->SWTRG |= DUAL_SWTRIG_SET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Generate code to store result of expression 'ex' into variable 'var'. */
void luaK_storevar(FuncState *fs, expdesc *var, expdesc *ex)
/* Generate code to store result of expression 'ex' into variable 'var'. */ void luaK_storevar(FuncState *fs, expdesc *var, expdesc *ex)
{ case VLOCAL: { freeexp(fs, ex); exp2reg(fs, ex, var->u.info); return; } case VUPVAL: { int e = luaK_exp2anyreg(fs, ex); luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); break; } case VINDEXED: { OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; int e = luaK_exp2RK(fs, ex); luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); break; } default: lua_assert(0); } freeexp(fs, ex); }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Enables or Disables the TimeStamp on Tamper Detection Event. */
void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState)
/* Enables or Disables the TimeStamp on Tamper Detection Event. */ void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState)
{ assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { RTC->TMPCFG |= (uint32_t)RTC_TMPCFG_TPTS; } else { RTC->TMPCFG &= (uint32_t)~RTC_TMPCFG_TPTS; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Checks whether the Tamper Pin Event flag is set or not. */
FlagStatus BKP_GetFlagStatus(void)
/* Checks whether the Tamper Pin Event flag is set or not. */ FlagStatus BKP_GetFlagStatus(void)
{ return ((BKP->CSR & BKP_CSR_TEF) ? SET : RESET); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Writes a bit value to an output IO pin. */
uint8_t IOE_WriteIOPin(uint8_t IO_Pin, IOE_BitValue_TypeDef BitVal)
/* Writes a bit value to an output IO pin. */ uint8_t IOE_WriteIOPin(uint8_t IO_Pin, IOE_BitValue_TypeDef BitVal)
{ uint8_t DeviceAddr = 0; if (IO_Pin & IO1_OUT_ALL_PINS) { DeviceAddr = IOE_1_ADDR; } else { return PARAM_ERROR; } if (BitVal == BitReset) { I2C_WriteDeviceRegister(DeviceAddr, IOE_REG_GPIO_CLR_PIN, IO_Pin); } else { I2C_WriteDeviceRegister(DeviceAddr, IOE_REG_GPIO_SET_PIN, IO_Pin); } return IOE_OK; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Receives a byte that has been sent to the I2C Master. */
unsigned long I2CMasterDataGet(unsigned long ulBase)
/* Receives a byte that has been sent to the I2C Master. */ unsigned long I2CMasterDataGet(unsigned long ulBase)
{ unsigned long ulData; ulData = xHWREGB(ulBase + I2C_DAT); xHWREGB(ulBase + I2C_STATUS) |= I2C_STATUS_IF; return ulData; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* When this function is called, the engine is triggered to start using this context. */
void AESDataLengthSet(uint32_t ui32Base, uint64_t ui64Length)
/* When this function is called, the engine is triggered to start using this context. */ void AESDataLengthSet(uint32_t ui32Base, uint64_t ui64Length)
{ ASSERT(ui32Base == AES_BASE); HWREG(ui32Base + AES_O_C_LENGTH_0) = (uint32_t)(ui64Length); HWREG(ui32Base + AES_O_C_LENGTH_1) = (uint32_t)(ui64Length >> 32); }
micropython/micropython
C++
Other
18,334
/* Set or clear the multicast filter for this adaptor. num_addrs == -1 Promiscuous mode, receive all packets num_addrs == 0 Normal mode, clear multicast list num_addrs > 0 Multicast mode, receive normal and MC packets, and do best-effort filtering. */
static void set_multicast_list(struct net_device *dev)
/* Set or clear the multicast filter for this adaptor. num_addrs == -1 Promiscuous mode, receive all packets num_addrs == 0 Normal mode, clear multicast list num_addrs > 0 Multicast mode, receive normal and MC packets, and do best-effort filtering. */ static void set_multicast_list(struct net_device *dev)
{ short ioaddr = dev->base_addr; if (dev->flags&IFF_PROMISC) { outw(MULTICAST|PROMISC, ioaddr); } else if((dev->flags&IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { hardware_set_filter(NULL); outw(MULTICAST, ioaddr); } else if(dev->mc_count) { hardware_set_filter(dev->mc_list); outw(MULTICAST, ioaddr); } else outw(0, ioaddr); }
robutest/uclinux
C++
GPL-2.0
60
/* This file is part of the Simba project. */
int mock_write_time_get(struct time_t *now_p, int res)
/* This file is part of the Simba project. */ int mock_write_time_get(struct time_t *now_p, int res)
{ harness_mock_write("time_get(): return (now_p)", now_p, sizeof(*now_p)); harness_mock_write("time_get(): return (res)", &res, sizeof(res)); return (0); }
eerimoq/simba
C++
Other
337
/* @twsi: The MVTWSI register structure to use. @byte: The byte to send. @expected_status: The I2C bus status expected to be asserted after the operation completion. @tick: The duration of a clock cycle at the current I2C speed. */
static int twsi_send(struct mvtwsi_registers *twsi, u8 byte, int expected_status, uint tick)
/* @twsi: The MVTWSI register structure to use. @byte: The byte to send. @expected_status: The I2C bus status expected to be asserted after the operation completion. @tick: The duration of a clock cycle at the current I2C speed. */ static int twsi_send(struct mvtwsi_registers *twsi, u8 byte, int expected_status, uint tick)
{ writel(byte, &twsi->data); writel(MVTWSI_CONTROL_TWSIEN | MVTWSI_CONTROL_CLEAR_IFLG, &twsi->control); return twsi_wait(twsi, expected_status, tick); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Function to detemine if a handle has removable storage. */
BOOLEAN IsRemoveableDevice(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* Function to detemine if a handle has removable storage. */ BOOLEAN IsRemoveableDevice(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ if (NULL == DevicePath) { return FALSE; } while (!IsDevicePathEndType (DevicePath)) { if (DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) { switch (DevicePathSubType (DevicePath)) { case MSG_USB_DP: case MSG_SCSI_DP: return TRUE; default: return FALSE; } } DevicePath = NextDevicePathNode (DevicePath); } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Notes: We could have inlined this, but it would have required fc_event_seq to be exposed. For now, live with the subroutine call. Atomic used to avoid lock/unlock... */
u32 fc_get_event_number(void)
/* Notes: We could have inlined this, but it would have required fc_event_seq to be exposed. For now, live with the subroutine call. Atomic used to avoid lock/unlock... */ u32 fc_get_event_number(void)
{ return atomic_add_return(1, &fc_event_seq); }
robutest/uclinux
C++
GPL-2.0
60
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param transfer The pointer to the transfer descriptor. retval #kStatus_Success The transaction was started successfully. retval #kStatus_LPI2C_Busy Either another master is currently utilizing the bus, or a non-blocking transaction is already in progress. */
status_t LPI2C_MasterTransferNonBlocking(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_t *transfer)
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param transfer The pointer to the transfer descriptor. retval #kStatus_Success The transaction was started successfully. retval #kStatus_LPI2C_Busy Either another master is currently utilizing the bus, or a non-blocking transaction is already in progress. */ status_t LPI2C_MasterTransferNonBlocking(LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_t *transfer)
{ status_t result; assert(handle); assert(transfer); assert(transfer->subaddressSize <= sizeof(transfer->subaddress)); if (handle->state != kIdleState) { return kStatus_LPI2C_Busy; } result = LPI2C_CheckForBusyBus(base); if (result) { return result; } LPI2C_MasterDisableInterrupts(base, kMasterIrqFlags); handle->transfer = *transfer; LPI2C_InitTransferStateMachine(handle); LPI2C_MasterClearStatusFlags(base, kMasterClearFlags); base->MCFGR1 &= ~LPI2C_MCFGR1_AUTOSTOP_MASK; LPI2C_MasterEnableInterrupts(base, kMasterIrqFlags); return result; }
nanoframework/nf-interpreter
C++
MIT License
293
/* called whenever there is a large jump in sequence numbers, or when they get out of probation... */
static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
/* called whenever there is a large jump in sequence numbers, or when they get out of probation... */ static void rtp_init_sequence(RTPStatistics *s, uint16_t seq)
{ s->max_seq= seq; s->cycles= 0; s->base_seq= seq -1; s->bad_seq= RTP_SEQ_MOD + 1; s->received= 0; s->expected_prior= 0; s->received_prior= 0; s->jitter= 0; s->transit= 0; }
DC-SWAT/DreamShell
C++
null
404
/* Select the start bank filter for slave CAN. */
void CAN_StartBankSlave(uint8_t bankNumber)
/* Select the start bank filter for slave CAN. */ void CAN_StartBankSlave(uint8_t bankNumber)
{ CAN->FCTRL_B.FIM = BIT_SET; CAN->FCTRL &= 0xFFFFC0F1; CAN->FCTRL |= (uint32_t)(bankNumber) << 8; CAN->FCTRL_B.FIM = BIT_RESET; }
pikasTech/PikaPython
C++
MIT License
1,403
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnToUint32(IN UINTN Operand, OUT UINT32 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */ RETURN_STATUS EFIAPI SafeUintnToUint32(IN UINTN Operand, OUT UINT32 *Result)
{ if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (sizeof (UINTN) == sizeof (UINT32)) { *Result = (UINT32)Operand; return RETURN_SUCCESS; } return SafeUint64ToUint32 ((UINT64)Operand, Result); }
tianocore/edk2
C++
Other
4,240
/* New (hopefully final) interface for the API. We use the sctp_getaddrs_old structure so that use-space library can avoid any unnecessary allocations. The only defferent part is that we store the actual length of the address buffer into the addrs_num structure member. That way we can re-use the existing code. */
SCTP_STATIC int sctp_getsockopt_connectx3(struct sock *sk, int len, char __user *optval, int __user *optlen)
/* New (hopefully final) interface for the API. We use the sctp_getaddrs_old structure so that use-space library can avoid any unnecessary allocations. The only defferent part is that we store the actual length of the address buffer into the addrs_num structure member. That way we can re-use the existing code. */ SCTP_STATIC int sctp_getsockopt_connectx3(struct sock *sk, int len, char __user *optval, int __user *optlen)
{ struct sctp_getaddrs_old param; sctp_assoc_t assoc_id = 0; int err = 0; if (len < sizeof(param)) return -EINVAL; if (copy_from_user(&param, optval, sizeof(param))) return -EFAULT; err = __sctp_setsockopt_connectx(sk, (struct sockaddr __user *)param.addrs, param.addr_num, &assoc_id); if (err == 0 || err == -EINPROGRESS) { if (copy_to_user(optval, &assoc_id, sizeof(assoc_id))) return -EFAULT; if (put_user(sizeof(assoc_id), optlen)) return -EFAULT; } return err; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Clear the SPI interrupt flag of the specified SPI port. */
void SPIIntFlagClear(unsigned long ulBase, unsigned long ulIntFlags)
/* Clear the SPI interrupt flag of the specified SPI port. */ void SPIIntFlagClear(unsigned long ulBase, unsigned long ulIntFlags)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)); xHWREG(ulBase + SPI_SR) &= ~ulIntFlags; }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Take ownership of all the rx Descriptors. This function is called when there is fatal error in DMA transmission. When called it takes the ownership of all the tx descriptor in tx descriptor pool/queue from DMA. The function is same for both the ring mode and the chain mode DMA structures. */
void synopGMAC_take_desc_ownership_tx(synopGMACdevice *gmacdev)
/* Take ownership of all the rx Descriptors. This function is called when there is fatal error in DMA transmission. When called it takes the ownership of all the tx descriptor in tx descriptor pool/queue from DMA. The function is same for both the ring mode and the chain mode DMA structures. */ void synopGMAC_take_desc_ownership_tx(synopGMACdevice *gmacdev)
{ s32 i; DmaDesc *desc; desc = gmacdev->TxDesc; for (i = 0; i < gmacdev->TxDescCount; i++) { if (synopGMAC_is_tx_desc_chained(desc)) { synopGMAC_take_desc_ownership(desc); desc = (DmaDesc *)desc->data2; } else { synopGMAC_take_desc_ownership(desc + i); } } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) */
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
/* Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) */ void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
{ if(indev->driver.type != LV_INDEV_TYPE_POINTER) return; indev->cursor = cur_obj; lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Force BREAK character on UART line, output pin UARTx TXD is forced to logic 0. */
void UART_ForceBreak(LPC_UART_TypeDef *UARTx)
/* Force BREAK character on UART line, output pin UARTx TXD is forced to logic 0. */ void UART_ForceBreak(LPC_UART_TypeDef *UARTx)
{ if (((LPC_UART1_TypeDef *)UARTx) == LPC_UART1) { ((LPC_UART1_TypeDef *)UARTx)->LCR |= UART_LCR_BREAK_EN; } else { UARTx->LCR |= UART_LCR_BREAK_EN; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sends the contents of a data buffer a SSC peripheral, using the PDC. Returns true if the buffer has been queued for transmission; otherwise returns false. */
unsigned char SSC_WriteBuffer(AT91S_SSC *ssc, void *buffer, unsigned int length)
/* Sends the contents of a data buffer a SSC peripheral, using the PDC. Returns true if the buffer has been queued for transmission; otherwise returns false. */ unsigned char SSC_WriteBuffer(AT91S_SSC *ssc, void *buffer, unsigned int length)
{ if (ssc->SSC_TCR == 0) { ssc->SSC_TPR = (unsigned int) buffer; ssc->SSC_TCR = length; ssc->SSC_PTCR = AT91C_PDC_TXTEN; return 1; } else if (ssc->SSC_TNCR == 0) { ssc->SSC_TNPR = (unsigned int) buffer; ssc->SSC_TNCR = length; return 1; } return 0; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Initialise the per-inode cache cookie pointer for an NFS inode. */
void nfs_fscache_init_inode_cookie(struct inode *inode)
/* Initialise the per-inode cache cookie pointer for an NFS inode. */ void nfs_fscache_init_inode_cookie(struct inode *inode)
{ NFS_I(inode)->fscache = NULL; if (S_ISREG(inode->i_mode)) set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags); }
robutest/uclinux
C++
GPL-2.0
60
/* Converts a text device path node to CDROM device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextCDROM(IN CHAR16 *TextDeviceNode)
/* Converts a text device path node to CDROM device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextCDROM(IN CHAR16 *TextDeviceNode)
{ CHAR16 *EntryStr; CHAR16 *StartStr; CHAR16 *SizeStr; CDROM_DEVICE_PATH *CDROMDevPath; EntryStr = GetNextParamStr (&TextDeviceNode); StartStr = GetNextParamStr (&TextDeviceNode); SizeStr = GetNextParamStr (&TextDeviceNode); CDROMDevPath = (CDROM_DEVICE_PATH *)CreateDeviceNode ( MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, (UINT16)sizeof (CDROM_DEVICE_PATH) ); CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr); Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); return (EFI_DEVICE_PATH_PROTOCOL *)CDROMDevPath; }
tianocore/edk2
C++
Other
4,240
/* This function tries to read a node and returns %1 if the node is read, %0 if the node is not present, and a negative error code in the case of error. */
static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, struct ubifs_zbranch *zbr, void *node)
/* This function tries to read a node and returns %1 if the node is read, %0 if the node is not present, and a negative error code in the case of error. */ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, struct ubifs_zbranch *zbr, void *node)
{ int ret; dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs); ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum, zbr->offs); if (ret == 1) { union ubifs_key node_key; struct ubifs_dent_node *dent = node; key_read(c, &dent->key, &node_key); if (keys_cmp(c, key, &node_key) != 0) ret = 0; } if (ret == 0 && c->replaying) dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ", zbr->lnum, zbr->offs, zbr->len); return ret; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Set boot source from LDROM or APROM after next software reset. */
void FMC_SetBootSource(int32_t i32BootSrc)
/* Set boot source from LDROM or APROM after next software reset. */ void FMC_SetBootSource(int32_t i32BootSrc)
{ if (i32BootSrc) { FMC->ISPCTL |= FMC_ISPCTL_BS_Msk; } else { FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* PSA Random number generator wrapper for Mbed TLS. */
static int psa_rng_for_mbedtls(void *p_rng, unsigned char *output, size_t output_len)
/* PSA Random number generator wrapper for Mbed TLS. */ static int psa_rng_for_mbedtls(void *p_rng, unsigned char *output, size_t output_len)
{ (void)p_rng; return psa_generate_random(output, output_len); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* This function "opens" SMRAM so that it is visible while not inside of SMM. The function should return EFI_UNSUPPORTED if the hardware does not support hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM configuration is locked. */
STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
/* This function "opens" SMRAM so that it is visible while not inside of SMM. The function should return EFI_UNSUPPORTED if the hardware does not support hiding of SMRAM. The function should return EFI_DEVICE_ERROR if the SMRAM configuration is locked. */ STATIC EFI_STATUS EFIAPI SmmAccessPeiOpen(IN EFI_PEI_SERVICES **PeiServices, IN PEI_SMM_ACCESS_PPI *This, IN UINTN DescriptorIndex)
{ if (DescriptorIndex >= DescIdxCount) { return EFI_INVALID_PARAMETER; } return SmramAccessOpen (&This->LockState, &This->OpenState); }
tianocore/edk2
C++
Other
4,240
/* Copy the PrefixLength bits from Src to Dest. */
VOID Ip6CopyAddressByPrefix(OUT EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src, IN UINT8 PrefixLength)
/* Copy the PrefixLength bits from Src to Dest. */ VOID Ip6CopyAddressByPrefix(OUT EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src, IN UINT8 PrefixLength)
{ UINT8 Byte; UINT8 Bit; UINT8 Mask; ASSERT (Dest != NULL && Src != NULL); ASSERT (PrefixLength <= IP6_PREFIX_MAX); Byte = (UINT8)(PrefixLength / 8); Bit = (UINT8)(PrefixLength % 8); ZeroMem (Dest, sizeof (EFI_IPv6_ADDRESS)); CopyMem (Dest, Src, Byte); if (Bit > 0) { Mask = (UINT8)(0xFF << (8 - Bit)); ASSERT (Byte < 16); Dest->Addr[Byte] = (UINT8)(Src->Addr[Byte] & Mask); } }
tianocore/edk2
C++
Other
4,240
/* Must be called with interrupt disabled and spinlock held */
static void dwc2_kill_all_urbs(struct dwc2_hsotg *hsotg)
/* Must be called with interrupt disabled and spinlock held */ static void dwc2_kill_all_urbs(struct dwc2_hsotg *hsotg)
{ dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->non_periodic_sched_inactive); dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->non_periodic_sched_active); dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_inactive); dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_ready); dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_assigned); dwc2_kill_urbs_in_qh_list(hsotg, &hsotg->periodic_sched_queued); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns current source and destination addresses for a particular parameter RAM slot. Its channel should not be active when this is called. */
void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst)
/* Returns current source and destination addresses for a particular parameter RAM slot. Its channel should not be active when this is called. */ void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst)
{ struct edmacc_param temp; unsigned ctlr; ctlr = EDMA_CTLR(slot); slot = EDMA_CHAN_SLOT(slot); edma_read_slot(EDMA_CTLR_CHAN(ctlr, slot), &temp); if (src != NULL) *src = temp.src; if (dst != NULL) *dst = temp.dst; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Write a 32 bit IO APIC register. This routine writes the specified IO APIC register using indirect addressing. */
static __pinned_func void __IoApicSet(int32_t offset, uint32_t value)
/* Write a 32 bit IO APIC register. This routine writes the specified IO APIC register using indirect addressing. */ static __pinned_func void __IoApicSet(int32_t offset, uint32_t value)
{ unsigned int key; key = irq_lock(); *(volatile uint32_t *)(IOAPIC_REG + IOAPIC_IND) = (unsigned char)offset; *((volatile uint32_t *)(IOAPIC_REG + IOAPIC_DATA)) = value; irq_unlock(key); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* fc_fcp_ddp_setup() - Calls a LLD's ddp_setup routine to set up DDP context @fsp: The FCP packet that will manage the DDP frames @xid: The XID that will be used for the DDP exchange */
void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid)
/* fc_fcp_ddp_setup() - Calls a LLD's ddp_setup routine to set up DDP context @fsp: The FCP packet that will manage the DDP frames @xid: The XID that will be used for the DDP exchange */ void fc_fcp_ddp_setup(struct fc_fcp_pkt *fsp, u16 xid)
{ struct fc_lport *lport; lport = fsp->lp; if ((fsp->req_flags & FC_SRB_READ) && (lport->lro_enabled) && (lport->tt.ddp_setup)) { if (lport->tt.ddp_setup(lport, xid, scsi_sglist(fsp->cmd), scsi_sg_count(fsp->cmd))) fsp->xfer_ddp = xid; } }
robutest/uclinux
C++
GPL-2.0
60
/* This function set the thread creation stacksize attribute in the attr object. */
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stack_size)
/* This function set the thread creation stacksize attribute in the attr object. */ int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stack_size)
{ RT_ASSERT(attr != RT_NULL); attr->stacksize = stack_size; return 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This syscall also checks the @tgid and returns -ESRCH even if the PID exists but it's not belonging to the target process anymore. This method solves the problem of threads exiting and PIDs getting reused. */
SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)
/* This syscall also checks the @tgid and returns -ESRCH even if the PID exists but it's not belonging to the target process anymore. This method solves the problem of threads exiting and PIDs getting reused. */ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)
{ if (pid <= 0 || tgid <= 0) return -EINVAL; return do_tkill(tgid, pid, sig); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enables or disables the I2C 10-bit addressing mode for the master. */
void I2C_10BitAddressingModeCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
/* Enables or disables the I2C 10-bit addressing mode for the master. */ void I2C_10BitAddressingModeCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
{ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { I2Cx->CR2 |= I2C_CR2_ADD10; } else { I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_ADD10); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* return PHY address. If PHY don't fount, returns 255. */
uint8_t PHY_probe(void)
/* return PHY address. If PHY don't fount, returns 255. */ uint8_t PHY_probe(void)
{ uint8_t phy; uint8_t phy_found; uint16_t reg; phy_found = 0; for (phy = MSS_PHY_ADDRESS_MIN; phy <= MSS_PHY_ADDRESS_MAX; phy++) { g_mss_mac.phy_address = phy; reg = MDIO_read( PHYREG_PHYID1R ); if ((reg != 0x0000ffffUL) && (reg != 0x00000000UL)) { phy_found = 1; phy = MSS_PHY_ADDRESS_MAX + 1; } } if( phy_found == 0 ) { g_mss_mac.phy_address = MSS_PHY_ADDRESS_AUTO_DETECT; } return g_mss_mac.phy_address; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* vx_set_stream_format - send the stream format command @pipe: the affected pipe @data: format bitmask */
static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe, unsigned int data)
/* vx_set_stream_format - send the stream format command @pipe: the affected pipe @data: format bitmask */ static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe, unsigned int data)
{ struct vx_rmh rmh; vx_init_rmh(&rmh, pipe->is_capture ? CMD_FORMAT_STREAM_IN : CMD_FORMAT_STREAM_OUT); rmh.Cmd[0] |= pipe->number << FIELD_SIZE; vx_set_differed_time(chip, &rmh, pipe); rmh.Cmd[rmh.LgCmd] = (data & 0xFFFFFF00) >> 8; rmh.Cmd[rmh.LgCmd + 1] = (data & 0xFF) << 16; rmh.LgCmd += 2; return vx_send_msg(chip, &rmh); }
robutest/uclinux
C++
GPL-2.0
60
/* Reads the time stamp contents in to the respective pointers These registers are readonly. This function returns the 48 bit time stamp assuming Version 2 timestamp with higher word is selected. */
void synopGMAC_TS_read_timestamp(synopGMACdevice *gmacdev, u16 *higher_sec_val, u32 *sec_val, u32 *sub_sec_val)
/* Reads the time stamp contents in to the respective pointers These registers are readonly. This function returns the 48 bit time stamp assuming Version 2 timestamp with higher word is selected. */ void synopGMAC_TS_read_timestamp(synopGMACdevice *gmacdev, u16 *higher_sec_val, u32 *sec_val, u32 *sub_sec_val)
{ * higher_sec_val = (u16)(synopGMACReadReg(gmacdev->MacBase,GmacTSHighWord) & GmacTSHighWordMask); * sec_val = synopGMACReadReg(gmacdev->MacBase,GmacTSHigh); * sub_sec_val = synopGMACReadReg(gmacdev->MacBase,GmacTSLow); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable Write Protect on pages marked as read-only. */
VOID EnableReadOnlyPageWriteProtect(VOID)
/* Enable Write Protect on pages marked as read-only. */ VOID EnableReadOnlyPageWriteProtect(VOID)
{ IA32_CR0 Cr0; if (!IsInSmm ()) { Cr0.UintN = AsmReadCr0 (); Cr0.Bits.WP = 1; AsmWriteCr0 (Cr0.UintN); } }
tianocore/edk2
C++
Other
4,240
/* Assign bond->master_ipv6 to the next IPv6 address in the list, or zero it out if there are none. */
static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr)
/* Assign bond->master_ipv6 to the next IPv6 address in the list, or zero it out if there are none. */ static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr)
{ struct inet6_dev *idev; struct inet6_ifaddr *ifa; if (!dev) return; idev = in6_dev_get(dev); if (!idev) return; read_lock_bh(&idev->lock); ifa = idev->addr_list; if (ifa) ipv6_addr_copy(addr, &ifa->addr); else ipv6_addr_set(addr, 0, 0, 0, 0); read_unlock_bh(&idev->lock); in6_dev_put(idev); }
robutest/uclinux
C++
GPL-2.0
60
/* This function frees memory associated with the mailbox command. */
static void lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
/* This function frees memory associated with the mailbox command. */ static void lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
{ struct lpfc_vport *vport = mboxq->vport; if (mboxq->u.mb.mbxStatus) { lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, "2555 UNREG_VFI mbxStatus error x%x " "HBA state x%x\n", mboxq->u.mb.mbxStatus, vport->port_state); } mempool_free(mboxq, phba->mbox_mem_pool); return; }
robutest/uclinux
C++
GPL-2.0
60
/* USBD_Init Initailizes the device stack and load the class driver. */
void USBD_Init(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID, USBD_DEVICE *pDevice, USBD_Class_cb_TypeDef *class_cb, USBD_Usr_cb_TypeDef *usr_cb)
/* USBD_Init Initailizes the device stack and load the class driver. */ void USBD_Init(USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID, USBD_DEVICE *pDevice, USBD_Class_cb_TypeDef *class_cb, USBD_Usr_cb_TypeDef *usr_cb)
{ USB_OTG_BSP_Init(pdev); USBD_DeInit(pdev); pdev->dev.class_cb = class_cb; pdev->dev.usr_cb = usr_cb; pdev->dev.usr_device = pDevice; DCD_Init(pdev , coreID); pdev->dev.usr_cb->Init(); USB_OTG_BSP_EnableInterrupt(pdev); }
MaJerle/stm32f429
C++
null
2,036
/* Further optimization could be realized by adding an ability to cache the directory in memory. The goal being a single comprehensive file read to put the file I need in a memory. typedef struct unz_file_pos_s { uLong pos_in_zip_directory; // offset in file uLong num_of_file; // # of file } unz_file_pos; */
int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
/* Further optimization could be realized by adding an ability to cache the directory in memory. The goal being a single comprehensive file read to put the file I need in a memory. typedef struct unz_file_pos_s { uLong pos_in_zip_directory; // offset in file uLong num_of_file; // # of file } unz_file_pos; */ int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
{ unz_s* s; if (file == NULL || file_pos == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; file_pos->pos_in_zip_directory = s->pos_in_central_dir; file_pos->num_of_file = s->num_file; return UNZ_OK; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Don't try to provide a year that's before 1998, please ! */
static int compute_wday(efi_time_t *eft)
/* Don't try to provide a year that's before 1998, please ! */ static int compute_wday(efi_time_t *eft)
{ int y; int ndays = 0; if (eft->year < 1998) { printk(KERN_ERR "efirtc: EFI year < 1998, invalid date\n"); return -1; } for (y = EFI_RTC_EPOCH; y < eft->year; y++) ndays += 365 + (is_leap_year(y) ? 1 : 0); ndays += compute_yday(eft); return (ndays + 4) % 7; }
robutest/uclinux
C++
GPL-2.0
60
/* Scheduler clock - returns current time in nanosec units. */
unsigned long long notrace sched_clock(void)
/* Scheduler clock - returns current time in nanosec units. */ unsigned long long notrace sched_clock(void)
{ return (get_clock_monotonic() * 125) >> 9; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Add a Multicast address to slaves according to mode */
static void bond_mc_add(struct bonding *bond, void *addr, int alen)
/* Add a Multicast address to slaves according to mode */ static void bond_mc_add(struct bonding *bond, void *addr, int alen)
{ if (USES_PRIMARY(bond->params.mode)) { if (bond->curr_active_slave) dev_mc_add(bond->curr_active_slave->dev, addr, alen, 0); } else { struct slave *slave; int i; bond_for_each_slave(bond, slave, i) dev_mc_add(slave->dev, addr, alen, 0); } }
robutest/uclinux
C++
GPL-2.0
60
/* pci_request_selected_regions - Reserve selected PCI I/O and memory resources @pdev: PCI device whose resources are to be reserved @bars: Bitmask of BARs to be requested @res_name: Name to be associated with resource */
int pci_request_selected_regions(struct pci_dev *pdev, int bars, const char *res_name)
/* pci_request_selected_regions - Reserve selected PCI I/O and memory resources @pdev: PCI device whose resources are to be reserved @bars: Bitmask of BARs to be requested @res_name: Name to be associated with resource */ int pci_request_selected_regions(struct pci_dev *pdev, int bars, const char *res_name)
{ return __pci_request_selected_regions(pdev, bars, res_name, 0); }
robutest/uclinux
C++
GPL-2.0
60
/* write the filemap data using writepage() address_space_operations. We don't do block allocation here even for delalloc. We don't use writepages() because with dealyed allocation we may be doing block allocation in writepages(). */
static int journal_submit_inode_data_buffers(struct address_space *mapping)
/* write the filemap data using writepage() address_space_operations. We don't do block allocation here even for delalloc. We don't use writepages() because with dealyed allocation we may be doing block allocation in writepages(). */ static int journal_submit_inode_data_buffers(struct address_space *mapping)
{ int ret; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = mapping->nrpages * 2, .range_start = 0, .range_end = i_size_read(mapping->host), }; ret = generic_writepages(mapping, &wbc); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* PCD MSP Initialization This function configures the hardware resources used in this example. */
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
/* PCD MSP Initialization This function configures the hardware resources used in this example. */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
{ GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hpcd->Instance==USB_DRD_FS) { PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); } __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = USB_FS_DN_Pin|USB_FS_DP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_USB; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_USB_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function is used for the soft reset The soft reset register will be written with 0xB6 in the register 0x14. */
BMG160_RETURN_FUNCTION_TYPE bmg160_set_soft_rst(void)
/* This function is used for the soft reset The soft reset register will be written with 0xB6 in the register 0x14. */ BMG160_RETURN_FUNCTION_TYPE bmg160_set_soft_rst(void)
{ BMG160_RETURN_FUNCTION_TYPE comres = ERROR; u8 v_soft_rst_u8 = BMG160_INIT_VALUE; v_soft_rst_u8 = BMG160_SOFT_RESET; if (p_bmg160 == BMG160_NULL) { return E_BMG160_NULL_PTR; } else { comres = p_bmg160->BMG160_BUS_WRITE_FUNC(p_bmg160->dev_addr, BMG160_BGW_SOFT_RST_ADDR, &v_soft_rst_u8, BMG160_GEN_READ_WRITE_DATA_LENGTH); } return comres; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The socket function closes a created socket. closesocket */
INT32 CC3000_EXPORT() closesocket(INT32 sd)
/* The socket function closes a created socket. closesocket */ INT32 CC3000_EXPORT() closesocket(INT32 sd)
{ INT32 ret; UINT8 *ptr, *args; ret = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + HEADERS_SIZE_CMD); args = UINT32_TO_STREAM(args, sd); hci_command_send(HCI_CMND_CLOSE_SOCKET, ptr, SOCKET_CLOSE_PARAMS_LEN); SimpleLinkWaitEvent(HCI_CMND_CLOSE_SOCKET, &ret); CC3000_EXPORT(errno) = ret; set_socket_active_status(sd, SOCKET_STATUS_INACTIVE); return(ret); }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Copies one line from file_instanse into buf, On sucessful the destination buf buf is changed into NULL terminated C String. If log content size is longer than buf_len-1, remain will be not saved and NULL terminatated is implicitly appended at the end of destination. */
int get_log_line(const int fd, char *buf, const uint16_t buf_len)
/* Copies one line from file_instanse into buf, On sucessful the destination buf buf is changed into NULL terminated C String. If log content size is longer than buf_len-1, remain will be not saved and NULL terminatated is implicitly appended at the end of destination. */ int get_log_line(const int fd, char *buf, const uint16_t buf_len)
{ int rc = -1; int cnt = 0; if (fd < 0 || NULL == buf || buf_len <= 0) { return -1; } memset(buf, 0, buf_len); while ((cnt < buf_len) && (0 < aos_read(fd, &buf[cnt], 1))) { if (buf[cnt] == LOG_LINE_SEPARATOR) { break; } cnt++; } if (cnt == 0) { rc = 0; } else if (cnt < buf_len) { if (buf[cnt - 1] == LOG_LINE_SEPARATOR) { buf[cnt - 1] = 0; } else { buf[cnt] = 0; } rc = cnt; } else { rc = cnt; buf[cnt - 1] = 0; } return rc; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Deinitializes the uart peripheral registers to their default reset values. */
void UART_DeInit(UART_TypeDef *uart)
/* Deinitializes the uart peripheral registers to their default reset values. */ void UART_DeInit(UART_TypeDef *uart)
{ if(UART2 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART2); } if(UART1 == uart) { exRCC_APB2PeriphReset(RCC_APB2ENR_UART1); } if(UART3 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART3); } if(UART4 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART4); } if(UART5 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART5); } if(UART6 == uart) { exRCC_APB2PeriphReset(RCC_APB2ENR_UART6); } if(UART7 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART7); } if(UART8 == uart) { exRCC_APB1PeriphReset(RCC_APB1ENR_UART8); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Send an IGMP membership report. Depends on whether the server is v1 or v2, it will send either a V1 or V2 membership report. */
EFI_STATUS Ip4SendIgmpReport(IN IP4_SERVICE *IpSb, IN IP4_ADDR Group)
/* Send an IGMP membership report. Depends on whether the server is v1 or v2, it will send either a V1 or V2 membership report. */ EFI_STATUS Ip4SendIgmpReport(IN IP4_SERVICE *IpSb, IN IP4_ADDR Group)
{ if (IpSb->IgmpCtrl.Igmpv1QuerySeen != 0) { return Ip4SendIgmpMessage (IpSb, Group, IGMP_V1_MEMBERSHIP_REPORT, Group); } else { return Ip4SendIgmpMessage (IpSb, Group, IGMP_V2_MEMBERSHIP_REPORT, Group); } }
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 Vector32_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 Vector32_handler(void)
{ asm { LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (32 * 2)) JMP 0,X } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Sync the fph state of the task so that it can be manipulated through thread.fph. If necessary, f32-f127 are written back to thread.fph or, if the fph state hasn't been used before, thread.fph is cleared to zeroes. Also, access to f32-f127 is disabled to ensure that the task picks up the state from thread.fph when it executes again. */
void ia64_sync_fph(struct task_struct *task)
/* Sync the fph state of the task so that it can be manipulated through thread.fph. If necessary, f32-f127 are written back to thread.fph or, if the fph state hasn't been used before, thread.fph is cleared to zeroes. Also, access to f32-f127 is disabled to ensure that the task picks up the state from thread.fph when it executes again. */ void ia64_sync_fph(struct task_struct *task)
{ struct ia64_psr *psr = ia64_psr(task_pt_regs(task)); ia64_flush_fph(task); if (!(task->thread.flags & IA64_THREAD_FPH_VALID)) { task->thread.flags |= IA64_THREAD_FPH_VALID; memset(&task->thread.fph, 0, sizeof(task->thread.fph)); } ia64_drop_fpu(task); psr->dfh = 1; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Synchronizes the counters in one or multiple PWM generator blocks. */
void PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits)
/* Synchronizes the counters in one or multiple PWM generator blocks. */ void PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits)
{ ASSERT((ui32Base == PWM0_BASE) || (ui32Base == PWM1_BASE)); ASSERT(!(ui32GenBits & ~(PWM_GEN_0_BIT | PWM_GEN_1_BIT | PWM_GEN_2_BIT | PWM_GEN_3_BIT))); HWREG(ui32Base + PWM_O_SYNC) = ui32GenBits; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Write buf to the FCM Controller Data Buffer */
static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
/* Write buf to the FCM Controller Data Buffer */ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
{ struct nand_chip *chip = mtd_to_nand(mtd); struct fsl_elbc_mtd *priv = nand_get_controller_data(chip); struct fsl_elbc_ctrl *ctrl = priv->ctrl; unsigned int bufsize = mtd->writesize + mtd->oobsize; if (len <= 0) { printf("write_buf of %d bytes", len); ctrl->status = 0; return; } if ((unsigned int)len > bufsize - ctrl->index) { printf("write_buf beyond end of buffer " "(%d requested, %u available)\n", len, bufsize - ctrl->index); len = bufsize - ctrl->index; } memcpy_toio(&ctrl->addr[ctrl->index], buf, len); in_8(&ctrl->addr[ctrl->index] + len - 1); ctrl->index += len; }
4ms/stm32mp1-baremetal
C++
Other
137
/* TI TLK105 & DP83822 PHY link status polling function Link status polling function for the TI TLK105 & DP83822 PHYs. */
static uint8_t phy_xlnx_gem_ti_dp83822_poll_lsts(const struct device *dev)
/* TI TLK105 & DP83822 PHY link status polling function Link status polling function for the TI TLK105 & DP83822 PHYs. */ static uint8_t phy_xlnx_gem_ti_dp83822_poll_lsts(const struct device *dev)
{ const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config; struct eth_xlnx_gem_dev_data *dev_data = dev->data; uint16_t phy_data; phy_data = phy_xlnx_gem_mdio_read(dev_conf->base_addr, dev_data->phy_addr, PHY_TI_BASIC_MODE_STATUS_REGISTER); phy_data = phy_xlnx_gem_mdio_read(dev_conf->base_addr, dev_data->phy_addr, PHY_TI_BASIC_MODE_STATUS_REGISTER); return ((phy_data & PHY_TI_BASIC_MODE_STATUS_LINK_STATUS_BIT) != 0); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* The constructor function initializes the Mm Mem library */
EFI_STATUS EFIAPI MemLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
/* The constructor function initializes the Mm Mem library */ EFI_STATUS EFIAPI MemLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
{ EFI_STATUS Status; MmMemLibInternalCalculateMaximumSupportAddress (); Status = MmMemLibInternalPopulateMmramRanges (); return Status; }
tianocore/edk2
C++
Other
4,240
/* Configure the edge detector of an input pin. */
static uint32_t gpio_configure_edge_detector(uint32_t pin, uint32_t mode)
/* Configure the edge detector of an input pin. */ static uint32_t gpio_configure_edge_detector(uint32_t pin, uint32_t mode)
{ volatile avr32_gpio_port_t *gpio_port = &AVR32_GPIO.port[pin >> 5]; switch (mode) { case GPIO_PIN_CHANGE: gpio_port->imr0c = 1 << (pin & 0x1F); gpio_port->imr1c = 1 << (pin & 0x1F); break; case GPIO_RISING_EDGE: gpio_port->imr0s = 1 << (pin & 0x1F); gpio_port->imr1c = 1 << (pin & 0x1F); break; case GPIO_FALLING_EDGE: gpio_port->imr0c = 1 << (pin & 0x1F); gpio_port->imr1s = 1 << (pin & 0x1F); break; default: return GPIO_INVALID_ARGUMENT; } return GPIO_SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables the PWM dead band output, and sets the dead band delays. */
void PWMDeadBandEnable(unsigned long ulBase, unsigned long ulGen, unsigned short usRise, unsigned short usFall)
/* Enables the PWM dead band output, and sets the dead band delays. */ void PWMDeadBandEnable(unsigned long ulBase, unsigned long ulGen, unsigned short usRise, unsigned short usFall)
{ ASSERT(ulBase == PWM_BASE); ASSERT(PWMGenValid(ulGen)); ASSERT(usRise < 4096); ASSERT(usFall < 4096); ulGen = PWM_GEN_BADDR(ulBase, ulGen); HWREG(ulGen + PWM_O_X_DBRISE) = usRise; HWREG(ulGen + PWM_O_X_DBFALL) = usFall; HWREG(ulGen + PWM_O_X_DBCTL) |= PWM_X_DBCTL_ENABLE; }
watterott/WebRadio
C++
null
71
/* In TDX a serial of TdIoRead32 is invoked to read data from the I/O port. */
VOID EFIAPI IoReadFifo32(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
/* In TDX a serial of TdIoRead32 is invoked to read data from the I/O port. */ VOID EFIAPI IoReadFifo32(IN UINTN Port, IN UINTN Count, OUT VOID *Buffer)
{ UINT32 *Buffer32; Buffer32 = (UINT32 *)Buffer; while (Count-- > 0) { *Buffer32++ = IoRead32 (Port); } }
tianocore/edk2
C++
Other
4,240
/* Account for idle time. @cputime: the cpu time spent in idle wait */
void account_idle_time(cputime_t cputime)
/* Account for idle time. @cputime: the cpu time spent in idle wait */ void account_idle_time(cputime_t cputime)
{ struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; cputime64_t cputime64 = cputime_to_cputime64(cputime); struct rq *rq = this_rq(); if (atomic_read(&rq->nr_iowait) > 0) cpustat->iowait = cputime64_add(cpustat->iowait, cputime64); else cpustat->idle = cputime64_add(cpustat->idle, cputime64); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Do not optimize to prevent GCC from generating invalid opcode exception instruction instead of real instruction. */
static __no_optimization void trigger_fault_illegal_instruction(void)
/* Do not optimize to prevent GCC from generating invalid opcode exception instruction instead of real instruction. */ static __no_optimization void trigger_fault_illegal_instruction(void)
{ void *a = NULL; ((void(*)(void))&a)(); }
zephyrproject-rtos/zephyr
C++
Apache License 2.0
9,573
/* @fout: Output file @col: Colour to output (COL_...), or COL_NONE to reset colour */
static void print_ansi_colour(FILE *fout, int col)
/* @fout: Output file @col: Colour to output (COL_...), or COL_NONE to reset colour */ static void print_ansi_colour(FILE *fout, int col)
{ if (col == COL_NONE) fprintf(fout, "\033[0m"); else fprintf(fout, "\033[1;%dm", col + 30); }
4ms/stm32mp1-baremetal
C++
Other
137
/* Whether the platform supports capsules that persist across reset. Note that some platforms only support such capsules at boot time. */
BOOLEAN IsPersistAcrossResetCapsuleSupported(VOID)
/* Whether the platform supports capsules that persist across reset. Note that some platforms only support such capsules at boot time. */ BOOLEAN IsPersistAcrossResetCapsuleSupported(VOID)
{ return FeaturePcdGet (PcdSupportUpdateCapsuleReset) && !EfiAtRuntime (); }
tianocore/edk2
C++
Other
4,240
/* dccp_feat_index - Hash function to map feature number into array position Returns consecutive array index or -1 if the feature is not understood. */
static int dccp_feat_index(u8 feat_num)
/* dccp_feat_index - Hash function to map feature number into array position Returns consecutive array index or -1 if the feature is not understood. */ static int dccp_feat_index(u8 feat_num)
{ if (feat_num > DCCPF_RESERVED && feat_num <= DCCPF_DATA_CHECKSUM) return feat_num - 1; switch (feat_num) { case DCCPF_SEND_LEV_RATE: return DCCP_FEAT_SUPPORTED_MAX - 1; } return -1; }
EmcraftSystems/linux-emcraft
C++
Other
266