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
/* Returns CR_OK upon successfull completion, an error code otherwise. */
enum CRStatus cr_doc_handler_set_result(CRDocHandler *a_this, gpointer a_result)
/* Returns CR_OK upon successfull completion, an error code otherwise. */ enum CRStatus cr_doc_handler_set_result(CRDocHandler *a_this, gpointer a_result)
{ g_return_val_if_fail (a_this && a_this->priv, CR_BAD_PARAM_ERROR); a_this->priv->result = a_result; return CR_OK; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Driver done interrupt service routine for channel 2. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */
void XDmaPs_DoneISR_2(XDmaPs *InstPtr)
/* Driver done interrupt service routine for channel 2. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC */ void XDmaPs_DoneISR_2(XDmaPs *InstPtr)
{ XDmaPs_DoneISR_n(InstPtr, 2); }
ua1arn/hftrx
C++
null
69
/* adds a firewall record Note that this function is documented in the main component header file, IxEthDB.h. */
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
/* adds a firewall record Note that this function is documented in the main component header file, IxEthDB.h. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr)
{ MacDescriptor recordTemplate; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(macAddr); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_FIREWALL); memcpy(recordTemplate.macAddress, macAddr, sizeof (IxEthDBMacAddr)); recordTemplate.type = IX_ETH_DB_FI...
EmcraftSystems/u-boot
C++
Other
181
/* special ep0 version of the above. no UBCR0 or double buffering; status handshaking is magic. most device protocols don't need control-OUT. CDC vendor commands (and RNDIS), mass storage CB/CBI, and some other protocols do use them. */
static int read_ep0_fifo(struct pxa25x_ep *ep, struct pxa25x_request *req)
/* special ep0 version of the above. no UBCR0 or double buffering; status handshaking is magic. most device protocols don't need control-OUT. CDC vendor commands (and RNDIS), mass storage CB/CBI, and some other protocols do use them. */ static int read_ep0_fifo(struct pxa25x_ep *ep, struct pxa25x_request *req)
{ u8 *buf, byte; unsigned bufferspace; buf = req->req.buf + req->req.actual; bufferspace = req->req.length - req->req.actual; while (UDCCS0 & UDCCS0_RNE) { byte = (u8) UDDR0; if (unlikely (bufferspace == 0)) { if (req->req.status != -EOVERFLOW) DMSG("%s overflow\n", ep->ep.name); req->req.status = -...
robutest/uclinux
C++
GPL-2.0
60
/* Enable or disable the low power mode for OPAMP peripheral. */
void OPAMP_LowPowerCmd(uint32_t OPAMP_Selection, FunctionalState NewState)
/* Enable or disable the low power mode for OPAMP peripheral. */ void OPAMP_LowPowerCmd(uint32_t OPAMP_Selection, FunctionalState NewState)
{ assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { OPAMP->CSR |= (uint32_t) (OPAMP_Selection << 7); } else { OPAMP->CSR &= (~(uint32_t) (OPAMP_Selection << 7)); } }
avem-labs/Avem
C++
MIT License
1,752
/* RTC MSP Initialization This function configures the hardware resources used in this example. */
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
/* RTC MSP Initialization This function configures the hardware resources used in this example. */ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{ if(hrtc->Instance==RTC) { __HAL_RCC_RTC_ENABLE(); __HAL_RCC_RTCAPB_CLK_ENABLE(); } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* If the interface is not supported, then ASSERT(). */
VOID EFIAPI CryptoServiceX509Free(IN VOID *X509Cert)
/* If the interface is not supported, then ASSERT(). */ VOID EFIAPI CryptoServiceX509Free(IN VOID *X509Cert)
{ CALL_VOID_BASECRYPTLIB (X509.Services.Free, X509Free, (X509Cert)); }
tianocore/edk2
C++
Other
4,240
/* Transfer data off of/on to card using programmed IO. Notes: this is incredibly slow. */
static void fas216_pio(FAS216_Info *info, fasdmadir_t direction)
/* Transfer data off of/on to card using programmed IO. Notes: this is incredibly slow. */ static void fas216_pio(FAS216_Info *info, fasdmadir_t direction)
{ struct scsi_pointer *SCp = &info->scsi.SCp; fas216_checkmagic(info); if (direction == DMA_OUT) fas216_writeb(info, REG_FF, get_next_SCp_byte(SCp)); else put_next_SCp_byte(SCp, fas216_readb(info, REG_FF)); if (SCp->this_residual == 0) next_SCp(SCp); }
robutest/uclinux
C++
GPL-2.0
60
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. */
static void s2io_io_resume(struct pci_dev *pdev)
/* This callback is called when the error recovery driver tells us that its OK to resume normal operation. */ static void s2io_io_resume(struct pci_dev *pdev)
{ struct net_device *netdev = pci_get_drvdata(pdev); struct s2io_nic *sp = netdev_priv(netdev); if (netif_running(netdev)) { if (s2io_card_up(sp)) { pr_err("Can't bring device back up after reset.\n"); return; } if (s2io_set_mac_addr(netdev, netdev->dev_addr) == FAILURE) { s2io_card_down(sp); pr_er...
robutest/uclinux
C++
GPL-2.0
60
/* XXX - there should perhaps be a preference setting to turn this off, as sometimes it can, and does, get a false hit. */
static int check_for_old_linux_tvb(tvbuff_t *tvb)
/* XXX - there should perhaps be a preference setting to turn this off, as sometimes it can, and does, get a false hit. */ static int check_for_old_linux_tvb(tvbuff_t *tvb)
{ const guint8 *data; int x, bytes; bytes = tvb_captured_length(tvb); if (bytes > 19) { bytes = 19; } data = tvb_get_ptr(tvb, 0, bytes); for(x = 1; x <= bytes-1 ;x++) { if (memcmp(&data[0], &data[x], x) == 0) { return x; } } return 0; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* The register selects a DWORD (32 bit) register offset. Hence it doesn't get shifted by 2 bits as we want to "drop" the bottom two bits. */
static int mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where, unsigned long *pci_addr, unsigned char *type1)
/* The register selects a DWORD (32 bit) register offset. Hence it doesn't get shifted by 2 bits as we want to "drop" the bottom two bits. */ static int mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where, unsigned long *pci_addr, unsigned char *type1)
{ struct pci_controller *hose = pbus->sysdata; unsigned long addr; u8 bus = pbus->number; DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, " "pci_addr=0x%p, type1=0x%p)\n", bus, device_fn, where, pci_addr, type1)); if (!pbus->parent) bus = 0; *type1 = (bus != 0); addr = (bus << 16) | (device_fn...
EmcraftSystems/linux-emcraft
C++
Other
266
/* Function for activating received Application image. This function will move the received application image fram swap (bank 1) to application area (bank 0). */
static uint32_t dfu_activate_app(void)
/* Function for activating received Application image. This function will move the received application image fram swap (bank 1) to application area (bank 0). */ static uint32_t dfu_activate_app(void)
{ uint32_t err_code; err_code = pstorage_clear(&m_storage_handle_app, m_start_packet.app_image_size); APP_ERROR_CHECK(err_code); err_code = pstorage_store(&m_storage_handle_app, (uint8_t *)m_storage_handle_swap.block_id, m_start_packet....
labapart/polymcu
C++
null
201
/* Clears or safeguards the OCREF5 signal on an external event. */
void TIM_ClearOC5Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
/* Clears or safeguards the OCREF5 signal on an external event. */ void TIM_ClearOC5Ref(TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
{ uint32_t tmpccmr3 = 0; assert_param(IS_TIM_LIST4_PERIPH(TIMx)); assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear)); tmpccmr3 = TIMx->CCMR3; tmpccmr3 &= (uint32_t)~TIM_CCMR3_OC5CE; tmpccmr3 |= (uint32_t)(TIM_OCClear); TIMx->CCMR3 = tmpccmr3; }
ajhc/demo-cortex-m3
C++
null
38
/* The heartbeat timer of IP6 service instance. It times out all of its IP6 children's received-but-not-delivered and transmitted-but-not-recycle packets. */
VOID EFIAPI Ip6TimerTicking(IN EFI_EVENT Event, IN VOID *Context)
/* The heartbeat timer of IP6 service instance. It times out all of its IP6 children's received-but-not-delivered and transmitted-but-not-recycle packets. */ VOID EFIAPI Ip6TimerTicking(IN EFI_EVENT Event, IN VOID *Context)
{ IP6_SERVICE *IpSb; IpSb = (IP6_SERVICE *)Context; NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); Ip6PacketTimerTicking (IpSb); Ip6NdTimerTicking (IpSb); Ip6MldTimerTicking (IpSb); }
tianocore/edk2
C++
Other
4,240
/* Software reset. Restore the default values in user registers.. */
int32_t lsm6dso_reset_get(lsm6dso_ctx_t *ctx, uint8_t *val)
/* Software reset. Restore the default values in user registers.. */ int32_t lsm6dso_reset_get(lsm6dso_ctx_t *ctx, uint8_t *val)
{ lsm6dso_ctrl3_c_t reg; int32_t ret; ret = lsm6dso_read_reg(ctx, LSM6DSO_CTRL3_C, (uint8_t*)&reg, 1); *val = reg.sw_reset; return ret; }
alexander-g-dean/ESF
C++
null
41
/* Returns the link containing the data or NULL */
static xmlLinkPtr xmlListHigherSearch(xmlListPtr l, void *data)
/* Returns the link containing the data or NULL */ static xmlLinkPtr xmlListHigherSearch(xmlListPtr l, void *data)
{ xmlLinkPtr lk; if (l == NULL) return(NULL); for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); return lk; }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Returns TRUE if the machine type of PE/COFF image is supported. Supported does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point. */
BOOLEAN PeCoffLoaderImageFormatSupported(IN UINT16 Machine)
/* Returns TRUE if the machine type of PE/COFF image is supported. Supported does not mean the image can be executed it means the PE/COFF loader supports loading and relocating of the image type. It's up to the caller to support the entry point. */ BOOLEAN PeCoffLoaderImageFormatSupported(IN UINT16 Machine)
{ if ((Machine == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) || (Machine == IMAGE_FILE_MACHINE_EBC)) { return TRUE; } return FALSE; }
tianocore/edk2
C++
Other
4,240
/* Return the maximum counter, useful for initiating counters Utility functions used for various comparisons/cleanups in tree */
static gint rrc_key_cmp(gconstpointer b_ptr, gconstpointer a_ptr, gpointer ignore _U_)
/* Return the maximum counter, useful for initiating counters Utility functions used for various comparisons/cleanups in tree */ static gint rrc_key_cmp(gconstpointer b_ptr, gconstpointer a_ptr, gpointer ignore _U_)
{ return -1; } return GPOINTER_TO_INT(a_ptr) < GPOINTER_TO_INT(b_ptr); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Draws an ASCII character on the given LCD buffer. */
void LCDD_DrawChar(void *pBuffer, unsigned int x, unsigned int y, char c, unsigned int color)
/* Draws an ASCII character on the given LCD buffer. */ void LCDD_DrawChar(void *pBuffer, unsigned int x, unsigned int y, char c, unsigned int color)
{ unsigned int row, col; SANITY_CHECK((c >= 0x20) && (c <= 0x7F)); for (col = 0; col < 10; col++) { for (row = 0; row < 8; row++) { if ((pCharset10x14[((c - 0x20) * 20) + col * 2] >> (7 - row)) & 0x1) { LCDD_DrawPixel(pBuffer, x+col, y+row, color); } }...
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Message: SubscribeDtmfPayloadReqMessage Opcode: 0x0129 Type: CallControl Direction: pbx2dev VarLength: no */
static void handle_SubscribeDtmfPayloadReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
/* Message: SubscribeDtmfPayloadReqMessage Opcode: 0x0129 Type: CallControl Direction: pbx2dev VarLength: no */ static void handle_SubscribeDtmfPayloadReqMessage(ptvcursor_t *cursor, packet_info *pinfo _U_)
{ ptvcursor_add(cursor, hf_skinny_payloadDtmf, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_conferenceID, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_passthruPartyID, 4, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_skinny_dtmfType, 4, ENC_LITTLE_ENDIAN); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* Enables packet timestamping and starts the system clock running. */
void EMACTimestampEnable(uint32_t ui32Base)
/* Enables packet timestamping and starts the system clock running. */ void EMACTimestampEnable(uint32_t ui32Base)
{ ASSERT(ui32Base == EMAC0_BASE); HWREG(ui32Base + EMAC_O_TIMSTCTRL) |= EMAC_TIMSTCTRL_TSEN; if(!(HWREG(ui32Base + EMAC_O_TIMSTCTRL) & EMAC_TIMSTCTRL_TSINIT)) { HWREG(ui32Base + EMAC_O_TIMSTCTRL) |= EMAC_TIMSTCTRL_TSINIT; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Returns the flash Write Protection Option Bytes value: */
uint32_t FMC_ReadOptionByteWriteProtection(void)
/* Returns the flash Write Protection Option Bytes value: */ uint32_t FMC_ReadOptionByteWriteProtection(void)
{ return (uint32_t)(FMC->WRTPROT); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Selects the MII port. When called MII (10/100Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */
void synopGMAC_select_mii(synopGMACdevice *gmacdev)
/* Selects the MII port. When called MII (10/100Mbps) port is selected (programmable only in 10/100/1000 Mbps configuration). */ void synopGMAC_select_mii(synopGMACdevice *gmacdev)
{ synopGMACSetBits(gmacdev -> MacBase, GmacConfig, GmacMiiGmii); return; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Select duplex mode depending on negotiation state. This also updates our carrier state. */
static void smc_phy_check_media(struct net_device *dev, int init)
/* Select duplex mode depending on negotiation state. This also updates our carrier state. */ static void smc_phy_check_media(struct net_device *dev, int init)
{ struct smc_local *lp = netdev_priv(dev); void __iomem *ioaddr = lp->base; if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) { if (lp->mii.full_duplex) { lp->tcr_cur_mode |= TCR_SWFDUP; } else { lp->tcr_cur_mode &= ~TCR_SWFDUP; } SMC_SELECT_BANK(lp, 0); SMC_SET_TCR(lp, lp->tcr_cur_mode); } }
robutest/uclinux
C++
GPL-2.0
60
/* Read a device register and return its value. The MCP interface must be enabled to prevent this function hanging. */
unsigned int mcp_reg_read(struct mcp *mcp, unsigned int reg)
/* Read a device register and return its value. The MCP interface must be enabled to prevent this function hanging. */ unsigned int mcp_reg_read(struct mcp *mcp, unsigned int reg)
{ unsigned long flags; unsigned int val; spin_lock_irqsave(&mcp->lock, flags); val = mcp->ops->reg_read(mcp, reg); spin_unlock_irqrestore(&mcp->lock, flags); return val; }
robutest/uclinux
C++
GPL-2.0
60
/* fcs_vport_public FCS virtual port public interfaces Online notification from fabric SM. */
void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport)
/* fcs_vport_public FCS virtual port public interfaces Online notification from fabric SM. */ void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport)
{ vport->vport_stats.fab_online++; bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE); }
robutest/uclinux
C++
GPL-2.0
60
/* This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. This event is signaled with */
EFI_STATUS EFIAPI EfiNamedEventListen(IN CONST EFI_GUID *Name, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN CONST VOID *NotifyContext OPTIONAL, OUT VOID *Registration OPTIONAL)
/* This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. This event is signaled with */ EFI_STATUS EFIAPI EfiNamedEventListen(IN CONST EFI_GUID *Name, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN CONST VOID *NotifyContext OPTIONAL, OUT VOID *Registration OPTIONAL)
{ EFI_STATUS Status; EFI_EVENT Event; VOID *RegistrationLocal; ASSERT (Name != NULL); ASSERT (NotifyFunction != NULL); ASSERT (NotifyTpl <= TPL_HIGH_LEVEL); Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, NotifyTpl, NotifyFunction, ...
tianocore/edk2
C++
Other
4,240
/* Simple callback that copies response back into command. */
int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, struct cmd_header *resp)
/* Simple callback that copies response back into command. */ int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, struct cmd_header *resp)
{ struct cmd_header *buf = (void *)extra; uint16_t copy_len; copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size)); memcpy(buf, resp, copy_len); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* This function is called from the board init */
void __init u8500_init_devices(void)
/* This function is called from the board init */ void __init u8500_init_devices(void)
{ platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); return ; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Decrement a buffer_head's reference count. If all buffers against a page have zero reference count, are clean and unlocked, and if the page is clean and unlocked then try_to_free_buffers() may strip the buffers from the page in preparation for freeing it (sometimes, rarely, buffers are removed from a page but it end...
void __brelse(struct buffer_head *buf)
/* Decrement a buffer_head's reference count. If all buffers against a page have zero reference count, are clean and unlocked, and if the page is clean and unlocked then try_to_free_buffers() may strip the buffers from the page in preparation for freeing it (sometimes, rarely, buffers are removed from a page but it end...
{ if (atomic_read(&buf->b_count)) { put_bh(buf); return; } WARN(1, KERN_ERR "VFS: brelse: Trying to free free buffer\n"); }
robutest/uclinux
C++
GPL-2.0
60
/* When running on a device supporting extended PWM fault handling, the fault interrupts are derived by performing a logical OR of each of the configured fault trigger signals for a given generator. Therefore, these interrupts are not directly related to the four possible FAULTn inputs to the device but indicate that a...
void PWMFaultIntClearExt(unsigned long ulBase, unsigned long ulFaultInts)
/* When running on a device supporting extended PWM fault handling, the fault interrupts are derived by performing a logical OR of each of the configured fault trigger signals for a given generator. Therefore, these interrupts are not directly related to the four possible FAULTn inputs to the device but indicate that a...
{ ASSERT(ulBase == PWM_BASE); ASSERT((ulFaultInts & ~(PWM_INT_FAULT0 | PWM_INT_FAULT1 | PWM_INT_FAULT2 | PWM_INT_FAULT3)) == 0); HWREG(ulBase + PWM_O_ISC) = ulFaultInts; }
watterott/WebRadio
C++
null
71
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI PciExpressAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
/* If Address > 0x0FFFFFFF, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */ UINT32 EFIAPI PciExpressAndThenOr32(IN UINTN Address, IN UINT32 AndData, IN UINT32 OrData)
{ if (Address >= mSmmPciExpressLibPciExpressBaseSize) { return (UINT32)-1; } return MmioAndThenOr32 ( GetPciExpressAddress (Address), AndData, OrData ); }
tianocore/edk2
C++
Other
4,240
/* @speed: The speed in Hz to calculate the clock cycle duration for. */
uint calc_tick(uint speed)
/* @speed: The speed in Hz to calculate the clock cycle duration for. */ uint calc_tick(uint speed)
{ return (1000000000u / speed) + 100; }
4ms/stm32mp1-baremetal
C++
Other
137
/* try to convert a value to an integer, rounding according to 'mode': mode == 0: accepts only integral values mode == 1: takes the floor of the number mode == 2: takes the ceil of the number */
int luaV_tointeger(const TValue *obj, lua_Integer *p, int mode)
/* try to convert a value to an integer, rounding according to 'mode': mode == 0: accepts only integral values mode == 1: takes the floor of the number mode == 2: takes the ceil of the number */ int luaV_tointeger(const TValue *obj, lua_Integer *p, int mode)
{ lua_Number n = fltvalue(obj); lua_Number f = l_floor(n); if (n != f) { if (mode == 0) return 0; else if (mode > 1) f += 1; } return lua_numbertointeger(f, p); } else if (ttisinteger(obj)) { *p = ivalue(obj); return 1; } else if (cvt2num(obj) && luaO_...
nodemcu/nodemcu-firmware
C++
MIT License
7,566
/* Check if point is inside clipping region. This function checks if a point is inside the clipping region. The origin field of the clipping region is not relevant, only the corners of the clipping region itself. */
bool win_is_inside_clip(const struct win_clip_region *clip, const struct win_point *point)
/* Check if point is inside clipping region. This function checks if a point is inside the clipping region. The origin field of the clipping region is not relevant, only the corners of the clipping region itself. */ bool win_is_inside_clip(const struct win_clip_region *clip, const struct win_point *point)
{ return (clip->NW.x <= point->x) && (clip->NW.y <= point->y) && (point->x <= clip->SE.x) && (point->y <= clip->SE.y); }
memfault/zero-to-main
C++
null
200
/* Deinitializes the CAN peripheral registers to their default reset values. */
void CAN_DeInit(CAN_Module *CANx)
/* Deinitializes the CAN peripheral registers to their default reset values. */ void CAN_DeInit(CAN_Module *CANx)
{ assert_param(IS_CAN_ALL_PERIPH(CANx)); if (CANx == CAN1) { RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_CAN1, ENABLE); RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_CAN1, DISABLE); } else { RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_CAN2, ENABLE); RCC_EnableAPB1PeriphRe...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Try to post a message to mailbox from ISR. */
err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg)
/* Try to post a message to mailbox from ISR. */ err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg)
{ BaseType_t ret; BaseType_t xHigherPriorityTaskWoken = pdFALSE; ret = xQueueSendFromISR((*mbox)->os_mbox, &msg, &xHigherPriorityTaskWoken); if (ret == pdTRUE) { if (xHigherPriorityTaskWoken == pdTRUE) { return ERR_NEED_SCHED; } return ERR_OK; } else { LWIP_ASSERT("mbox trypost failed", ...
nanoframework/nf-interpreter
C++
MIT License
293
/* 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; }
avem-labs/Avem
C++
MIT License
1,752
/* Returns pointer to current completion descriptor to consume */
STATIC PVSCSI_RING_CMP_DESC* PvScsiGetCurrentResponse(IN CONST PVSCSI_DEV *Dev)
/* Returns pointer to current completion descriptor to consume */ STATIC PVSCSI_RING_CMP_DESC* PvScsiGetCurrentResponse(IN CONST PVSCSI_DEV *Dev)
{ PVSCSI_RINGS_STATE *RingState; UINT32 CmpNumEntries; RingState = Dev->RingDesc.RingState; CmpNumEntries = 1U << RingState->CmpNumEntriesLog2; return Dev->RingDesc.RingCmps + (RingState->CmpConsIdx & (CmpNumEntries - 1)); }
tianocore/edk2
C++
Other
4,240
/* Restore the generation IRQ interrupts to the setting it had prior to calling IrqInterruptDisable. Normally used as a pair together with IrqInterruptDisable during a critical section. */
void IrqInterruptRestore(void)
/* Restore the generation IRQ interrupts to the setting it had prior to calling IrqInterruptDisable. Normally used as a pair together with IrqInterruptDisable during a critical section. */ void IrqInterruptRestore(void)
{ irqNesting--; if (irqNesting == 0) { asm { ldaa irqCCRregSave tap } } }
feaser/openblt
C++
GNU General Public License v3.0
601
/* atl1c_tx_timeout - Respond to a Tx Hang @netdev: network interface device structure */
static void atl1c_tx_timeout(struct net_device *netdev)
/* atl1c_tx_timeout - Respond to a Tx Hang @netdev: network interface device structure */ static void atl1c_tx_timeout(struct net_device *netdev)
{ struct atl1c_adapter *adapter = netdev_priv(netdev); adapter->work_event |= ATL1C_WORK_EVENT_RESET; schedule_work(&adapter->common_task); }
robutest/uclinux
C++
GPL-2.0
60
/* Write a specific register in the controller with a single byte. Use this function to write a value to a specific register in the display controller. */
void hx8347a_write_register(uint8_t address, uint8_t value)
/* Write a specific register in the controller with a single byte. Use this function to write a value to a specific register in the display controller. */ void hx8347a_write_register(uint8_t address, uint8_t value)
{ hx8347a_select_register(address); hx8347a_select_chip(); hx8347a_send_byte(HX8347A_START_WRITEREG); hx8347a_send_byte(value); hx8347a_deselect_chip(); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Example: sign_extend(9, 3) would return -7 as bit3 of 1001b is 1 and bit0..2 is 001b which when sign extended to 1111111111111001b is -7. */
static s32 sign_extend(u32 oper, int index)
/* Example: sign_extend(9, 3) would return -7 as bit3 of 1001b is 1 and bit0..2 is 001b which when sign extended to 1111111111111001b is -7. */ static s32 sign_extend(u32 oper, int index)
{ u8 shift = 31 - index; return (s32)(oper << shift) >> shift; }
robutest/uclinux
C++
GPL-2.0
60
/* Calculates an integer from two bytes read from the input buffer */
int mqtt_read_int(unsigned char **pptr)
/* Calculates an integer from two bytes read from the input buffer */ int mqtt_read_int(unsigned char **pptr)
{ unsigned char* ptr = *pptr; int len = 256*(*ptr) + (*(ptr+1)); *pptr += 2; return len; }
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Returns true if the requested field equals to the str (including NULL). */
bool dmi_match(enum dmi_field f, const char *str)
/* Returns true if the requested field equals to the str (including NULL). */ bool dmi_match(enum dmi_field f, const char *str)
{ const char *info = dmi_get_system_info(f); if (info == NULL || str == NULL) return info == str; return !strcmp(info, str); }
robutest/uclinux
C++
GPL-2.0
60
/* Processes a given Keyboard LED report from the host, and sets the board LEDs to match. Since the Keyboard LED report can be sent through either the control endpoint (via a HID SetReport request) or the HID OUT endpoint, the processing code is placed here to avoid duplicating it and potentially having different behav...
void Keyboard_ProcessLEDReport(const uint8_t LEDStatus)
/* Processes a given Keyboard LED report from the host, and sets the board LEDs to match. Since the Keyboard LED report can be sent through either the control endpoint (via a HID SetReport request) or the HID OUT endpoint, the processing code is placed here to avoid duplicating it and potentially having different behav...
{ uint8_t LEDMask = LEDS_LED2; if (LEDStatus & HID_KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; if (LEDStatus & HID_KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; if (LEDStatus & HID_KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; LEDs_SetAllLEDs(LEDMask); }
prusa3d/Prusa-Firmware-Buddy
C++
Other
1,019
/* This function checks if the buffer is valid per processor architecture and does not overlap with SMRAM. */
BOOLEAN VariableSmmIsBufferOutsideSmmValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
/* This function checks if the buffer is valid per processor architecture and does not overlap with SMRAM. */ BOOLEAN VariableSmmIsBufferOutsideSmmValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
{ return SmmIsBufferOutsideSmmValid (Buffer, Length); }
tianocore/edk2
C++
Other
4,240
/* The constructor function initializes the Smm IO library */
EFI_STATUS EFIAPI SmmIoLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
/* The constructor function initializes the Smm IO library */ EFI_STATUS EFIAPI SmmIoLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{ EFI_STATUS Status; SmmIoLibInternalCalculateMaximumSupportAddress (); Status = gSmst->SmmRegisterProtocolNotify (&gEfiSmmEndOfDxeProtocolGuid, SmmIoLibInternalEndOfDxeNotify, &mSmmIoLibRegistrationEndOfDxe); ASSERT_EFI_ERROR (Status); Status = gSmst->SmmRegisterProtocolNotify (&gEfiSmmReadyToLockProtocolGu...
tianocore/edk2
C++
Other
4,240
/* on an EXCLUSIVE create, the server should send back a bitmask with FATTR4-* fields corresponding to attributes that were used to store the verifier. Make sure we clobber those fields in the later setattr call */
static void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct iattr *sattr)
/* on an EXCLUSIVE create, the server should send back a bitmask with FATTR4-* fields corresponding to attributes that were used to store the verifier. Make sure we clobber those fields in the later setattr call */ static void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct iattr *sattr)
{ if ((opendata->o_res.attrset[1] & FATTR4_WORD1_TIME_ACCESS) && !(sattr->ia_valid & ATTR_ATIME_SET)) sattr->ia_valid |= ATTR_ATIME; if ((opendata->o_res.attrset[1] & FATTR4_WORD1_TIME_MODIFY) && !(sattr->ia_valid & ATTR_MTIME_SET)) sattr->ia_valid |= ATTR_MTIME; }
robutest/uclinux
C++
GPL-2.0
60
/* Get Word2 of the unique device identifier (UID based on 96 bits) */
uint32_t LL_GetUID_Word2(void)
/* Get Word2 of the unique device identifier (UID based on 96 bits) */ uint32_t LL_GetUID_Word2(void)
{ return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); }
remotemcu/remcu-chip-sdks
C++
null
436
/* Request the PE to send a VDM discovery SVID. */
USBPD_StatusTypeDef USBPD_DPM_RequestVDM_DiscoverySVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType)
/* Request the PE to send a VDM discovery SVID. */ USBPD_StatusTypeDef USBPD_DPM_RequestVDM_DiscoverySVID(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType)
{ return USBPD_PE_SVDM_RequestSVID(PortNum, SOPType); }
st-one/X-CUBE-USB-PD
C++
null
110
/* Reset the host associated with this command. Returns: FAILED if unable to reset. Notes: io_request_lock is taken, and irqs are disabled */
int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
/* Reset the host associated with this command. Returns: FAILED if unable to reset. Notes: io_request_lock is taken, and irqs are disabled */ int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
{ FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; spin_lock_irq(info->host->host_lock); fas216_checkmagic(info); printk("scsi%d.%c: %s: resetting host\n", info->host->host_no, '0' + SCpnt->device->id, __func__); fas216_cmd(info, CMD_RESETCHIP); spin_unlock_irq(info->host->host_lock); msleep(5...
robutest/uclinux
C++
GPL-2.0
60
/* Get next message from message queue. Return NULL if no message present. User must call next_message() to move to next message. rmq message queue */
void* gru_get_next_message(struct gru_message_queue_desc *mqd)
/* Get next message from message queue. Return NULL if no message present. User must call next_message() to move to next message. rmq message queue */ void* gru_get_next_message(struct gru_message_queue_desc *mqd)
{ struct message_queue *mq = mqd->mq; struct message_header *mhdr = mq->next; int present = mhdr->present; while (present == MQS_NOOP) { gru_free_message(mqd, mhdr); mhdr = mq->next; present = mhdr->present; } if (present == MQS_FULL && mhdr->lines == 2 && get_present2(mhdr) == MQS_EMPTY) present = MQ...
robutest/uclinux
C++
GPL-2.0
60
/* called to determine if there is an EDAC driver interested in knowing an event (such as NMI) occurred */
int edac_handler_set(void)
/* called to determine if there is an EDAC driver interested in knowing an event (such as NMI) occurred */ int edac_handler_set(void)
{ if (edac_op_state == EDAC_OPSTATE_POLL) return 0; return atomic_read(&edac_handlers); }
robutest/uclinux
C++
GPL-2.0
60
/* sunxi_lcd_power_enable - enable the power of panel. @screen_id: The index of screen. @pwr_id: The index of power */
void sunxi_lcd_power_enable(u32 screen_id, u32 pwr_id)
/* sunxi_lcd_power_enable - enable the power of panel. @screen_id: The index of screen. @pwr_id: The index of power */ void sunxi_lcd_power_enable(u32 screen_id, u32 pwr_id)
{ if (g_lcd_drv.src_ops.sunxi_lcd_power_enable) g_lcd_drv.src_ops.sunxi_lcd_power_enable(screen_id, pwr_id); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Get slave arbitration type of the specified slave. */
arbitration_type_t matrix_get_slave_arbitration_type(uint32_t ul_id)
/* Get slave arbitration type of the specified slave. */ arbitration_type_t matrix_get_slave_arbitration_type(uint32_t ul_id)
{ Matrix *p_matrix = MATRIX; volatile uint32_t ul_reg; ul_reg = p_matrix->MATRIX_SCFG[ul_id] & (MATRIX_SCFG_ARBT_Msk); return (arbitration_type_t)ul_reg; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Get all the PWR flag is set or not. */
unsigned long SysCtlFlagStatusGet(void)
/* Get all the PWR flag is set or not. */ unsigned long SysCtlFlagStatusGet(void)
{ return (xHWREG(PWR_CSR) & (PWR_CSR_WUF | PWR_CSR_SBF | PWR_CSR_PVDO)); }
coocox/cox
C++
Berkeley Software Distribution (BSD)
104
/* Returns NULL if not found, otherwise node set for the ID. */
xmlListPtr xmlGetRefs(xmlDocPtr doc, const xmlChar *ID)
/* Returns NULL if not found, otherwise node set for the ID. */ xmlListPtr xmlGetRefs(xmlDocPtr doc, const xmlChar *ID)
{ return(NULL); } if (ID == NULL) { return(NULL); } table = (xmlRefTablePtr) doc->refs; if (table == NULL) return(NULL); return (xmlHashLookup(table, ID)); }
seemoo-lab/nexmon
C++
GNU General Public License v3.0
2,330
/* An error must be cleared or acked to take a FS out of readonly mode. */
int jbd2_journal_clear_err(journal_t *journal)
/* An error must be cleared or acked to take a FS out of readonly mode. */ int jbd2_journal_clear_err(journal_t *journal)
{ int err = 0; spin_lock(&journal->j_state_lock); if (journal->j_flags & JBD2_ABORT) err = -EROFS; else journal->j_errno = 0; spin_unlock(&journal->j_state_lock); return err; }
robutest/uclinux
C++
GPL-2.0
60
/* Forces or releases Low Speed APB (APB1) peripheral reset. */
void RCC_APB1PeriphReset(u32 apb1_periph)
/* Forces or releases Low Speed APB (APB1) peripheral reset. */ void RCC_APB1PeriphReset(u32 apb1_periph)
{ RCC->APB1RSTR |= apb1_periph; RCC->APB1RSTR &= ~apb1_periph; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Free the URB as it purpose has been served. Usage: Backend use it to mark the transfer */
void usbd_urb_complete(usbd_device *dev, usbd_urb *urb, usbd_transfer_status status)
/* Free the URB as it purpose has been served. Usage: Backend use it to mark the transfer */ void usbd_urb_complete(usbd_device *dev, usbd_urb *urb, usbd_transfer_status status)
{ detach_from_active(dev, urb); urb_callback(dev, urb, status); unused_push(dev, urb); usbd_urb_schedule(dev); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* If 64-bit 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */
UINT64 EFIAPI BitFieldWrite64(IN UINT64 Operand, IN UINTN StartBit, IN UINTN EndBit, IN UINT64 Value)
/* If 64-bit 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 Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT(). */ UINT64 EFIAPI BitField...
{ ASSERT (EndBit < 64); ASSERT (StartBit <= EndBit); return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value); }
tianocore/edk2
C++
Other
4,240
/* Free pages allocated from bio_copy_user() and write back data to user space in case of a read. */
int bio_uncopy_user(struct bio *bio)
/* Free pages allocated from bio_copy_user() and write back data to user space in case of a read. */ int bio_uncopy_user(struct bio *bio)
{ struct bio_map_data *bmd = bio->bi_private; int ret = 0; if (!bio_flagged(bio, BIO_NULL_MAPPED)) ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, bmd->nr_sgvecs, bio_data_dir(bio) == READ, 0, bmd->is_our_pages); bio_free_map_data(bmd); bio_put(bio); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Converts a text device path node to ACPI HID device path structure. */
EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpi(CHAR16 *TextDeviceNode)
/* Converts a text device path node to ACPI HID device path structure. */ EFI_DEVICE_PATH_PROTOCOL* DevPathFromTextAcpi(CHAR16 *TextDeviceNode)
{ CHAR16 *HIDStr; CHAR16 *UIDStr; ACPI_HID_DEVICE_PATH *Acpi; HIDStr = GetNextParamStr (&TextDeviceNode); UIDStr = GetNextParamStr (&TextDeviceNode); Acpi = (ACPI_HID_DEVICE_PATH *) CreateDeviceNode ( ACPI_DEVICE_PATH, ...
tianocore/edk2
C++
Other
4,240
/* Release regions claimed by a successful call to amba_request_regions. */
void amba_release_regions(struct amba_device *dev)
/* Release regions claimed by a successful call to amba_request_regions. */ void amba_release_regions(struct amba_device *dev)
{ u32 size; size = resource_size(&dev->res); release_mem_region(dev->res.start, size); }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Computes a cycle count for a given time in nanoseconds. */
static uint32_t LPI2C_GetCyclesForWidth(uint32_t sourceClock_Hz, uint32_t width_ns, uint32_t maxCycles, uint32_t prescaler)
/* Computes a cycle count for a given time in nanoseconds. */ static uint32_t LPI2C_GetCyclesForWidth(uint32_t sourceClock_Hz, uint32_t width_ns, uint32_t maxCycles, uint32_t prescaler)
{ uint32_t busCycle_ns = 1000000 / (sourceClock_Hz / prescaler / 1000); uint32_t cycles = 0; while ((((cycles + 1) * busCycle_ns) < width_ns) && (cycles + 1 < maxCycles)) { ++cycles; } if ((cycles == 0) && (busCycle_ns <= (width_ns * 10))) { cycles = 1; } return cycle...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Sends a byte of data to one of the TWI slaves on the bus. This function must be called once before TWI_StartWrite() with the first byte of data to send, then it shall be called repeatedly after that to send the remaining bytes. */
void TWI_WriteByte(AT91S_TWI *pTwi, unsigned char byte)
/* Sends a byte of data to one of the TWI slaves on the bus. This function must be called once before TWI_StartWrite() with the first byte of data to send, then it shall be called repeatedly after that to send the remaining bytes. */ void TWI_WriteByte(AT91S_TWI *pTwi, unsigned char byte)
{ SANITY_CHECK(pTwi); pTwi->TWI_THR = byte; }
apopple/Pandaboard-FreeRTOS
C++
null
25
/* Lock the security level of PUF block until key generate, wrap or unwrap operation is completed. Note: Only secure-privilege code can change the security level. */
status_t PUF_SetLock(PUF_Type *base, puf_sec_level_t securityLevel)
/* Lock the security level of PUF block until key generate, wrap or unwrap operation is completed. Note: Only secure-privilege code can change the security level. */ status_t PUF_SetLock(PUF_Type *base, puf_sec_level_t securityLevel)
{ uint32_t sec_lock_option = 0u; if ((securityLevel != kPUF_NonsecureUser) && (securityLevel != kPUF_NonsecurePrivilege) && (securityLevel != kPUF_SecureUser) && (securityLevel != kPUF_SecurePrivilege)) { return kStatus_InvalidArgument; } while ((base->SR & PUF_SR_BUSY_MASK) != 0u) ...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Read one byte out of the RX buffer. This function will return the byte located at the array index of the read pointer, and then increment the read pointer index. If the read pointer exceeds the maximum buffer size, it will roll over to zero. */
uint8_t uartRxBufferRead()
/* Read one byte out of the RX buffer. This function will return the byte located at the array index of the read pointer, and then increment the read pointer index. If the read pointer exceeds the maximum buffer size, it will roll over to zero. */ uint8_t uartRxBufferRead()
{ uart_pcb_t *pcb = uartGetPCB(); uint8_t data; data = pcb->rxfifo.buf[pcb->rxfifo.rd_ptr]; pcb->rxfifo.rd_ptr = (pcb->rxfifo.rd_ptr + 1) % CFG_UART_BUFSIZE; pcb->rxfifo.len--; return data; }
microbuilder/LPC1343CodeBase
C++
Other
73
/* Note: One reference to the tape device was made by the open function. So we just get the pointer here and release the reference. */
static int tapeblock_release(struct gendisk *, fmode_t)
/* Note: One reference to the tape device was made by the open function. So we just get the pointer here and release the reference. */ static int tapeblock_release(struct gendisk *, fmode_t)
{ struct tape_device *device = disk->private_data; tape_state_set(device, TS_IN_USE); tape_release(device); tape_put_device(device); return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
/* TIM_Base MSP Initialization This function configures the hardware resources used in this example. */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
{ if(htim_base->Instance==TIM1) { __HAL_RCC_TIM1_CLK_ENABLE(); } else if(htim_base->Instance==TIM2) { __HAL_RCC_TIM2_CLK_ENABLE(); } else if(htim_base->Instance==TIM3) { __HAL_RCC_TIM3_CLK_ENABLE(); } else if(htim_base->Instance==TIM4) { __HAL_RCC_TIM4_CLK_ENABLE(); } else if(h...
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Enables a GPIO pin as a trigger to start an ADC capture. */
void GPIOADCTriggerEnable(unsigned long ulPort, unsigned char ucPins)
/* Enables a GPIO pin as a trigger to start an ADC capture. */ void GPIOADCTriggerEnable(unsigned long ulPort, unsigned char ucPins)
{ ASSERT(GPIOBaseValid(ulPort)); HWREG(ulPort + GPIO_O_ADCCTL) |= ucPins; }
feaser/openblt
C++
GNU General Public License v3.0
601
/* Use this to compute the square root of a 16.16 fixed point number. */
square_root(FT_16D16 val)
/* Use this to compute the square root of a 16.16 fixed point number. */ square_root(FT_16D16 val)
{ FT_ULong t, q, b, r; r = (FT_ULong)val; b = 0x40000000L; q = 0; while ( b > 0x40L ) { t = q + b; if ( r >= t ) { r -= t; q = t + b; } r <<= 1; b >>= 1; } q >>= 8; return (FT_16D16)q; }
pikasTech/PikaPython
C++
MIT License
1,403
/* This function returns the real bus clock of USCI_I2C module. */
uint32_t UI2C_GetBusClockFreq(UI2C_T *ui2c)
/* This function returns the real bus clock of USCI_I2C module. */ uint32_t UI2C_GetBusClockFreq(UI2C_T *ui2c)
{ uint32_t u32Divider; uint32_t u32Pclk; if (ui2c == UI2C0) { u32Pclk = CLK_GetPCLK0Freq(); } else { u32Pclk = CLK_GetPCLK1Freq(); } u32Divider = (ui2c->BRGEN & UI2C_BRGEN_CLKDIV_Msk) >> UI2C_BRGEN_CLKDIV_Pos; return (u32Pclk / ((u32Divider + 1U) << 1U)); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Force the running and committing transactions to commit, and wait on the commit. */
int ext3_force_commit(struct super_block *sb)
/* Force the running and committing transactions to commit, and wait on the commit. */ int ext3_force_commit(struct super_block *sb)
{ journal_t *journal; int ret; if (sb->s_flags & MS_RDONLY) return 0; journal = EXT3_SB(sb)->s_journal; ret = ext3_journal_force_commit(journal); return ret; }
robutest/uclinux
C++
GPL-2.0
60
/* Set slave arbitration type of the specified slave. */
void matrix_set_slave_arbitration_type(uint32_t ul_id, arbitration_type_t type)
/* Set slave arbitration type of the specified slave. */ void matrix_set_slave_arbitration_type(uint32_t ul_id, arbitration_type_t type)
{ Matrix *p_matrix = MATRIX; volatile uint32_t ul_reg; ul_reg = p_matrix->MATRIX_SCFG[ul_id] & (~MATRIX_SCFG_ARBT_Msk); p_matrix->MATRIX_SCFG[ul_id] = ul_reg | (uint32_t)type; }
remotemcu/remcu-chip-sdks
C++
null
436
/* Please refer to the official documentation for function purpose and expected parameters. */
int ph7_result_bool(ph7_context *pCtx, int iBool)
/* Please refer to the official documentation for function purpose and expected parameters. */ int ph7_result_bool(ph7_context *pCtx, int iBool)
{ return ph7_value_int64(pCtx->pRet,iValue); }
pikasTech/PikaPython
C++
MIT License
1,403
/* Setthe source address of the specified dma channel. */
en_result_t Dma_SetSourceAddress(en_dma_channel_t enCh, uint32_t u32Address)
/* Setthe source address of the specified dma channel. */ en_result_t Dma_SetSourceAddress(en_dma_channel_t enCh, uint32_t u32Address)
{ ASSERT(IS_VALID_CH(enCh)); if(!IS_VALID_CH(enCh)) { return ErrorInvalidParameter; } if(enCh == DmaCh0) { M0P_DMAC->SRCADR0_f.SRCADR = u32Address; } else { M0P_DMAC->SRCADR1_f.SRCADR = u32Address;; } return Ok; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Make the refreshing from an object. Draw all its children and the youngers too. */
static void lv_refr_obj_and_children(lv_obj_t *top_p, const lv_area_t *mask_p)
/* Make the refreshing from an object. Draw all its children and the youngers too. */ static void lv_refr_obj_and_children(lv_obj_t *top_p, const lv_area_t *mask_p)
{ if(top_p == NULL) top_p = lv_scr_act(); lv_refr_obj(top_p, mask_p); lv_obj_t * par; lv_obj_t * i; lv_obj_t * border_p = top_p; par = lv_obj_get_parent(top_p); while(par != NULL) { i = lv_ll_get_prev(&(par->child_ll), border_p); while(i != NULL) { lv_refr_obj(i, ...
RavenSystem/esp-homekit-devices
C++
Other
2,577
/* Returns 1 if any slot in the node has this tag set. Otherwise returns 0. */
static int any_tag_set(struct radix_tree_node *node, unsigned int tag)
/* Returns 1 if any slot in the node has this tag set. Otherwise returns 0. */ static int any_tag_set(struct radix_tree_node *node, unsigned int tag)
{ int idx; for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) { if (node->tags[tag][idx]) return 1; } return 0; }
robutest/uclinux
C++
GPL-2.0
60
/* Allocate a circular buffer and all associated memory. */
static struct pl2303_buf* pl2303_buf_alloc(unsigned int size)
/* Allocate a circular buffer and all associated memory. */ static struct pl2303_buf* pl2303_buf_alloc(unsigned int size)
{ struct pl2303_buf *pb; if (size == 0) return NULL; pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); if (pb == NULL) return NULL; pb->buf_buf = kmalloc(size, GFP_KERNEL); if (pb->buf_buf == NULL) { kfree(pb); return NULL; } pb->buf_size = size; pb->buf_get = pb->buf_put = pb->buf_buf; return pb; ...
robutest/uclinux
C++
GPL-2.0
60
/* Resets the slave hardware state machine. According to documentation, after disabling slave to rest the slave hardware state machine, the register configuration remains unchanged. */
static void I2C_SlaveInternalStateMachineReset(I2C_Type *base)
/* Resets the slave hardware state machine. According to documentation, after disabling slave to rest the slave hardware state machine, the register configuration remains unchanged. */ static void I2C_SlaveInternalStateMachineReset(I2C_Type *base)
{ I2C_SlaveEnable(base, false); }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* This function returns the CA-supplied certificate revocation list data which was currently set in the specified TLS object. */
EFI_STATUS EFIAPI TlsGetCertRevocationList(OUT VOID *Data, IN OUT UINTN *DataSize)
/* This function returns the CA-supplied certificate revocation list data which was currently set in the specified TLS object. */ EFI_STATUS EFIAPI TlsGetCertRevocationList(OUT VOID *Data, IN OUT UINTN *DataSize)
{ CALL_CRYPTO_SERVICE (TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED); }
tianocore/edk2
C++
Other
4,240
/* Enables the interrupt mask for a specific port pin. */
void gpioIntEnable(uint32_t portNum, uint32_t bitPos)
/* Enables the interrupt mask for a specific port pin. */ void gpioIntEnable(uint32_t portNum, uint32_t bitPos)
{ if (!_gpioInitialised) gpioInit(); switch (portNum) { case 0: GPIO_GPIO0IE |= (0x1<<bitPos); break; case 1: GPIO_GPIO1IE |= (0x1<<bitPos); break; case 2: GPIO_GPIO2IE |= (0x1<<bitPos); break; case 3: GPIO_GPIO3IE |= (0x1<<bitPos); break; defaul...
microbuilder/LPC1343CodeBase
C++
Other
73
/* Sets the probe callback corresponding to one tracepoint. */
static void set_tracepoint(struct tracepoint_entry **entry, struct tracepoint *elem, int active)
/* Sets the probe callback corresponding to one tracepoint. */ static void set_tracepoint(struct tracepoint_entry **entry, struct tracepoint *elem, int active)
{ WARN_ON(strcmp((*entry)->name, elem->name) != 0); if (elem->regfunc && !elem->state && active) elem->regfunc(); else if (elem->unregfunc && elem->state && !active) elem->unregfunc(); rcu_assign_pointer(elem->funcs, (*entry)->funcs); elem->state = active; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Returns a string by the given string offset. */
CONST CHAR8* EFIAPI FdtGetString(IN CONST VOID *Fdt, IN INT32 StrOffset, IN INT32 *Length OPTIONAL)
/* Returns a string by the given string offset. */ CONST CHAR8* EFIAPI FdtGetString(IN CONST VOID *Fdt, IN INT32 StrOffset, IN INT32 *Length OPTIONAL)
{ return fdt_get_string (Fdt, StrOffset, Length); }
tianocore/edk2
C++
Other
4,240
/* The reference to the input task_struct is released. */
static struct task_struct* next_tid(struct task_struct *start)
/* The reference to the input task_struct is released. */ static struct task_struct* next_tid(struct task_struct *start)
{ struct task_struct *pos = NULL; rcu_read_lock(); if (pid_alive(start)) { pos = next_thread(start); if (thread_group_leader(pos)) pos = NULL; else get_task_struct(pos); } rcu_read_unlock(); put_task_struct(start); return pos; }
robutest/uclinux
C++
GPL-2.0
60
/* This function hash the input string 'name' using the ELF hash function for strings. */
static __u32 hash(const char *name)
/* This function hash the input string 'name' using the ELF hash function for strings. */ static __u32 hash(const char *name)
{ __u32 h = 0; __u32 g; while(*name) { h = (h<<4) + *name++; if ((g = (h & 0xf0000000))) h ^=g>>24; h &=~g; } return h; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Enable the UART. Enable the UART. The Rx and Tx lines are also enabled. */
void uart_enable(uint32_t uart)
/* Enable the UART. Enable the UART. The Rx and Tx lines are also enabled. */ void uart_enable(uint32_t uart)
{ UART_CTL(uart) |= (UART_CTL_UARTEN | UART_CTL_RXE | UART_CTL_TXE); }
insane-adding-machines/unicore-mx
C++
GNU General Public License v3.0
50
/* Allocate a new USB request structure appropriate for the specified endpoint */
static struct usb_request* s3c_hsotg_ep_alloc_request(struct usb_ep *ep, gfp_t flags)
/* Allocate a new USB request structure appropriate for the specified endpoint */ static struct usb_request* s3c_hsotg_ep_alloc_request(struct usb_ep *ep, gfp_t flags)
{ struct s3c_hsotg_req *req; req = kzalloc(sizeof(struct s3c_hsotg_req), flags); if (!req) return NULL; INIT_LIST_HEAD(&req->queue); return &req->req; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* Initializes peripherals used by the I2C Humidity Sensor driver. */
uint32_t BSP_HSENSOR_Init(void)
/* Initializes peripherals used by the I2C Humidity Sensor driver. */ uint32_t BSP_HSENSOR_Init(void)
{ uint32_t ret; if(HTS221_H_Drv.ReadID(HTS221_I2C_ADDRESS) != HTS221_WHO_AM_I_VAL) { ret = HSENSOR_ERROR; } else { Hsensor_drv = &HTS221_H_Drv; Hsensor_drv->Init(HTS221_I2C_ADDRESS); ret = HSENSOR_OK; } return ret; }
eclipse-threadx/getting-started
C++
Other
310
/* Description: Checks the given categories against the given DOI definition and returns a negative value if any of the categories do not have a valid mapping and a zero value if all of the categories are valid. */
static int cipso_v4_map_cat_enum_valid(const struct cipso_v4_doi *doi_def, const unsigned char *enumcat, u32 enumcat_len)
/* Description: Checks the given categories against the given DOI definition and returns a negative value if any of the categories do not have a valid mapping and a zero value if all of the categories are valid. */ static int cipso_v4_map_cat_enum_valid(const struct cipso_v4_doi *doi_def, const unsigned char *enumcat,...
{ u16 cat; int cat_prev = -1; u32 iter; if (doi_def->type != CIPSO_V4_MAP_PASS || enumcat_len & 0x01) return -EFAULT; for (iter = 0; iter < enumcat_len; iter += 2) { cat = get_unaligned_be16(&enumcat[iter]); if (cat <= cat_prev) return -EFAULT; cat_prev = cat; } return 0; }
EmcraftSystems/linux-emcraft
C++
Other
266
/* hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter @val: Parameter value (numeric) */
static int __init hvc_iucv_config(char *val)
/* hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter @val: Parameter value (numeric) */ static int __init hvc_iucv_config(char *val)
{ return strict_strtoul(val, 10, &hvc_iucv_devices); }
robutest/uclinux
C++
GPL-2.0
60
/* Event notification function to set Hot Plug controller status. */
VOID EFIAPI PciHPCInitialized(IN EFI_EVENT Event, IN VOID *Context)
/* Event notification function to set Hot Plug controller status. */ VOID EFIAPI PciHPCInitialized(IN EFI_EVENT Event, IN VOID *Context)
{ ROOT_HPC_DATA *HpcData; HpcData = (ROOT_HPC_DATA *)Context; HpcData->Initialized = TRUE; }
tianocore/edk2
C++
Other
4,240
/* Verify a region of NAND flash. Reads NAND in page-sized chunks and verifies the contents against the contents of a buffer. The offset into the NAND must be page-aligned, and the function doesn't handle skipping bad blocks. */
int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf)
/* Verify a region of NAND flash. Reads NAND in page-sized chunks and verifies the contents against the contents of a buffer. The offset into the NAND must be page-aligned, and the function doesn't handle skipping bad blocks. */ int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf)
{ int rval = 0; size_t verofs; size_t verlen = mtd->writesize; uint8_t *verbuf = memalign(ARCH_DMA_MINALIGN, verlen); if (!verbuf) return -ENOMEM; for (verofs = ofs; verofs < ofs + len; verofs += verlen, buf += verlen) { verlen = min(mtd->writesize, (uint32_t)(ofs + len - verofs)); rval = nand_read(mt...
4ms/stm32mp1-baremetal
C++
Other
137
/* when btree blocks are allocated, they have some corresponding bits set for them in one of two extent_io trees. This is used to make sure all of those extents are on disk for transaction or log commit */
int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, int mark)
/* when btree blocks are allocated, they have some corresponding bits set for them in one of two extent_io trees. This is used to make sure all of those extents are on disk for transaction or log commit */ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, int mark)
{ int ret; int ret2; ret = btrfs_write_marked_extents(root, dirty_pages, mark); ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark); return ret || ret2; }
robutest/uclinux
C++
GPL-2.0
60
/* Big-endian to little-endian byte-swapping/bitmaps by David S. Miller ( */
static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
/* Big-endian to little-endian byte-swapping/bitmaps by David S. Miller ( */ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
{ ext2_clear_super_error(sb); es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); es->s_wtime = cpu_to_le32(get_seconds()); mark_buffer_dirty(EXT2_SB(sb)->s_sbh); sync_dirty_buffer(EXT2_SB(sb)->s_sbh); sb->s_dirt = 0; }
robutest/uclinux
C++
GPL-2.0
60
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */
void FLEXIO_I2S_TransferAbortSend(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
/* param base Pointer to FLEXIO_I2S_Type structure. param handle Pointer to flexio_i2s_handle_t structure which stores the transfer state */ void FLEXIO_I2S_TransferAbortSend(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
{ assert(handle); FLEXIO_I2S_DisableInterrupts(base, kFLEXIO_I2S_TxDataRegEmptyInterruptEnable); handle->state = kFLEXIO_I2S_Idle; memset(handle->queue, 0, sizeof(flexio_i2s_transfer_t) * FLEXIO_I2S_XFER_QUEUE_SIZE); handle->queueDriver = 0; handle->queueUser = 0; }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535
/* Initialize the header of the iSCSI Boot Firmware Table. */
VOID IScsiInitIbfTableHeader(OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header, IN UINT8 *OemId, IN UINT64 *OemTableId)
/* Initialize the header of the iSCSI Boot Firmware Table. */ VOID IScsiInitIbfTableHeader(OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header, IN UINT8 *OemId, IN UINT64 *OemTableId)
{ Header->Signature = EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE; Header->Length = IBFT_HEAP_OFFSET; Header->Revision = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION; Header->Checksum = 0; CopyMem (Header->OemId, OemId, sizeof (Header->OemId)); CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT...
tianocore/edk2
C++
Other
4,240
/* Perform a blocking write of 16 words of data to the SHA/MD5 module. */
void SHAMD5DataWrite(uint32_t ui32Base, uint32_t *pui32Src)
/* Perform a blocking write of 16 words of data to the SHA/MD5 module. */ void SHAMD5DataWrite(uint32_t ui32Base, uint32_t *pui32Src)
{ uint32_t ui32Counter; ASSERT(ui32Base == SHAMD5_BASE); while ((HWREG(ui32Base + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_INPUT_READY) == 0) { } for (ui32Counter = 0; ui32Counter < 64; ui32Counter += 4) { HWREG(ui32Base + SHAMD5_O_DATA_0_IN + ui32Counter) = *pui32Src++; } }
RT-Thread/rt-thread
C++
Apache License 2.0
9,535