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
/* Adjust an allocation size to be aligned to word size, and no smaller than internal minimum. */
static size_t adjust_request_size(size_t size, size_t align)
/* Adjust an allocation size to be aligned to word size, and no smaller than internal minimum. */ static size_t adjust_request_size(size_t size, size_t align)
{ size_t adjust = 0; if(size) { const size_t aligned = align_up(size, align); if(aligned < block_size_max) { adjust = tlsf_max(aligned, block_size_min); } } return adjust; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Retrieves the the count of free buffers in the ACL fragment pool. */
int ble_hs_hci_frag_num_mbufs_free(void)
/* Retrieves the the count of free buffers in the ACL fragment pool. */ int ble_hs_hci_frag_num_mbufs_free(void)
{ return ble_hs_hci_frag_mempool.mp_num_free; }
Nicholas3388/LuaNode
C++
Other
1,055
/* free_all_swap_pages - free swap pages allocated for saving image data. It also frees the extents used to register which swap entres had been allocated. */
void free_all_swap_pages(int swap)
/* free_all_swap_pages - free swap pages allocated for saving image data. It also frees the extents used to register which swap entres had been allocated. */ void free_all_swap_pages(int swap)
{ struct rb_node *node; while ((node = swsusp_extents.rb_node)) { struct swsusp_extent *ext; unsigned long offset; ext = container_of(node, struct swsusp_extent, node); rb_erase(node, &swsusp_extents); for (offset = ext->start; offset <= ext->end; offset++) swap_free(swp_entry(swap, offset)); kfree(ext); } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns the clock source used as RTC clock (RTCCLK). */
uint32_t RCC_GetRTCClkSrc(void)
/* Returns the clock source used as RTC clock (RTCCLK). */ uint32_t RCC_GetRTCClkSrc(void)
{ return ((uint32_t)(RCC->LDCTRL & RCC_LDCTRL_RTCSEL)); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Returns: TRUE if the mount points have changed since @time. */
gboolean g_unix_mount_points_changed_since(guint64 time)
/* Returns: TRUE if the mount points have changed since @time. */ gboolean g_unix_mount_points_changed_since(guint64 time)
{ return get_mount_points_timestamp () != time; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Function is used to determine the number of device path instances that exist in a device path. */
UINTN EfiDevicePathInstanceCount(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
/* Function is used to determine the number of device path instances that exist in a device path. */ UINTN EfiDevicePathInstanceCount(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
{ UINTN Count; UINTN Size; Count = 0; while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) { Count += 1; } return Count; }
tianocore/edk2
C++
Other
4,240
/* Description: Process a user generated PROTOCOLS message and respond accordingly. */
static int netlbl_mgmt_protocols(struct sk_buff *skb, struct netlink_callback *cb)
/* Description: Process a user generated PROTOCOLS message and respond accordingly. */ static int netlbl_mgmt_protocols(struct sk_buff *skb, struct netlink_callback *cb)
{ u32 protos_sent = cb->args[0]; if (protos_sent == 0) { if (netlbl_mgmt_protocols_cb(skb, cb, NETLBL_NLTYPE_UNLABELED) < 0) goto protocols_return; protos_sent++; } if (protos_sent == 1) { if (netlbl_mgmt_protocols_cb(skb, cb, NETLBL_NLTYPE_CIPSOV4) < 0) goto protocols_return; protos_sent++; } protocols_return: cb->args[0] = protos_sent; return skb->len; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* The codec has no support for reading its registers except for peak level... */
static unsigned int uda134x_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg)
/* The codec has no support for reading its registers except for peak level... */ static unsigned int uda134x_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg)
{ u8 *cache = codec->reg_cache; if (reg >= UDA134X_REGS_NUM) return -1; return cache[reg]; }
robutest/uclinux
C++
GPL-2.0
60
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_CS42448_SetMute(void *handle, uint32_t playChannel, bool isMute)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param isMute true is mute, false is unmute. return kStatus_Success is success, else configure failed. */ status_t HAL_CODEC_CS42448_SetMute(void *handle, uint32_t playChannel, bool isMute)
{ assert(handle != NULL); uint8_t i = 0U; status_t ret = kStatus_Success; for (i = 0U; i < (uint8_t)kCS42448_AOUT8; i++) { if ((playChannel & (1UL << i)) == 0U) { continue; } ret = CS42448_SetChannelMute((cs42448_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)), (uint8_t)(i + 1U), isMute); if (ret != kStatus_Success) { return ret; } } return kStatus_Success; }
eclipse-threadx/getting-started
C++
Other
310
/* Returns the combined result, note that if a pointer is 32-bit wide @reg0 will be discarded. */
static void* reg_pair_to_ptr(u32 reg0, u32 reg1)
/* Returns the combined result, note that if a pointer is 32-bit wide @reg0 will be discarded. */ static void* reg_pair_to_ptr(u32 reg0, u32 reg1)
{ return (void *)(ulong)(((u64)reg0 << 32) | reg1); }
4ms/stm32mp1-baremetal
C++
Other
137
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. If this interface is not supported, then return FALSE. */
BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
/* If AesContext is NULL, then return FALSE. If Input is NULL, then return FALSE. If InputSize is not multiple of block size (16 bytes), then return FALSE. If Ivec is NULL, then return FALSE. If Output is NULL, then return FALSE. If this interface is not supported, then return FALSE. */ BOOLEAN EFIAPI AesCbcEncrypt(IN VOID *AesContext, IN CONST UINT8 *Input, IN UINTN InputSize, IN CONST UINT8 *Ivec, OUT UINT8 *Output)
{ CALL_CRYPTO_SERVICE (AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE); }
tianocore/edk2
C++
Other
4,240
/* Given a chip identifier return a suitable description. Returns a pointer a static string valid while the driver is loaded. */
static const char __devinit* get_chip_name(enum chip_type chip_id)
/* Given a chip identifier return a suitable description. Returns a pointer a static string valid while the driver is loaded. */ static const char __devinit* get_chip_name(enum chip_type chip_id)
{ int i; for (i = 0; chip_info_table[i].name != NULL; i++) if (chip_info_table[i].chip_id == chip_id) break; return chip_info_table[i].name; }
robutest/uclinux
C++
GPL-2.0
60
/* Delete entry from the list Note: ListIsEmpty() on this list entry would not return true, since its state is undefined */
void ListDeleteNode(PRT_LIST_ENTRY ListToDelete)
/* Delete entry from the list Note: ListIsEmpty() on this list entry would not return true, since its state is undefined */ void ListDeleteNode(PRT_LIST_ENTRY ListToDelete)
{ { ListToDelete->Next->Prev = ListToDelete->Prev; ListToDelete->Prev->Next = ListToDelete->Next; ListToDelete->Next = ListToDelete->Prev = ListToDelete; } }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* Write a filemark if write_filemark=1. Flush the device buffers without writing a filemark otherwise. */
static void idetape_create_write_filemark_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc, int write_filemark)
/* Write a filemark if write_filemark=1. Flush the device buffers without writing a filemark otherwise. */ static void idetape_create_write_filemark_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc, int write_filemark)
{ ide_init_pc(pc); pc->c[0] = WRITE_FILEMARKS; pc->c[4] = write_filemark; pc->flags |= PC_FLAG_WAIT_FOR_DSC; }
robutest/uclinux
C++
GPL-2.0
60
/* Reset Peripheral, release. Restore peripheral from reset state to working state. */
void rcc_periph_reset_release(enum rcc_periph_rst rst)
/* Reset Peripheral, release. Restore peripheral from reset state to working state. */ void rcc_periph_reset_release(enum rcc_periph_rst rst)
{ _RCC_REG(rst) &= ~_RCC_BIT(rst); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* configure counter reload value, and prescaler divider value */
ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
/* configure counter reload value, and prescaler divider value */ ErrStatus fwdgt_config(uint16_t reload_value, uint8_t prescaler_div)
{ uint32_t timeout = FWDGT_PSC_TIMEOUT; uint32_t flag_status = RESET; FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE; do{ flag_status = FWDGT_STAT & FWDGT_STAT_PUD; }while((--timeout > 0U) && ((uint32_t)RESET != flag_status)); if ((uint32_t)RESET != flag_status){ return ERROR; } FWDGT_PSC = (uint32_t)prescaler_div; timeout = FWDGT_RLD_TIMEOUT; do{ flag_status = FWDGT_STAT & FWDGT_STAT_RUD; }while((--timeout > 0U) && ((uint32_t)RESET != flag_status)); if ((uint32_t)RESET != flag_status){ return ERROR; } FWDGT_RLD = RLD_RLD(reload_value); FWDGT_CTL = FWDGT_KEY_RELOAD; return SUCCESS; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */
void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins)
/* The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. */ void GPIOPinTypeADC(uint32_t ui32Port, uint8_t ui8Pins)
{ ASSERT(_GPIOBaseValid(ui32Port)); GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_IN); GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_ANALOG); }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Deinitializes the WWDG peripheral registers to their default reset values. */
void WWDG_DeInit(void)
/* Deinitializes the WWDG peripheral registers to their default reset values. */ void WWDG_DeInit(void)
{ RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* This function calls TIFFWriteDirectory on the output after blanking its output by replacing the read, write, and seek procedures with empty implementations, then it replaces the original implementations. */
void t2p_write_advance_directory(T2P *, TIFF *)
/* This function calls TIFFWriteDirectory on the output after blanking its output by replacing the read, write, and seek procedures with empty implementations, then it replaces the original implementations. */ void t2p_write_advance_directory(T2P *, TIFF *)
{ t2p_disable(output); if(!TIFFWriteDirectory(output)){ TIFFError(TIFF2PDF_MODULE, "Error writing virtual directory to output PDF %s", TIFFFileName(output)); t2p->t2p_error = T2P_ERR_ERROR; return; } t2p_enable(output); return; }
alibaba/AliOS-Things
C++
Apache License 2.0
4,536
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable SHA/MD5 interrupts on the interrupt controller. */
void SHAMD5IntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
/* If the application is using a static interrupt vector table stored in flash, then it is not necessary to register the interrupt handler this way. Instead, IntEnable() should be used to enable SHA/MD5 interrupts on the interrupt controller. */ void SHAMD5IntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
{ ASSERT(ui32Base == SHAMD5_BASE); IntRegister(INT_SHA0, pfnHandler); IntEnable(INT_SHA0); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */
void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
/* param base SPDIF base pointer. param handle Pointer to the spdif_handle_t structure which stores the transfer state. */ void SPDIF_TransferAbortSend(SPDIF_Type *base, spdif_handle_t *handle)
{ assert(handle != NULL); SPDIF_DisableInterrupts(base, kSPDIF_TxFIFOEmpty); handle->state = kSPDIF_Idle; (void)memset(handle->spdifQueue, 0, sizeof(spdif_transfer_t) * SPDIF_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
eclipse-threadx/getting-started
C++
Other
310
/* param base FlexCAN peripheral base address. param handle Pointer to flexcan_edma_handle_t structure. param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t. retval kStatus_Success if succeed, others failed. retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. */
status_t FLEXCAN_TransferReceiveFifoEDMA(CAN_Type *base, flexcan_edma_handle_t *handle, flexcan_fifo_transfer_t *pFifoXfer)
/* param base FlexCAN peripheral base address. param handle Pointer to flexcan_edma_handle_t structure. param pFifoXfer FlexCAN Rx FIFO EDMA transfer structure, see #flexcan_fifo_transfer_t. retval kStatus_Success if succeed, others failed. retval kStatus_FLEXCAN_RxFifoBusy Previous transfer ongoing. */ status_t FLEXCAN_TransferReceiveFifoEDMA(CAN_Type *base, flexcan_edma_handle_t *handle, flexcan_fifo_transfer_t *pFifoXfer)
{ assert(NULL != handle->rxFifoEdmaHandle); edma_transfer_config_t dmaXferConfig; status_t status; FLEXCAN_PrepareTransfConfiguration(base, pFifoXfer, &dmaXferConfig); status = FLEXCAN_StartTransferDatafromRxFIFO(base, handle, &dmaXferConfig); return status; }
eclipse-threadx/getting-started
C++
Other
310
/* Callback called when the pen is pressed on the touchscreen. */
static void event_handler(rtouch_event_t const *event)
/* Callback called when the pen is pressed on the touchscreen. */ static void event_handler(rtouch_event_t const *event)
{ switch(event->type) { case RTOUCH_MOVE: printf("Pen moved at (%03u, %03u)\n\r", (unsigned int) event->panel.x, (unsigned int) event->panel.y); break; case RTOUCH_PRESS: printf("Pen pressed at (%03u, %03u)\n\r", (unsigned int) event->panel.x, (unsigned int) event->panel.y); break; case RTOUCH_RELEASE: printf("Pen released at (%03u, %03u)\n\r", (unsigned int) event->panel.x, (unsigned int) event->panel.y); break; default: break; } }
remotemcu/remcu-chip-sdks
C++
null
436
/* Checks whether the last I2Cx Event is equal to the one passed as parameter. */
ErrorStatus I2C_CheckEvent(I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
/* Checks whether the last I2Cx Event is equal to the one passed as parameter. */ ErrorStatus I2C_CheckEvent(I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
{ uint32_t lastevent = 0; uint32_t flag1 = 0; ErrorStatus status = ERROR; assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_I2C_EVENT(I2C_EVENT)); if((I2C_EVENT == I2C_EVENT_RX_FULL)&&(I2C_CMD_DIR==0)) { I2C1->IC_DATA_CMD = CMD_READ; I2C_CMD_DIR = 1; } flag1 = I2Cx->IC_RAW_INTR_STAT; lastevent = (flag1 ) & I2C_EVENT; if (lastevent == I2C_EVENT ) { status = SUCCESS; } else { status = ERROR; } return status; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Converts a File device path structure to its string representative. */
VOID DevPathToTextFilePath(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
/* Converts a File device path structure to its string representative. */ VOID DevPathToTextFilePath(IN OUT POOL_PRINT *Str, IN VOID *DevPath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
{ FILEPATH_DEVICE_PATH *Fp; Fp = DevPath; UefiDevicePathLibCatPrint (Str, L"%s", Fp->PathName); }
tianocore/edk2
C++
Other
4,240
/* Initialized the list of the waiting receivers on the IPC channel. */
rt_inline rt_err_t rt_channel_object_init(struct rt_ipc_object *ipc)
/* Initialized the list of the waiting receivers on the IPC channel. */ rt_inline rt_err_t rt_channel_object_init(struct rt_ipc_object *ipc)
{ rt_list_init(&(ipc->suspend_thread)); return RT_EOK; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Waits until last write operation on RTC registers has finished. */
void RTC_WaitForLastTask(void)
/* Waits until last write operation on RTC registers has finished. */ void RTC_WaitForLastTask(void)
{ while (!(RTC->CSR & RTC_CSR_RTOFF)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the width in pixels of a string when it is rendered. This method can be used to determine whether a string will fit inside a specific area, or if it needs to be broken up into multiple lines to be properly rendered on the screen. */
uint16_t aafontsGetStringWidth(const aafontsFont_t *font, char *str)
/* Returns the width in pixels of a string when it is rendered. This method can be used to determine whether a string will fit inside a specific area, or if it needs to be broken up into multiple lines to be properly rendered on the screen. */ uint16_t aafontsGetStringWidth(const aafontsFont_t *font, char *str)
{ uint16_t width = 0; const aafontsCharInfo_t *charInfo; uint32_t currChar; for (currChar = *str; currChar; currChar = *(++str)) { if ((currChar > font->lastChar) || (currChar < font->firstChar)) { width += font->unknownCharWidth; } else { charInfo = &(font->charTable[currChar - font->firstChar]); width += charInfo->width; } } return width; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Enable Write Protect on pages marked as read-only. */
STATIC VOID EnableReadOnlyPageWriteProtect(VOID)
/* Enable Write Protect on pages marked as read-only. */ STATIC VOID EnableReadOnlyPageWriteProtect(VOID)
{ AsmWriteCr0 (AsmReadCr0 () | BIT16); }
tianocore/edk2
C++
Other
4,240
/* ZigBee Device Profile dissector for the permit joining */
void dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* ZigBee Device Profile dissector for the permit joining */ void dissect_zbee_zdp_req_mgmt_permit_join(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ guint offset = 0; zbee_parse_uint(tree, hf_zbee_zdp_duration, tvb, &offset, 1, NULL); zbee_parse_uint(tree, hf_zbee_zdp_significance, tvb, &offset, 1, NULL); zdp_dump_excess(tvb, offset, pinfo, tree); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Encodes the input as a byte string in a way that can be unambiguously parsed from the beginning of the string by inserting the length of the byte string before the byte string representation of input. */
UINTN EFIAPI LeftEncode(OUT UINT8 *EncBuf, IN UINTN Value)
/* Encodes the input as a byte string in a way that can be unambiguously parsed from the beginning of the string by inserting the length of the byte string before the byte string representation of input. */ UINTN EFIAPI LeftEncode(OUT UINT8 *EncBuf, IN UINTN Value)
{ UINT32 BlockNum; UINT32 EncLen; UINT32 Index; UINTN ValueCopy; for ( ValueCopy = Value, BlockNum = 0; ValueCopy && (BlockNum < sizeof (UINTN)); ++BlockNum, ValueCopy >>= 8 ) { } if (BlockNum == 0) { BlockNum = 1; } for (Index = 1; Index <= BlockNum; ++Index) { EncBuf[Index] = (UINT8)(Value >> (8 * (BlockNum - Index))); } EncBuf[0] = (UINT8)BlockNum; EncLen = BlockNum + 1; return EncLen; }
tianocore/edk2
C++
Other
4,240
/* SEP member function. Deletes an existing section stream */
EFI_STATUS EFIAPI CloseSectionStream(IN UINTN StreamHandleToClose, IN BOOLEAN FreeStreamBuffer)
/* SEP member function. Deletes an existing section stream */ EFI_STATUS EFIAPI CloseSectionStream(IN UINTN StreamHandleToClose, IN BOOLEAN FreeStreamBuffer)
{ CORE_SECTION_STREAM_NODE *StreamNode; EFI_TPL OldTpl; EFI_STATUS Status; LIST_ENTRY *Link; CORE_SECTION_CHILD_NODE *ChildNode; OldTpl = CoreRaiseTpl (TPL_NOTIFY); Status = FindStreamNode (StreamHandleToClose, &StreamNode); if (!EFI_ERROR (Status)) { RemoveEntryList (&StreamNode->Link); while (!IsListEmpty (&StreamNode->Children)) { Link = GetFirstNode (&StreamNode->Children); ChildNode = CHILD_SECTION_NODE_FROM_LINK (Link); FreeChildNode (ChildNode); } if (FreeStreamBuffer) { CoreFreePool (StreamNode->StreamBuffer); } CoreFreePool (StreamNode); Status = EFI_SUCCESS; } else { Status = EFI_INVALID_PARAMETER; } CoreRestoreTpl (OldTpl); return Status; }
tianocore/edk2
C++
Other
4,240
/* device_create_file - create sysfs attribute file for device. @dev: device. @attr: device attribute descriptor. */
int device_create_file(struct device *dev, const struct device_attribute *attr)
/* device_create_file - create sysfs attribute file for device. @dev: device. @attr: device attribute descriptor. */ int device_create_file(struct device *dev, const struct device_attribute *attr)
{ int error = 0; if (dev) error = sysfs_create_file(&dev->kobj, &attr->attr); return error; }
robutest/uclinux
C++
GPL-2.0
60
/* System Power Configuration. This code was created by CubeMX. */
static void SystemPower_Config(void)
/* System Power Configuration. This code was created by CubeMX. */ static void SystemPower_Config(void)
{ HAL_PWREx_DisableUCPDDeadBattery(); if (HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY) != HAL_OK) { while(1); } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Read specified Event port input data port pins. */
en_ep_state_t EP_ReadInputPins(uint8_t u8EventPort, uint16_t u16EventPin)
/* Read specified Event port input data port pins. */ en_ep_state_t EP_ReadInputPins(uint8_t u8EventPort, uint16_t u16EventPin)
{ DDL_ASSERT(IS_EVENT_PORT(u8EventPort)); DDL_ASSERT(IS_EVENT_PIN(u16EventPin)); return ((READ_REG32(PEVNTIDR_REG(u8EventPort)) & (u16EventPin)) != 0UL) ? EVT_PIN_SET : EVT_PIN_RESET; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enable SIR (IrDA) mode on the specified UART. */
void UARTEnableIrDA(unsigned long ulBase, xtBoolean bEnable)
/* Enable SIR (IrDA) mode on the specified UART. */ void UARTEnableIrDA(unsigned long ulBase, xtBoolean bEnable)
{ xASSERT(UARTBaseValid(ulBase)); if(bEnable) { xHWREG(ulBase + USART_IRCR) |= USART_IRCR_IRDA_EN; } else { xHWREG(ulBase + USART_IRCR) &= ~(USART_IRCR_IRDA_EN); } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* param base MCAN peripheral base address. param config The MCAN filter configuration. */
void MCAN_SetFilterConfig(CAN_Type *base, const mcan_frame_filter_config_t *config)
/* param base MCAN peripheral base address. param config The MCAN filter configuration. */ void MCAN_SetFilterConfig(CAN_Type *base, const mcan_frame_filter_config_t *config)
{ if (config->idFormat == kMCAN_FrameIDStandard) { base->GFC |= CAN_GFC_RRFS(config->remFrame) | CAN_GFC_ANFS(config->nmFrame); base->SIDFC |= CAN_SIDFC_FLSSA(config->address >> CAN_SIDFC_FLSSA_SHIFT) | CAN_SIDFC_LSS(config->listSize); } else { base->GFC |= CAN_GFC_RRFE(config->remFrame) | CAN_GFC_ANFE(config->nmFrame); base->XIDFC |= CAN_XIDFC_FLESA(config->address >> CAN_XIDFC_FLESA_SHIFT) | CAN_XIDFC_LSE(config->listSize); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Before PDC_SYSTEM_MAP was invented, the PDC_MEM_MAP call was used. To use it, we initialise the mod_path.bc to 0xff and try all values of mod to get the HPA for the top-level devices. Bus adapters may have sub-devices which are discovered by setting bc to 0 and bc to the module, then trying all possible functions. */
static void __init snake_inventory(void)
/* Before PDC_SYSTEM_MAP was invented, the PDC_MEM_MAP call was used. To use it, we initialise the mod_path.bc to 0xff and try all values of mod to get the HPA for the top-level devices. Bus adapters may have sub-devices which are discovered by setting bc to 0 and bc to the module, then trying all possible functions. */ static void __init snake_inventory(void)
{ int mod; for (mod = 0; mod < 16; mod++) { struct parisc_device *dev; struct pdc_module_path module_path; struct pdc_memory_map r_addr; unsigned int func; memset(module_path.path.bc, 0xff, 6); module_path.path.mod = mod; dev = legacy_create_device(&r_addr, &module_path); if ((!dev) || (dev->id.hw_type != HPHW_BA)) continue; memset(module_path.path.bc, 0xff, 4); module_path.path.bc[4] = mod; for (func = 0; func < 16; func++) { module_path.path.bc[5] = 0; module_path.path.mod = func; legacy_create_device(&r_addr, &module_path); } } }
EmcraftSystems/linux-emcraft
C++
Other
266
/* must be called with the lock held and interrupts disabled. */
static void enable_common_interrupts(struct xircom_private *card)
/* must be called with the lock held and interrupts disabled. */ static void enable_common_interrupts(struct xircom_private *card)
{ unsigned int val; enter("enable_link_interrupt"); val = inl(card->io_port + CSR7); val |= (1<<16); val |= (1<<15); val |= (1<<13); val |= (1<<8); val |= (1<<7); val |= (1<<5); val |= (1<<2); val |= (1<<1); outl(val, card->io_port + CSR7); leave("enable_link_interrupt"); }
robutest/uclinux
C++
GPL-2.0
60
/* Set DMA source address used by a HDMA channel. */
void DMA_SetSourceAddr(unsigned char channel, unsigned int address)
/* Set DMA source address used by a HDMA channel. */ void DMA_SetSourceAddr(unsigned char channel, unsigned int address)
{ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist"); AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_SADDR = address; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* This will stop the SysTick counter. If an interrupt handler has been registered, it will no longer be called until SysTick is restarted. */
void SysTickDisable(void)
/* This will stop the SysTick counter. If an interrupt handler has been registered, it will no longer be called until SysTick is restarted. */ void SysTickDisable(void)
{ HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE); }
watterott/WebRadio
C++
null
71
/* Enable/disable the FIFO mode of the specified SPI port. The */
void SPIFIFOModeSet(unsigned long ulBase, xtBoolean xtEnable, unsigned long ulInterval)
/* Enable/disable the FIFO mode of the specified SPI port. The */ void SPIFIFOModeSet(unsigned long ulBase, xtBoolean xtEnable, unsigned long ulInterval)
{ xASSERT((ulBase == SPI0_BASE) || (ulBase == SPI1_BASE)|| (ulBase == SPI2_BASE) || (ulBase == SPI3_BASE)); xASSERT((ulInterval == 0) ||((ulInterval >= 2) && (ulInterval <= 15))); if (xtEnable) { xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_SP_CYCLE_M; xHWREG(ulBase + SPI_CNTRL) |= (ulInterval << SPI_CNTRL_SP_CYCLE_S); xHWREG(ulBase + SPI_CNTRL) |= SPI_CNTRL_FIFO; } else { xHWREG(ulBase + SPI_CNTRL) &= ~SPI_CNTRL_FIFO; } }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened. */
void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
/* Called during the final close of a tty/pty pair in order to shut down the line discpline layer. On exit the ldisc assigned is N_TTY and the ldisc has not been opened. */ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
{ tty_ldisc_halt(tty); flush_scheduled_work(); mutex_lock(&tty->ldisc_mutex); tty_ldisc_close(tty, tty->ldisc); tty_ldisc_put(tty->ldisc); tty->ldisc = NULL; tty_set_termios_ldisc(tty, N_TTY); mutex_unlock(&tty->ldisc_mutex); if (o_tty) tty_ldisc_release(o_tty, NULL); }
robutest/uclinux
C++
GPL-2.0
60
/* Change a Unicode string to an ASCII string. */
UINTN UnicodeToAscii(IN CONST CHAR16 *UStr, IN CONST UINTN Length, OUT CHAR8 *AStr)
/* Change a Unicode string to an ASCII string. */ UINTN UnicodeToAscii(IN CONST CHAR16 *UStr, IN CONST UINTN Length, OUT CHAR8 *AStr)
{ UINTN Index; for (Index = 0; Index < Length; Index++) { *AStr++ = (CHAR8)*UStr++; } return Index; }
tianocore/edk2
C++
Other
4,240
/* Executes "full continuation" (everything in the stack) of a previously interrupted coroutine until the stack is empty (or another interruption long-jumps out of the loop). If the coroutine is recovering from an error, 'ud' points to the error status, which must be passed to the first continuation function (otherwise the default status is LUA_YIELD). */
static void unroll(lua_State *L, void *ud)
/* Executes "full continuation" (everything in the stack) of a previously interrupted coroutine until the stack is empty (or another interruption long-jumps out of the loop). If the coroutine is recovering from an error, 'ud' points to the error status, which must be passed to the first continuation function (otherwise the default status is LUA_YIELD). */ static void unroll(lua_State *L, void *ud)
{ if (!isLua(L->ci)) finishCcall(L, LUA_YIELD); else { luaV_finishOp(L); luaV_execute(L); } } }
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Enables Hash or Perfect filter (only if Hash filter is enabled in H/W). Only frames matching either perfect filtering or Hash Filtering as per HMC and HUC configuration are sent to application. */
void synopGMAC_hash_perfect_filter_enable(synopGMACdevice *gmacdev)
/* Enables Hash or Perfect filter (only if Hash filter is enabled in H/W). Only frames matching either perfect filtering or Hash Filtering as per HMC and HUC configuration are sent to application. */ void synopGMAC_hash_perfect_filter_enable(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev->MacBase, GmacFrameFilter, GmacHashPerfectFilter); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Opens an endpoint of the low level driver. */
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
/* Opens an endpoint of the low level driver. */ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
{ HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); switch (hal_status) { case HAL_OK : usb_status = USBD_OK; break; case HAL_ERROR : usb_status = USBD_FAIL; break; case HAL_BUSY : usb_status = USBD_BUSY; break; case HAL_TIMEOUT : usb_status = USBD_FAIL; break; default : usb_status = USBD_FAIL; break; } return usb_status; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Return: 0 if the determination succeeded, -ve on error */
static int cfg_main_link_max(struct udevice *dev)
/* Return: 0 if the determination succeeded, -ve on error */ static int cfg_main_link_max(struct udevice *dev)
{ struct dp_tx *dp_tx = dev_get_priv(dev); int status; if (!is_connected(dev)) return -ENODEV; status = set_link_rate(dev, dp_tx->link_config.max_link_rate); if (status) return status; status = set_lane_count(dev, dp_tx->link_config.max_lane_count); if (status) return status; return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Driver poll routine. This routine polls the boards in use and passes messages back up to host when necessary. This is actually very CPU efficient, since we will always have the kernel poll clock, it adds only a few cycles when idle (since board service can be determined very easily), but when loaded generates no interrupts (with their expensive associated context change). */
static void stli_poll(unsigned long arg)
/* Driver poll routine. This routine polls the boards in use and passes messages back up to host when necessary. This is actually very CPU efficient, since we will always have the kernel poll clock, it adds only a few cycles when idle (since board service can be determined very easily), but when loaded generates no interrupts (with their expensive associated context change). */ static void stli_poll(unsigned long arg)
{ cdkhdr_t __iomem *hdrp; struct stlibrd *brdp; unsigned int brdnr; mod_timer(&stli_timerlist, STLI_TIMEOUT); for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { brdp = stli_brds[brdnr]; if (brdp == NULL) continue; if ((brdp->state & BST_STARTED) == 0) continue; spin_lock(&brd_lock); EBRDENABLE(brdp); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); if (readb(&hdrp->hostreq)) stli_brdpoll(brdp, hdrp); EBRDDISABLE(brdp); spin_unlock(&brd_lock); } }
robutest/uclinux
C++
GPL-2.0
60
/* Walk the list of under-writeback pages of the given address space and wait for all of them. */
int filemap_fdatawait(struct address_space *mapping)
/* Walk the list of under-writeback pages of the given address space and wait for all of them. */ int filemap_fdatawait(struct address_space *mapping)
{ loff_t i_size = i_size_read(mapping->host); if (i_size == 0) return 0; return filemap_fdatawait_range(mapping, 0, i_size - 1); }
robutest/uclinux
C++
GPL-2.0
60
/* BMA020 ioctl control entry point. Support and FAQ: visit */
static bool bma020_ioctl(sensor_t *sensor, sensor_command_t cmd, void *arg)
/* BMA020 ioctl control entry point. Support and FAQ: visit */ static bool bma020_ioctl(sensor_t *sensor, sensor_command_t cmd, void *arg)
{ sensor_hal_t *const hal = sensor->hal; sensor_data_t sample = {.scaled = true}; switch (cmd) { case SENSOR_SET_RANGE: return bma020_set_range(hal, *((uint16_t *)arg)); case SENSOR_SET_BANDWIDTH: return bma020_set_bandwidth(hal, *((uint16_t *)arg)); case SENSOR_READ_VECTOR: if (bma020_get_accel(hal, &sample)) { vector3_t *const pvec = (vector3_t *)arg; pvec->x = sample.axis.x; pvec->y = sample.axis.y; pvec->z = sample.axis.z; return true; } else { return false; } default: sensor->err = SENSOR_ERR_UNSUPPORTED; return false; } }
memfault/zero-to-main
C++
null
200
/* Take a look at the first request on the ccw queue and check if it needs to be started. */
static void __dasd_device_start_head(struct dasd_device *device)
/* Take a look at the first request on the ccw queue and check if it needs to be started. */ static void __dasd_device_start_head(struct dasd_device *device)
{ struct dasd_ccw_req *cqr; int rc; if (list_empty(&device->ccw_queue)) return; cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); if (cqr->status != DASD_CQR_QUEUED) return; if (device->stopped) { cqr->status = DASD_CQR_CLEARED; dasd_schedule_device_bh(device); return; } rc = device->discipline->start_IO(cqr); if (rc == 0) dasd_device_set_timer(device, cqr->expires); else if (rc == -EACCES) { dasd_schedule_device_bh(device); } else dasd_device_set_timer(device, 50); }
robutest/uclinux
C++
GPL-2.0
60
/* I2C Set the Rise Time. Set the maximum rise time on the bus according to the I2C specification, as 1 more than the specified rise time in peripheral clock cycles. This is a 6 bit number. */
void i2c_set_trise(uint32_t i2c, uint16_t trise)
/* I2C Set the Rise Time. Set the maximum rise time on the bus according to the I2C specification, as 1 more than the specified rise time in peripheral clock cycles. This is a 6 bit number. */ void i2c_set_trise(uint32_t i2c, uint16_t trise)
{ I2C_TRISE(i2c) = trise; }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Build a indentation string for a given indentation level. XXX this should be really in util.c */
static char* indent_string(u_int indent)
/* Build a indentation string for a given indentation level. XXX this should be really in util.c */ static char* indent_string(u_int indent)
{ static char buf[20]; u_int idx; idx = 0; buf[idx] = '\0'; if (sizeof(buf) < ((indent/8) + (indent %8) + 2)) { return buf; } buf[idx] = '\n'; idx++; while (indent >= 8) { buf[idx] = '\t'; idx++; indent -= 8; } while (indent > 0) { buf[idx] = ' '; idx++; indent--; } buf[idx] = '\0'; return buf; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Allocate a memory block from the socket's option memory buffer. */
void* sock_kmalloc(struct sock *sk, int size, gfp_t priority)
/* Allocate a memory block from the socket's option memory buffer. */ void* sock_kmalloc(struct sock *sk, int size, gfp_t priority)
{ if ((unsigned)size <= sysctl_optmem_max && atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { void *mem; atomic_add(size, &sk->sk_omem_alloc); mem = kmalloc(size, priority); if (mem) return mem; atomic_sub(size, &sk->sk_omem_alloc); } return NULL; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Worker function that prints an EFI_GUID into specified Buffer. */
UINTN GuidToString(IN EFI_GUID *Guid, IN CHAR16 *Buffer, IN UINTN BufferSize)
/* Worker function that prints an EFI_GUID into specified Buffer. */ UINTN GuidToString(IN EFI_GUID *Guid, IN CHAR16 *Buffer, IN UINTN BufferSize)
{ UINTN Size; Size = UnicodeSPrint ( Buffer, BufferSize, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", (UINTN)Guid->Data1, (UINTN)Guid->Data2, (UINTN)Guid->Data3, (UINTN)Guid->Data4[0], (UINTN)Guid->Data4[1], (UINTN)Guid->Data4[2], (UINTN)Guid->Data4[3], (UINTN)Guid->Data4[4], (UINTN)Guid->Data4[5], (UINTN)Guid->Data4[6], (UINTN)Guid->Data4[7] ); return Size - 1; }
tianocore/edk2
C++
Other
4,240
/* Always use USER_MAP. These functions are used by the keyboard, which shouldn't be affected by G0/G1 switching, etc. If the user map still contains default values, i.e. the direct-to-font mapping, then assume user is using Latin1. */
u32 conv_8bit_to_uni(unsigned char c)
/* Always use USER_MAP. These functions are used by the keyboard, which shouldn't be affected by G0/G1 switching, etc. If the user map still contains default values, i.e. the direct-to-font mapping, then assume user is using Latin1. */ u32 conv_8bit_to_uni(unsigned char c)
{ unsigned short uni = translations[USER_MAP][c]; return uni == (0xf000 | c) ? c : uni; }
robutest/uclinux
C++
GPL-2.0
60
/* Spaceball 4000 FLX packets all start with a one letter packet-type decriptor, and end in 0x0d. It uses '^' as an escape for CR, XOFF and XON characters which can occur in the axis values. */
static irqreturn_t spaceball_interrupt(struct serio *serio, unsigned char data, unsigned int flags)
/* Spaceball 4000 FLX packets all start with a one letter packet-type decriptor, and end in 0x0d. It uses '^' as an escape for CR, XOFF and XON characters which can occur in the axis values. */ static irqreturn_t spaceball_interrupt(struct serio *serio, unsigned char data, unsigned int flags)
{ struct spaceball *spaceball = serio_get_drvdata(serio); switch (data) { case 0xd: spaceball_process_packet(spaceball); spaceball->idx = 0; spaceball->escape = 0; break; case '^': if (!spaceball->escape) { spaceball->escape = 1; break; } spaceball->escape = 0; case 'M': case 'Q': case 'S': if (spaceball->escape) { spaceball->escape = 0; data &= 0x1f; } default: if (spaceball->escape) spaceball->escape = 0; if (spaceball->idx < SPACEBALL_MAX_LENGTH) spaceball->data[spaceball->idx++] = data; break; } return IRQ_HANDLED; }
robutest/uclinux
C++
GPL-2.0
60
/* get peripheral clock 2 ( LCD, SD, SPI ) */
static unsigned long perclk2_get_rate(struct clk *clk)
/* get peripheral clock 2 ( LCD, SD, SPI ) */ static unsigned long perclk2_get_rate(struct clk *clk)
{ return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) & CCM_PCDR_PCLK2_MASK) >> CCM_PCDR_PCLK2_OFFSET) + 1); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Unregisters the interrupt handler in the system interrupt controller. The interrupt is disabled at the global level, and the interrupt handler will no longer be called. */
void HibernateIntUnregister(void)
/* Unregisters the interrupt handler in the system interrupt controller. The interrupt is disabled at the global level, and the interrupt handler will no longer be called. */ void HibernateIntUnregister(void)
{ IntDisable(INT_HIBERNATE); IntUnregister(INT_HIBERNATE); }
watterott/WebRadio
C++
null
71
/* Check to see if any future RCU-related work will need to be done by the current CPU, even if none need be done immediately, returning 1 if so. This function is part of the RCU implementation; it is -not- an exported member of the RCU API. */
int rcu_needs_cpu(int cpu)
/* Check to see if any future RCU-related work will need to be done by the current CPU, even if none need be done immediately, returning 1 if so. This function is part of the RCU implementation; it is -not- an exported member of the RCU API. */ int rcu_needs_cpu(int cpu)
{ return per_cpu(rcu_sched_data, cpu).nxtlist || per_cpu(rcu_bh_data, cpu).nxtlist || rcu_preempt_needs_cpu(cpu); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Decode signed LEB128 data. The algorithm is taken from Appendix C of the DWARF 3 spec. Return the number of bytes read. */
static unsigned long dwarf_read_leb128(char *addr, int *ret)
/* Decode signed LEB128 data. The algorithm is taken from Appendix C of the DWARF 3 spec. Return the number of bytes read. */ static unsigned long dwarf_read_leb128(char *addr, int *ret)
{ unsigned char byte; int result, shift; int num_bits; int count; result = 0; shift = 0; count = 0; while (1) { byte = __raw_readb(addr); addr++; result |= (byte & 0x7f) << shift; shift += 7; count++; if (!(byte & 0x80)) break; } num_bits = 8 * sizeof(result); if ((shift < num_bits) && (byte & 0x40)) result |= (-1 << shift); *ret = result; return count; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* USBH_LL_Init Initialize the Low Level portion of the Host driver. */
USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
/* USBH_LL_Init Initialize the Low Level portion of the Host driver. */ USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
{ hhcd.Instance = USB_OTG_FS; hhcd.Init.Host_channels = 11; hhcd.Init.dma_enable = 0; hhcd.Init.low_power_enable = 0; hhcd.Init.phy_itface = HCD_PHY_EMBEDDED; hhcd.Init.Sof_enable = 0; hhcd.Init.speed = HCD_SPEED_FULL; hhcd.Init.vbus_sensing_enable = 0; hhcd.Init.lpm_enable = 0; hhcd.pData = phost; phost->pData = &hhcd; HAL_HCD_Init(&hhcd); USBH_LL_SetTimer (phost, HAL_HCD_GetCurrentFrame(&hhcd)); return USBH_OK; }
STMicroelectronics/STM32CubeF4
C++
Other
789
/* Saves at boot time configured settings for any netdevice. */
int __init netdev_boot_setup(char *str)
/* Saves at boot time configured settings for any netdevice. */ int __init netdev_boot_setup(char *str)
{ int ints[5]; struct ifmap map; str = get_options(str, ARRAY_SIZE(ints), ints); if (!str || !*str) return 0; memset(&map, 0, sizeof(map)); if (ints[0] > 0) map.irq = ints[1]; if (ints[0] > 1) map.base_addr = ints[2]; if (ints[0] > 2) map.mem_start = ints[3]; if (ints[0] > 3) map.mem_end = ints[4]; return netdev_boot_setup_add(str, &map); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* See mss_uart.h for details of how to use this function. */
void MSS_UART_irq_tx(mss_uart_instance_t *this_uart, const uint8_t *pbuff, uint32_t tx_size)
/* See mss_uart.h for details of how to use this function. */ void MSS_UART_irq_tx(mss_uart_instance_t *this_uart, const uint8_t *pbuff, uint32_t tx_size)
{ ASSERT((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1)); ASSERT(pbuff != ((uint8_t *)0)); ASSERT(tx_size > 0u); if((tx_size > 0u) && ( pbuff != ((uint8_t *)0)) && ((this_uart == &g_mss_uart0) || (this_uart == &g_mss_uart1))) { this_uart->tx_buffer = pbuff; this_uart->tx_buff_size = tx_size; this_uart->tx_idx = (uint16_t)0; NVIC_ClearPendingIRQ(this_uart->irqn); this_uart->tx_handler = default_tx_handler; set_bit_reg8(&this_uart->hw_reg->IER,ETBEI); NVIC_EnableIRQ(this_uart->irqn); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* A transport listener is added by writing it's transport name and a port number. */
static ssize_t __write_ports_addxprt(char *buf)
/* A transport listener is added by writing it's transport name and a port number. */ static ssize_t __write_ports_addxprt(char *buf)
{ char transport[16]; int port, err; if (sscanf(buf, "%15s %4u", transport, &port) != 2) return -EINVAL; if (port < 1 || port > USHORT_MAX) return -EINVAL; err = nfsd_create_serv(); if (err != 0) return err; err = svc_create_xprt(nfsd_serv, transport, PF_INET, port, SVC_SOCK_ANONYMOUS); if (err < 0) { if (err == -ENOENT) err = -EPROTONOSUPPORT; return err; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Generate better values after random number generator is fully initalized. */
static int __init random32_reseed(void)
/* Generate better values after random number generator is fully initalized. */ static int __init random32_reseed(void)
{ int i; for_each_possible_cpu(i) { struct rnd_state *state = &per_cpu(net_rand_state,i); u32 seeds[3]; get_random_bytes(&seeds, sizeof(seeds)); state->s1 = __seed(seeds[0], 1); state->s2 = __seed(seeds[1], 7); state->s3 = __seed(seeds[2], 15); __random32(state); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Make the device online and schedule the bottom half to start the requeueing of requests from the linux request queue to the ccw queue. */
static int dasd_state_ready_to_online(struct dasd_device *device)
/* Make the device online and schedule the bottom half to start the requeueing of requests from the linux request queue to the ccw queue. */ static int dasd_state_ready_to_online(struct dasd_device *device)
{ int rc; struct gendisk *disk; struct disk_part_iter piter; struct hd_struct *part; if (device->discipline->ready_to_online) { rc = device->discipline->ready_to_online(device); if (rc) return rc; } device->state = DASD_STATE_ONLINE; if (device->block) { dasd_schedule_block_bh(device->block); disk = device->block->bdev->bd_disk; disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); while ((part = disk_part_iter_next(&piter))) kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); disk_part_iter_exit(&piter); } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Additional information is returned in the info pointer, providing that APM 1.2 is in use. If no messges are pending the value 0x80 is returned (No power management events pending). */
static int apm_get_event(apm_event_t *event, apm_eventinfo_t *info)
/* Additional information is returned in the info pointer, providing that APM 1.2 is in use. If no messges are pending the value 0x80 is returned (No power management events pending). */ static int apm_get_event(apm_event_t *event, apm_eventinfo_t *info)
{ struct apm_bios_call call; call.func = APM_FUNC_GET_EVENT; call.ebx = call.ecx = 0; if (apm_bios_call(&call)) return call.err; *event = call.ebx; if (apm_info.connection_version < 0x0102) *info = ~0; else *info = call.ecx; return APM_SUCCESS; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Code arithmetic operators ('+', '-', ...). If second operand is a constant in the proper range, use variant opcodes with K operands. */
static void codearith(FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2, int flip, int line)
/* Code arithmetic operators ('+', '-', ...). If second operand is a constant in the proper range, use variant opcodes with K operands. */ static void codearith(FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2, int flip, int line)
{ TMS event = cast(TMS, opr + TM_ADD); if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) { int v2 = e2->u.info; OpCode op = cast(OpCode, opr + OP_ADDK); finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); } else { OpCode op = cast(OpCode, opr + OP_ADD); if (flip) swapexps(e1, e2); codebinexpval(fs, op, e1, e2, line); } }
Nicholas3388/LuaNode
C++
Other
1,055
/* This function is called to increment a global variable "lib_tick" used as application time base. */
__weak void ald_inc_tick(void)
/* This function is called to increment a global variable "lib_tick" used as application time base. */ __weak void ald_inc_tick(void)
{ ++lib_tick; ald_systick_irq_cbk(); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* simple_strtoull - convert a string to an unsigned long long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */
unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
/* simple_strtoull - convert a string to an unsigned long long @cp: The start of the string @endp: A pointer to the end of the parsed string will be placed here @base: The number base to use */ unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
{ unsigned long long result = 0; if (!base) base = simple_guess_base(cp); if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') cp += 2; while (isxdigit(*cp)) { unsigned int value; value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; if (value >= base) break; result = result * base + value; cp++; } if (endp) *endp = (char *)cp; return result; }
robutest/uclinux
C++
GPL-2.0
60
/* This function returns zero in case of success and a negative error code in case of failure. */
static int replay_buds(struct ubifs_info *c)
/* This function returns zero in case of success and a negative error code in case of failure. */ static int replay_buds(struct ubifs_info *c)
{ struct bud_entry *b; int err; unsigned long long prev_sqnum = 0; list_for_each_entry(b, &c->replay_buds, list) { err = replay_bud(c, b); if (err) return err; ubifs_assert(b->sqnum > prev_sqnum); prev_sqnum = b->sqnum; } return 0; }
4ms/stm32mp1-baremetal
C++
Other
137
/* Handles an incoming ATT error response for the specified discover-all-services proc. */
static void ble_gattc_disc_all_svcs_err(struct ble_gattc_proc *proc, int status, uint16_t att_handle)
/* Handles an incoming ATT error response for the specified discover-all-services proc. */ static void ble_gattc_disc_all_svcs_err(struct ble_gattc_proc *proc, int status, uint16_t att_handle)
{ ble_gattc_dbg_assert_proc_not_inserted(proc); if (status == BLE_HS_ATT_ERR(BLE_ATT_ERR_ATTR_NOT_FOUND)) { status = BLE_HS_EDONE; } ble_gattc_disc_all_svcs_cb(proc, status, att_handle, NULL); }
Nicholas3388/LuaNode
C++
Other
1,055
/* helper functions to deal with 32 or 64bit block numbers. */
size_t journal_tag_bytes(journal_t *journal)
/* helper functions to deal with 32 or 64bit block numbers. */ size_t journal_tag_bytes(journal_t *journal)
{ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) return JBD2_TAG_SIZE64; else return JBD2_TAG_SIZE32; }
robutest/uclinux
C++
GPL-2.0
60
/* Search the bits provided for the next set bit after the value provided, and reset the calendar. */
static unsigned int find_prev(uint8_t *bits, unsigned int max, unsigned int value, struct tm *calendar, unsigned int field, unsigned int nextField, int *lower_orders, int *res_out)
/* Search the bits provided for the next set bit after the value provided, and reset the calendar. */ static unsigned int find_prev(uint8_t *bits, unsigned int max, unsigned int value, struct tm *calendar, unsigned int field, unsigned int nextField, int *lower_orders, int *res_out)
{ err = add_to_field(calendar, nextField, -1); if (err) goto return_error; err = reset_max(calendar, field); if (err) goto return_error; notfound = 0; next_value = prev_set_bit(bits, max - 1, value, &notfound); } if (notfound || next_value != value) { err = set_field(calendar, field, next_value); if (err) goto return_error; err = reset_all_max(calendar, lower_orders); if (err) goto return_error; } return next_value; return_error: *res_out = 1; return 0; }
arendst/Tasmota
C++
GNU General Public License v3.0
21,318
/* create_flat_tables() parses the env- and arg-strings in new user memory and creates the pointer tables from them, and puts their addresses on the "stack", returning the new stack pointer value. */
static abi_ulong copy_strings(abi_ulong p, int n, char **s)
/* create_flat_tables() parses the env- and arg-strings in new user memory and creates the pointer tables from them, and puts their addresses on the "stack", returning the new stack pointer value. */ static abi_ulong copy_strings(abi_ulong p, int n, char **s)
{ int len; while (n-- > 0) { len = strlen(s[n]) + 1; p -= len; memcpy_to_target(p, s[n], len); } return p; }
ve3wwg/teensy3_qemu
C++
Other
15
/* Threshold for wakeup: 1 LSB weight depends on WAKE_THS_W in WAKE_UP_DUR.. */
int32_t lsm6dso_wkup_threshold_get(stmdev_ctx_t *ctx, uint8_t *val)
/* Threshold for wakeup: 1 LSB weight depends on WAKE_THS_W in WAKE_UP_DUR.. */ int32_t lsm6dso_wkup_threshold_get(stmdev_ctx_t *ctx, uint8_t *val)
{ lsm6dso_wake_up_ths_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_WAKE_UP_THS, (uint8_t *)&reg, 1); *val = reg.wk_ths; return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). */
void RTC_ConfigCalibOutput(uint32_t RTC_CalibOutput)
/* Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). */ void RTC_ConfigCalibOutput(uint32_t RTC_CalibOutput)
{ assert_param(IS_RTC_CALIB_OUTPUT(RTC_CalibOutput)); RTC->WRP = 0xCA; RTC->WRP = 0x53; RTC->CTRL &= (uint32_t) ~(RTC_CTRL_CALOSEL); RTC->CTRL |= (uint32_t)RTC_CalibOutput; RTC->WRP = 0xFF; }
pikasTech/PikaPython
C++
MIT License
1,403
/* Enables or disables the specified ADC DMA request. */
void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState)
/* Enables or disables the specified ADC DMA request. */ void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState)
{ assert_param(IS_ADC_DMA_PERIPH(ADCx)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { ADCx->ADCR |= ADCR_DMA_Set; } else { ADCx->ADCR &= ADCR_DMA_Reset; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Set all the fields in a bmap extent record from the uncompressed form. */
void xfs_bmbt_set_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s)
/* Set all the fields in a bmap extent record from the uncompressed form. */ void xfs_bmbt_set_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s)
{ xfs_bmbt_set_allf(r, s->br_startoff, s->br_startblock, s->br_blockcount, s->br_state); }
robutest/uclinux
C++
GPL-2.0
60
/* Get the BPQ device for the ethernet device */
static struct net_device* bpq_get_ax25_dev(struct net_device *dev)
/* Get the BPQ device for the ethernet device */ static struct net_device* bpq_get_ax25_dev(struct net_device *dev)
{ struct bpqdev *bpq; list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list) { if (bpq->ethdev == dev) return bpq->axdev; } return NULL; }
robutest/uclinux
C++
GPL-2.0
60
/* Set if the TD is active and can be executed. */
VOID SetTDStatusActiveorInactive(IN TD_STRUCT *PtrTDStruct, IN BOOLEAN IsActive)
/* Set if the TD is active and can be executed. */ VOID SetTDStatusActiveorInactive(IN TD_STRUCT *PtrTDStruct, IN BOOLEAN IsActive)
{ if (IsActive) { PtrTDStruct->TDData.TDStatus |= 0x80; } else { PtrTDStruct->TDData.TDStatus &= 0x7F; } }
tianocore/edk2
C++
Other
4,240
/* Determines if the power manager's early wakeup expired during the last ISR and it was the only timer to expire in that period. */
bool sl_sleeptimer_is_power_manager_early_restore_timer_latest_to_expire(void)
/* Determines if the power manager's early wakeup expired during the last ISR and it was the only timer to expire in that period. */ bool sl_sleeptimer_is_power_manager_early_restore_timer_latest_to_expire(void)
{ CORE_DECLARE_IRQ_STATE; bool sleep; CORE_ENTER_ATOMIC(); sleep = sleep_on_isr_exit; sleep_on_isr_exit = false; CORE_EXIT_ATOMIC(); return sleep; }
eclipse-threadx/getting-started
C++
Other
310
/* Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent NumOfBits of bits from source. Returns NumOfBits of bits that are popped out. */
STATIC UINT32 GetBits(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
/* Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent NumOfBits of bits from source. Returns NumOfBits of bits that are popped out. */ STATIC UINT32 GetBits(IN SCRATCH_DATA *Sd, IN UINT16 NumOfBits)
{ UINT32 OutBits; OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits)); FillBuf (Sd, NumOfBits); return OutBits; }
tianocore/edk2
C++
Other
4,240
/* Sets a low output level on one or more pin(s) (if configured as output(s)). */
void PIO_Clear(const Pin *pin)
/* Sets a low output level on one or more pin(s) (if configured as output(s)). */ void PIO_Clear(const Pin *pin)
{ WRITE(pin->pio, PIO_CODR, pin->mask); }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Integer division; return 'm // n', that is, floor(m/n). C division truncates its result (rounds towards zero). 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, otherwise 'floor(q) == trunc(q) - 1'. */
lua_Integer luaV_idiv(lua_State *L, lua_Integer m, lua_Integer n)
/* Integer division; return 'm // n', that is, floor(m/n). C division truncates its result (rounds towards zero). 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, otherwise 'floor(q) == trunc(q) - 1'. */ lua_Integer luaV_idiv(lua_State *L, lua_Integer m, lua_Integer n)
{ if (n == 0) luaG_runerror(L, "attempt to divide by zero"); return intop(-, 0, m); } else { lua_Integer q = m / n; if ((m ^ n) < 0 && m % n != 0) q -= 1; return q; } }
Nicholas3388/LuaNode
C++
Other
1,055
/* Iterate through the list of strings in the Context, and check whether at least one string is matching the "compatible" property of the node. */
BOOLEAN EFIAPI FdtNodeIsCompatible(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *CompatInfo)
/* Iterate through the list of strings in the Context, and check whether at least one string is matching the "compatible" property of the node. */ BOOLEAN EFIAPI FdtNodeIsCompatible(IN CONST VOID *Fdt, IN INT32 Node, IN CONST VOID *CompatInfo)
{ UINT32 Index; CONST COMPATIBILITY_STR *CompatibleTable; UINT32 Count; CONST VOID *Prop; INT32 PropLen; if ((Fdt == NULL) || (CompatInfo == NULL)) { ASSERT (0); return FALSE; } Count = ((COMPATIBILITY_INFO *)CompatInfo)->Count; CompatibleTable = ((COMPATIBILITY_INFO *)CompatInfo)->CompatTable; Prop = fdt_getprop (Fdt, Node, "compatible", &PropLen); if ((Prop == NULL) || (PropLen < 0)) { return FALSE; } for (Index = 0; Index < Count; Index++) { if (fdt_stringlist_contains ( Prop, PropLen, CompatibleTable[Index].CompatStr )) { return TRUE; } } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Sort an associated group of pins according to their sequence numbers. */
static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, int num_pins)
/* Sort an associated group of pins according to their sequence numbers. */ static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, int num_pins)
{ int i, j; short seq; hda_nid_t nid; for (i = 0; i < num_pins; i++) { for (j = i + 1; j < num_pins; j++) { if (sequences[i] > sequences[j]) { seq = sequences[i]; sequences[i] = sequences[j]; sequences[j] = seq; nid = pins[i]; pins[i] = pins[j]; pins[j] = nid; } } } }
robutest/uclinux
C++
GPL-2.0
60
/* Stop any current commands to the EEPROM and clear the EEPROM request bit, then release the semaphores acquired. */
static void igb_release_nvm_82575(struct e1000_hw *)
/* Stop any current commands to the EEPROM and clear the EEPROM request bit, then release the semaphores acquired. */ static void igb_release_nvm_82575(struct e1000_hw *)
{ igb_release_nvm(hw); igb_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM); }
robutest/uclinux
C++
GPL-2.0
60
/* USBH_SetAddress This command sets the address to the connected device. */
USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost, uint8_t DeviceAddress)
/* USBH_SetAddress This command sets the address to the connected device. */ USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost, uint8_t DeviceAddress)
{ if(phost->RequestState == CMD_SEND) { phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_DEVICE | \ USB_REQ_TYPE_STANDARD; phost->Control.setup.b.bRequest = USB_REQ_SET_ADDRESS; phost->Control.setup.b.wValue.w = (uint16_t)DeviceAddress; phost->Control.setup.b.wIndex.w = 0; phost->Control.setup.b.wLength.w = 0; } return USBH_CtlReq(phost, 0 , 0 ); }
labapart/polymcu
C++
null
201
/* Write Data to TXD register to be sent. Writes one byte into transmission buffer. This API is only available if I2C_MODE_LEGACY is activated. */
void i2c_send_data(uint32_t i2c, uint8_t data)
/* Write Data to TXD register to be sent. Writes one byte into transmission buffer. This API is only available if I2C_MODE_LEGACY is activated. */ void i2c_send_data(uint32_t i2c, uint8_t data)
{ I2C_TXD(i2c) = data; }
libopencm3/libopencm3
C++
GNU General Public License v3.0
2,931
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 section Figure 3-7 for details. */
EFI_STATUS SdPeimSwitchBusWidth(IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 section Figure 3-7 for details. */ EFI_STATUS SdPeimSwitchBusWidth(IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
{ EFI_STATUS Status; UINT32 DevStatus; Status = SdPeimSetBusWidth (Slot, Rca, BusWidth); if (EFI_ERROR (Status)) { return Status; } Status = SdPeimSendStatus (Slot, Rca, &DevStatus); if (EFI_ERROR (Status)) { return Status; } if ((DevStatus >> 16) != 0) { return EFI_DEVICE_ERROR; } Status = SdPeimHcSetBusWidth (Slot->SdHcBase, BusWidth); return Status; }
tianocore/edk2
C++
Other
4,240
/* Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
static esp_err_t esp_eddystone_uid_received(const uint8_t *buf, uint8_t len, esp_eddystone_result_t *res)
/* Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ static esp_err_t esp_eddystone_uid_received(const uint8_t *buf, uint8_t len, esp_eddystone_result_t *res)
{ uint8_t pos = 0; if((len != EDDYSTONE_UID_DATA_LEN) && (len != (EDDYSTONE_UID_RFU_LEN+EDDYSTONE_UID_DATA_LEN))) { return -1; } res->inform.uid.ranging_data = buf[pos++]; for(int i=0; i<EDDYSTONE_UID_NAMESPACE_LEN; i++) { res->inform.uid.namespace_id[i] = buf[pos++]; } for(int i=0; i<EDDYSTONE_UID_INSTANCE_LEN; i++) { res->inform.uid.instance_id[i] = buf[pos++]; } return 0; }
retro-esp32/RetroESP32
C++
Creative Commons Attribution Share Alike 4.0 International
581
/* Configure PCM(TDM) function parameters, such as channel width, channel number and sync pulse width. */
void I2S_ConfigureTDM(I2S_T *i2s, uint32_t u32ChannelWidth, uint32_t u32ChannelNum, uint32_t u32SyncWidth)
/* Configure PCM(TDM) function parameters, such as channel width, channel number and sync pulse width. */ void I2S_ConfigureTDM(I2S_T *i2s, uint32_t u32ChannelWidth, uint32_t u32ChannelNum, uint32_t u32SyncWidth)
{ i2s->CTL0 = (i2s->CTL0 & ~(I2S_CTL0_TDMCHNUM_Msk | I2S_CTL0_CHWIDTH_Msk | I2S_CTL0_PCMSYNC_Msk)) | (u32ChannelWidth << I2S_CTL0_CHWIDTH_Pos) | (u32ChannelNum << I2S_CTL0_TDMCHNUM_Pos) | (u32SyncWidth << I2S_CTL0_PCMSYNC_Pos); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Puts the processor into sleep mode. This function places the processor into sleep mode; it will not return until the processor returns to run mode. */
void xSysCtlSleep(void)
/* Puts the processor into sleep mode. This function places the processor into sleep mode; it will not return until the processor returns to run mode. */ void xSysCtlSleep(void)
{ SysCtlPowerDownEnable(1); SysCtlPowerDownWaitCPUSet(1); xCPUwfi(); SysCtlPowerDownEnable(0); SysCtlPowerDownWaitCPUSet(0); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Converts the supplied 8-bit value to an approximate pixel height in the data grid */
uint16_t adcValToPixel(uint8_t value)
/* Converts the supplied 8-bit value to an approximate pixel height in the data grid */ uint16_t adcValToPixel(uint8_t value)
{ uint16_t pixel = 0; pixel = 200 - (value * 1000 / 1545); return pixel; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Reads a number of bytes to a page in the internal Flash. */
void _flash_read(struct _flash_device *const device, const uint32_t src_addr, uint8_t *buffer, uint32_t length)
/* Reads a number of bytes to a page in the internal Flash. */ void _flash_read(struct _flash_device *const device, const uint32_t src_addr, uint8_t *buffer, uint32_t length)
{ uint32_t nvm_address = src_addr / 2; uint32_t i; uint16_t data; while (!hri_nvmctrl_get_interrupt_READY_bit(device->hw)) { } hri_nvmctrl_clear_STATUS_reg(device->hw, NVMCTRL_STATUS_MASK); if (src_addr % 2) { data = NVM_MEMORY[nvm_address++]; buffer[0] = data >> 8; i = 1; } else { i = 0; } while (i < length) { data = NVM_MEMORY[nvm_address++]; buffer[i] = (data & 0xFF); if (i < (length - 1)) { buffer[i + 1] = (data >> 8); } i += 2; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Configures the ADCx external trigger for injected channels conversion. */
void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef *ADCx, uint32_t ADC_ExternalTrigInjecConv)
/* Configures the ADCx external trigger for injected channels conversion. */ void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef *ADCx, uint32_t ADC_ExternalTrigInjecConv)
{ uint32_t tmpreg = 0; assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConv)); tmpreg = ADCx->CR2; tmpreg &= CR2_JEXTSEL_Reset; tmpreg |= ADC_ExternalTrigInjecConv; ADCx->CR2 = tmpreg; }
gcallipo/RadioDSP-Stm32f103
C++
Common Creative - Attribution 3.0
51
/* Temperature data output register (r). L and H registers together express a 16-bit word in two’s complement.. */
int32_t lsm6dsl_temperature_raw_get(stmdev_ctx_t *ctx, uint8_t *buff)
/* Temperature data output register (r). L and H registers together express a 16-bit word in two’s complement.. */ int32_t lsm6dsl_temperature_raw_get(stmdev_ctx_t *ctx, uint8_t *buff)
{ int32_t ret; ret = lsm6dsl_read_reg(ctx, LSM6DSL_OUT_TEMP_L, buff, 2); return ret; }
eclipse-threadx/getting-started
C++
Other
310