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
|
|---|---|---|---|---|---|---|---|
/* Request the memory region(s) being used by 'port' */
|
static int ks8695uart_request_port(struct uart_port *port)
|
/* Request the memory region(s) being used by 'port' */
static int ks8695uart_request_port(struct uart_port *port)
|
{
return request_mem_region(port->mapbase, UART_PORT_SIZE,
"serial_ks8695") != NULL ? 0 : -EBUSY;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Associate a particular clock with a function (eg, "uart") and device. The drivers can then request the same 'function' with several different devices and not care about which clock name to use. */
|
void __init at91_clock_associate(const char *id, struct device *dev, const char *func)
|
/* Associate a particular clock with a function (eg, "uart") and device. The drivers can then request the same 'function' with several different devices and not care about which clock name to use. */
void __init at91_clock_associate(const char *id, struct device *dev, const char *func)
|
{
struct clk *clk = clk_get(NULL, id);
if (!dev || !clk || !IS_ERR(clk_get(dev, func)))
return;
clk->function = func;
clk->dev = dev;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* stmmac_init_module - Entry point for the driver Description: This function is the entry point for the driver. */
|
static int __init stmmac_init_module(void)
|
/* stmmac_init_module - Entry point for the driver Description: This function is the entry point for the driver. */
static int __init stmmac_init_module(void)
|
{
int ret;
if (platform_driver_register(&stmmacphy_driver)) {
pr_err("No PHY devices registered!\n");
return -ENODEV;
}
ret = platform_driver_register(&stmmac_driver);
return ret;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* st33zp24_i2c_read Recv byte from the TIS register according to the ST33ZP24 I2C protocol. */
|
static int st33zp24_i2c_read(struct udevice *dev, u8 tpm_register, u8 *tpm_data, size_t tpm_size)
|
/* st33zp24_i2c_read Recv byte from the TIS register according to the ST33ZP24 I2C protocol. */
static int st33zp24_i2c_read(struct udevice *dev, u8 tpm_register, u8 *tpm_data, size_t tpm_size)
|
{
return st33zp24_i2c_read8_reg(dev, tpm_register, tpm_data, tpm_size);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
|
UINT32 EFIAPI S3PciSegmentAnd32(IN UINT64 Address, IN UINT32 AndData)
|
/* If any reserved bits in Address are set, then ASSERT(). If Address is not aligned on a 32-bit boundary, then ASSERT(). */
UINT32 EFIAPI S3PciSegmentAnd32(IN UINT64 Address, IN UINT32 AndData)
|
{
return InternalSavePciSegmentWrite32ValueToBootScript (Address, PciSegmentAnd32 (Address, AndData));
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* SmmCpuRendezvousLib need to support MM_STANDALONE and DXE_SMM_DRIVER driver. So do not use library constructor to locate the protocol. */
|
EFI_STATUS EFIAPI SmmCpuRendezvousProtocolNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
|
/* SmmCpuRendezvousLib need to support MM_STANDALONE and DXE_SMM_DRIVER driver. So do not use library constructor to locate the protocol. */
EFI_STATUS EFIAPI SmmCpuRendezvousProtocolNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
|
{
EFI_STATUS Status;
Status = gMmst->MmLocateProtocol (
&gEdkiiSmmCpuRendezvousProtocolGuid,
NULL,
(VOID **)&mSmmCpuRendezvous
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Returns the interrupt number for a given EPI base address. */
|
static uint32_t _EPIIntNumberGet(uint32_t ui32Base)
|
/* Returns the interrupt number for a given EPI base address. */
static uint32_t _EPIIntNumberGet(uint32_t ui32Base)
|
{
uint32_t ui32Int;
ASSERT(ui32Base == EPI0_BASE);
ui32Int = 0;
if(CLASS_IS_TM4C129)
{
ui32Int = INT_EPI0_TM4C129;
}
return(ui32Int);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Update a reservations state, and schedule an update of the transmitted DRP IEs. */
|
static void uwb_rsv_state_update(struct uwb_rsv *rsv, enum uwb_rsv_state new_state)
|
/* Update a reservations state, and schedule an update of the transmitted DRP IEs. */
static void uwb_rsv_state_update(struct uwb_rsv *rsv, enum uwb_rsv_state new_state)
|
{
rsv->state = new_state;
rsv->ie_valid = false;
uwb_rsv_dump("SU", rsv);
uwb_rsv_stroke_timer(rsv);
uwb_rsv_sched_update(rsv->rc);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function will initialize idle thread, then start it. */
|
void rt_thread_idle_init(void)
|
/* This function will initialize idle thread, then start it. */
void rt_thread_idle_init(void)
|
{
rt_thread_init(&idle,
"tidle",
rt_thread_idle_entry,
RT_NULL,
&rt_thread_stack[0],
sizeof(rt_thread_stack),
RT_THREAD_PRIORITY_MAX - 1,
32);
rt_thread_startup(&idle);
}
|
armink/FreeModbus_Slave-Master-RTT-STM32
|
C++
|
Other
| 1,477
|
/* 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 GPIODirModeSet(unsigned long ulPort, unsigned char ucPins, unsigned long ulPinIO)
|
/* 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 GPIODirModeSet(unsigned long ulPort, unsigned char ucPins, unsigned long ulPinIO)
|
{
ASSERT(GPIOBaseValid(ulPort));
ASSERT((ulPinIO == GPIO_DIR_MODE_IN) || (ulPinIO == GPIO_DIR_MODE_OUT));
HWREG(ulPort + GPIO_O_GPIO_DIR) = ((ulPinIO & 1) ?
(HWREG(ulPort + GPIO_O_GPIO_DIR) | ucPins) :
(HWREG(ulPort + GPIO_O_GPIO_DIR) & ~(ucPins)));
}
|
micropython/micropython
|
C++
|
Other
| 18,334
|
/* Register this by name; it's called from the Ubertooth dissector. */
|
static gint dissect_bluetooth_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
/* Register this by name; it's called from the Ubertooth dissector. */
static gint dissect_bluetooth_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
{
bluetooth_data_t *bluetooth_data;
bluetooth_data = dissect_bluetooth_common(tvb, pinfo, tree);
bluetooth_data->previous_protocol_data_type = BT_PD_UBERTOOTH_DATA;
bluetooth_data->previous_protocol_data.ubertooth_data = (ubertooth_data_t *)data;
call_dissector(btle_handle, tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This API sets FIFO full interrupt of the sensor.This interrupt occurs when the FIFO is full and the next full data sample would cause a FIFO overflow, which may delete the old samples. */
|
static int8_t set_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
|
/* This API sets FIFO full interrupt of the sensor.This interrupt occurs when the FIFO is full and the next full data sample would cause a FIFO overflow, which may delete the old samples. */
static int8_t set_fifo_full_int(const struct bmi160_int_settg *int_config, const struct bmi160_dev *dev)
|
{
int8_t rslt = BMI160_OK;
if ((dev == NULL) || (dev->delay_ms == NULL))
{
rslt = BMI160_E_NULL_PTR;
}
else
{
rslt = enable_fifo_full_int(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = set_intr_pin_config(int_config, dev);
if (rslt == BMI160_OK)
{
rslt = map_hardware_interrupt(int_config, dev);
}
}
}
return rslt;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* convert from the byte/word on usb descriptor to the zero-based integer */
|
static int convert_signed_value(struct usb_mixer_elem_info *cval, int val)
|
/* convert from the byte/word on usb descriptor to the zero-based integer */
static int convert_signed_value(struct usb_mixer_elem_info *cval, int val)
|
{
switch (cval->val_type) {
case USB_MIXER_BOOLEAN:
return !!val;
case USB_MIXER_INV_BOOLEAN:
return !val;
case USB_MIXER_U8:
val &= 0xff;
break;
case USB_MIXER_S8:
val &= 0xff;
if (val >= 0x80)
val -= 0x100;
break;
case USB_MIXER_U16:
val &= 0xffff;
break;
case USB_MIXER_S16:
val &= 0xffff;
if (val >= 0x8000)
val -= 0x10000;
break;
}
return val;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
|
EFI_STATUS EFIAPI UsbNcmComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
/* This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. */
EFI_STATUS EFIAPI UsbNcmComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
|
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
gUsbNcmDriverNameTable,
DriverName,
(BOOLEAN)(This == &gUsbNcmComponentName)
);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Attach our controls and configure the necessary codec mappings for our sound card instance. */
|
static int simtec_hermes_init(struct snd_soc_codec *codec)
|
/* Attach our controls and configure the necessary codec mappings for our sound card instance. */
static int simtec_hermes_init(struct snd_soc_codec *codec)
|
{
snd_soc_dapm_new_controls(codec, dapm_widgets,
ARRAY_SIZE(dapm_widgets));
snd_soc_dapm_add_routes(codec, base_map, ARRAY_SIZE(base_map));
snd_soc_dapm_enable_pin(codec, "Headphone Jack");
snd_soc_dapm_enable_pin(codec, "Line In");
snd_soc_dapm_enable_pin(codec, "Line Out");
snd_soc_dapm_enable_pin(codec, "Mic Jack");
simtec_audio_init(codec);
snd_soc_dapm_sync(codec);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Init the Comp n Interrupt Callback function.
param of pfnCallback */
|
void xACMPIntCallbackInit(unsigned long ulBase, unsigned long ulCompID, xtEventCallback pfnCallback)
|
/* Init the Comp n Interrupt Callback function.
param of pfnCallback */
void xACMPIntCallbackInit(unsigned long ulBase, unsigned long ulCompID, xtEventCallback pfnCallback)
|
{
unsigned long Base;
xASSERT((ulBase == ACMP_BASE));
xASSERT((ulCompID == xACMP_0) || (ulCompID == xACMP_1));
Base = ((ulBase == ACMP_BASE) ? 0 : 2);
switch(ulCompID)
{
case xACMP_0:
{
g_pfnACMPHandlerCallbacks[Base+0] = pfnCallback;
break;
}
case xACMP_1:
{
g_pfnACMPHandlerCallbacks[Base+1] = pfnCallback;
break;
}
}
}
|
coocox/cox
|
C++
|
Berkeley Software Distribution (BSD)
| 104
|
/* free_inodes - free RB-tree of inodes. @fsckd: FS checking information */
|
static void free_inodes(struct fsck_data *fsckd)
|
/* free_inodes - free RB-tree of inodes. @fsckd: FS checking information */
static void free_inodes(struct fsck_data *fsckd)
|
{
struct fsck_inode *fscki, *n;
rbtree_postorder_for_each_entry_safe(fscki, n, &fsckd->inodes, rb)
kfree(fscki);
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* This function starts atomic LEB change operation. Returns zero in case of success and a negative error code in case of failure. */
|
int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, const struct ubi_leb_change_req *req)
|
/* This function starts atomic LEB change operation. Returns zero in case of success and a negative error code in case of failure. */
int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, const struct ubi_leb_change_req *req)
|
{
ubi_assert(!vol->updating && !vol->changing_leb);
dbg_gen("start changing LEB %d:%d, %u bytes",
vol->vol_id, req->lnum, req->bytes);
if (req->bytes == 0)
return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0);
vol->upd_bytes = req->bytes;
vol->upd_received = 0;
vol->changing_leb = 1;
vol->ch_lnum = req->lnum;
vol->upd_buf = vmalloc(req->bytes);
if (!vol->upd_buf)
return -ENOMEM;
return 0;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Mask off any voltages we don't support and select the lowest voltage */
|
rt_uint32_t mmcsd_select_voltage(struct rt_mmcsd_host *host, rt_uint32_t ocr)
|
/* Mask off any voltages we don't support and select the lowest voltage */
rt_uint32_t mmcsd_select_voltage(struct rt_mmcsd_host *host, rt_uint32_t ocr)
|
{
int bit;
extern int __rt_ffs(int value);
ocr &= host->valid_ocr;
bit = __rt_ffs(ocr);
if (bit)
{
bit -= 1;
ocr &= 3 << bit;
host->io_cfg.vdd = bit;
mmcsd_set_iocfg(host);
}
else
{
LOG_W("host doesn't support card's voltages!");
ocr = 0;
}
return ocr;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* param handle codec handle. param module audio codec module. param powerOn true is power on, false is power down. return kStatus_Success is success, else configure failed. */
|
status_t HAL_CODEC_WM8904_SetPower(void *handle, uint32_t module, bool powerOn)
|
/* param handle codec handle. param module audio codec module. param powerOn true is power on, false is power down. return kStatus_Success is success, else configure failed. */
status_t HAL_CODEC_WM8904_SetPower(void *handle, uint32_t module, bool powerOn)
|
{
assert(handle != NULL);
status_t ret = kStatus_Success;
ret = WM8904_SetModulePower((wm8904_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
HAL_WM8904_MAP_MODULE((codec_module_t)module), powerOn);
if (ret != kStatus_Success)
{
return ret;
}
return kStatus_Success;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* PcdCpuApStackSize must be configured with value taking the Guard page into account. */
|
VOID EFIAPI GetStackBase(IN OUT VOID *Buffer)
|
/* PcdCpuApStackSize must be configured with value taking the Guard page into account. */
VOID EFIAPI GetStackBase(IN OUT VOID *Buffer)
|
{
EFI_PHYSICAL_ADDRESS StackBase;
UINTN Index;
MpInitLibWhoAmI (&Index);
StackBase = (EFI_PHYSICAL_ADDRESS)(UINTN)&StackBase;
StackBase += BASE_4KB;
StackBase &= ~((EFI_PHYSICAL_ADDRESS)BASE_4KB - 1);
StackBase -= PcdGet32 (PcdCpuApStackSize);
*((EFI_PHYSICAL_ADDRESS *)Buffer + Index) = StackBase;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* BACnetPropertyValue ::= SEQUENCE { PropertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigned OPTIONAL, */
|
static guint fBACnetPropertyValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
/* BACnetPropertyValue ::= SEQUENCE { PropertyIdentifier BACnetPropertyIdentifier, propertyArrayIndex Unsigned OPTIONAL, */
static guint fBACnetPropertyValue(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset)
|
{
guint lastoffset = 0;
guint8 tag_no, tag_info;
guint32 lvt;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
lastoffset = offset;
offset = fPropertyIdentifierValue(tvb, pinfo, tree, offset, 0);
if (offset > lastoffset) {
fTagHeader(tvb, pinfo, offset, &tag_no, &tag_info, &lvt);
if (tag_is_context_specific(tag_info) && (tag_no == 3))
offset = fUnsignedTag(tvb, pinfo, tree, offset, "Priority: ");
}
if (offset == lastoffset) break;
}
return offset;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Get the MAC Address bit from the specified position */
|
static unsigned get_bit(const uint8_t *mac, unsigned bit)
|
/* Get the MAC Address bit from the specified position */
static unsigned get_bit(const uint8_t *mac, unsigned bit)
|
{
unsigned byte;
byte = mac[bit / 8];
byte >>= (bit & 0x7);
byte &= 1;
return byte;
}
|
ve3wwg/teensy3_qemu
|
C++
|
Other
| 15
|
/* If List is NULL, then ASSERT(). If Node is NULL, then ASSERT(). If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or */
|
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
|
/* If List is NULL, then ASSERT(). If Node is NULL, then ASSERT(). If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or */
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
|
{
ASSERT_VERIFY_NODE_IN_VALID_LIST (List, Node, TRUE);
return (BOOLEAN)(Node == List);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This routine must be called by kernel at boot time */
|
static int __init riscom8_init(void)
|
/* This routine must be called by kernel at boot time */
static int __init riscom8_init(void)
|
{
int i;
int found = 0;
printk(banner);
if (rc_init_drivers())
return -EIO;
for (i = 0; i < RC_NBOARD; i++)
if (rc_board[i].base && !rc_probe(&rc_board[i]))
found++;
if (!found) {
rc_release_drivers();
printk(no_boards_msg);
return -EIO;
}
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Receives a byte that has been sent to the I2C Master. */
|
unsigned long I2CMasterDataGet(unsigned long ulBase)
|
/* Receives a byte that has been sent to the I2C Master. */
unsigned long I2CMasterDataGet(unsigned long ulBase)
|
{
ASSERT(I2CMasterBaseValid(ulBase));
return(HWREG(ulBase + I2C_O_MDR));
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Vitual COM Port retrieve communication settings.
The function retrieves communication settings of the port used as the Virtual COM Port. */
|
int32_t USBD_CDC_ACM_PortGetLineCoding(CDC_LINE_CODING *line_coding)
|
/* Vitual COM Port retrieve communication settings.
The function retrieves communication settings of the port used as the Virtual COM Port. */
int32_t USBD_CDC_ACM_PortGetLineCoding(CDC_LINE_CODING *line_coding)
|
{
line_coding->dwDTERate = UART_Config.Baudrate;
line_coding->bDataBits = UART_Config.DataBits;
line_coding->bParityType = UART_Config.Parity;
line_coding->bCharFormat = UART_Config.StopBits;
return (1);
}
|
ARMmbed/DAPLink
|
C++
|
Apache License 2.0
| 2,140
|
/* Calculate how many blocks we need for the new attribute, */
|
int xfs_attr_calc_size(struct xfs_inode *ip, int namelen, int valuelen, int *local)
|
/* Calculate how many blocks we need for the new attribute, */
int xfs_attr_calc_size(struct xfs_inode *ip, int namelen, int valuelen, int *local)
|
{
struct xfs_mount *mp = ip->i_mount;
int size;
int nblks;
size = xfs_attr_leaf_newentsize(namelen, valuelen,
mp->m_sb.sb_blocksize, local);
nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
if (*local) {
if (size > (mp->m_sb.sb_blocksize >> 1)) {
nblks *= 2;
}
} else {
uint dblocks = XFS_B_TO_FSB(mp, valuelen);
nblks += dblocks;
nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK);
}
return nblks;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Mark all values stored in marked open upvalues from non-marked threads. (Values from marked threads were already marked when traversing the thread.) Remove from the list threads that no longer have upvalues and not-marked threads. */
|
static void remarkupvals(global_State *g)
|
/* Mark all values stored in marked open upvalues from non-marked threads. (Values from marked threads were already marked when traversing the thread.) Remove from the list threads that no longer have upvalues and not-marked threads. */
static void remarkupvals(global_State *g)
|
{
lua_assert(!isblack(thread));
if (isgray(thread) && thread->openupval != NULL)
p = &thread->twups;
else {
UpVal *uv;
*p = thread->twups;
thread->twups = thread;
for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) {
if (uv->u.open.touched) {
markvalue(g, uv->v);
uv->u.open.touched = 0;
}
}
}
}
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
/* Everything gets deallocated except the master jpeg_compress_struct itself and the error manager struct. Both of these are supplied by the application and must be freed, if necessary, by the application. (Often they are on the stack and so don't need to be freed anyway.) Closing a data source or destination, if necessary, is the application's responsibility. */
|
jpeg_destroy(j_common_ptr cinfo)
|
/* Everything gets deallocated except the master jpeg_compress_struct itself and the error manager struct. Both of these are supplied by the application and must be freed, if necessary, by the application. (Often they are on the stack and so don't need to be freed anyway.) Closing a data source or destination, if necessary, is the application's responsibility. */
jpeg_destroy(j_common_ptr cinfo)
|
{
if (cinfo->mem != NULL)
(*cinfo->mem->self_destruct) (cinfo);
cinfo->mem = NULL;
cinfo->global_state = 0;
}
|
nanoframework/nf-interpreter
|
C++
|
MIT License
| 293
|
/* <status> is (td_status(td) & 0xF60000), a.k.a. uhci_status_bits(td_status(td)). Note: <status> does not include the TD_CTRL_NAK bit. <dir_out> is True for output TDs and False for input TDs. */
|
static int uhci_map_status(int status, int dir_out)
|
/* <status> is (td_status(td) & 0xF60000), a.k.a. uhci_status_bits(td_status(td)). Note: <status> does not include the TD_CTRL_NAK bit. <dir_out> is True for output TDs and False for input TDs. */
static int uhci_map_status(int status, int dir_out)
|
{
if (!status)
return 0;
if (status & TD_CTRL_BITSTUFF)
return -EPROTO;
if (status & TD_CTRL_CRCTIMEO) {
if (dir_out)
return -EPROTO;
else
return -EILSEQ;
}
if (status & TD_CTRL_BABBLE)
return -EOVERFLOW;
if (status & TD_CTRL_DBUFERR)
return -ENOSR;
if (status & TD_CTRL_STALLED)
return -EPIPE;
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Created on: 15 feb. 2019 Author: Daniel Mårtensson Find the dot product of two vectors A and B with the same size: row x 1 MATLAB code: */
|
double dot(double *A, double *B, int row)
|
/* Created on: 15 feb. 2019 Author: Daniel Mårtensson Find the dot product of two vectors A and B with the same size: row x 1 MATLAB code: */
double dot(double *A, double *B, int row)
|
{
sum += (*(A + i)) * (*(B + i));
}
return sum;
}
|
DanielMartensson/EmbeddedLapack
|
C++
|
MIT License
| 129
|
/* Acknowledge the IRQ using either the PCI host bridge's interrupt acknowledge feature or poll. How i8259_init() is called determines which is called. It should be noted that polling is broken on some IBM and Motorola PReP boxes so we must use the int-ack feature on them. */
|
unsigned int i8259_irq(void)
|
/* Acknowledge the IRQ using either the PCI host bridge's interrupt acknowledge feature or poll. How i8259_init() is called determines which is called. It should be noted that polling is broken on some IBM and Motorola PReP boxes so we must use the int-ack feature on them. */
unsigned int i8259_irq(void)
|
{
int irq;
int lock = 0;
if (pci_intack)
irq = readb(pci_intack);
else {
spin_lock(&i8259_lock);
lock = 1;
outb(0x0C, 0x20);
irq = inb(0x20) & 7;
if (irq == 2 ) {
outb(0x0C, 0xA0);
irq = (inb(0xA0) & 7) + 8;
}
}
if (irq == 7) {
if (!pci_intack)
outb(0x0B, 0x20);
if(~inb(0x20) & 0x80)
irq = NO_IRQ;
} else if (irq == 0xff)
irq = NO_IRQ;
if (lock)
spin_unlock(&i8259_lock);
return irq;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Performs an atomic compare exchange operation to lock semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
|
STATIC UINT32 InternalLockdownSemaphore(IN OUT volatile UINT32 *Sem)
|
/* Performs an atomic compare exchange operation to lock semaphore. The compare exchange operation must be performed using MP safe mechanisms. */
STATIC UINT32 InternalLockdownSemaphore(IN OUT volatile UINT32 *Sem)
|
{
UINT32 Value;
do {
Value = *Sem;
} while (InterlockedCompareExchange32 (
(UINT32 *)Sem,
Value,
(UINT32)-1
) != Value);
return Value;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Shutdown the TLS connection without releasing the resources, meaning a new connection can be started without calling TlsNew() and without setting certificates etc. */
|
EFI_STATUS EFIAPI CryptoServiceTlsShutdown(IN VOID *Tls)
|
/* Shutdown the TLS connection without releasing the resources, meaning a new connection can be started without calling TlsNew() and without setting certificates etc. */
EFI_STATUS EFIAPI CryptoServiceTlsShutdown(IN VOID *Tls)
|
{
return CALL_BASECRYPTLIB (Tls.Services.Shutdown, TlsShutdown, (Tls), EFI_UNSUPPORTED);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* mmap support for full problem state area . */
|
static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
|
/* mmap support for full problem state area . */
static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
|
{
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
vma->vm_flags |= VM_IO | VM_PFNMAP;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_ops = &spufs_psmap_mmap_vmops;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* The function common_CALL is the default implementation for the function pointer CALL in struct k_clock. */
|
static int common_clock_getres(const clockid_t which_clock, struct timespec *tp)
|
/* The function common_CALL is the default implementation for the function pointer CALL in struct k_clock. */
static int common_clock_getres(const clockid_t which_clock, struct timespec *tp)
|
{
tp->tv_sec = 0;
tp->tv_nsec = posix_clocks[which_clock].res;
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* ADC Enable an External Trigger for Injected Channels.
This enables an external trigger for set of defined injected channels, and sets the polarity of the trigger event: rising or falling edge or both. */
|
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger, uint32_t polarity)
|
/* ADC Enable an External Trigger for Injected Channels.
This enables an external trigger for set of defined injected channels, and sets the polarity of the trigger event: rising or falling edge or both. */
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger, uint32_t polarity)
|
{
uint32_t reg32 = ADC_CR2(adc);
reg32 &= ~(ADC_CR2_JEXTSEL_MASK | ADC_CR2_JEXTEN_MASK);
reg32 |= (trigger | polarity);
ADC_CR2(adc) = reg32;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Deinitializes the SYSCFG registers to their default reset values. */
|
void SYSCFG_DeInit(void)
|
/* Deinitializes the SYSCFG registers to their default reset values. */
void SYSCFG_DeInit(void)
|
{
SYSCFG->CFGR &= SYSCFG_CFGR_MEM_MODE;
SYSCFG->EXTICR[0] = 0;
SYSCFG->EXTICR[1] = 0;
SYSCFG->EXTICR[2] = 0;
SYSCFG->EXTICR[3] = 0;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Register address automatically incremented during a multiple byte access with a serial interface.. */
|
int32_t lps22hh_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val)
|
/* Register address automatically incremented during a multiple byte access with a serial interface.. */
int32_t lps22hh_auto_increment_set(stmdev_ctx_t *ctx, uint8_t val)
|
{
lps22hh_ctrl_reg2_t reg;
int32_t ret;
ret = lps22hh_read_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1);
if (ret == 0) {
reg.if_add_inc = val;
ret = lps22hh_write_reg(ctx, LPS22HH_CTRL_REG2, (uint8_t *) ®, 1);
}
return ret;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Delete all mtd devices from a supplied devices list, free memory allocated for each device and delete all device partitions. */
|
static int device_delall(struct list_head *head)
|
/* Delete all mtd devices from a supplied devices list, free memory allocated for each device and delete all device partitions. */
static int device_delall(struct list_head *head)
|
{
struct list_head *entry, *n;
struct mtd_device *dev_tmp;
list_for_each_safe(entry, n, head) {
dev_tmp = list_entry(entry, struct mtd_device, link);
list_del(entry);
part_delall(&dev_tmp->parts);
free(dev_tmp);
}
INIT_LIST_HEAD(&devices);
return 0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Examines FDCAN receive FIFO and returns fill status of FIFO and ID of next message available for reading. If fill status is 0 (FIFO is empty), then get index is undefined. */
|
static void fdcan_get_fill_rxfifo(uint32_t canport, uint8_t fifo_id, unsigned *get_index, unsigned *pending_frames)
|
/* Examines FDCAN receive FIFO and returns fill status of FIFO and ID of next message available for reading. If fill status is 0 (FIFO is empty), then get index is undefined. */
static void fdcan_get_fill_rxfifo(uint32_t canport, uint8_t fifo_id, unsigned *get_index, unsigned *pending_frames)
|
{
*get_index = (FDCAN_RXFIS(canport, fifo_id) >> FDCAN_RXFIFO_GI_SHIFT)
& FDCAN_RXFIFO_GI_MASK;
*pending_frames = (FDCAN_RXFIS(canport, fifo_id) >> FDCAN_RXFIFO_FL_SHIFT)
& FDCAN_RXFIFO_FL_MASK;
}
|
libopencm3/libopencm3
|
C++
|
GNU General Public License v3.0
| 2,931
|
/* select LDO output voltage this bit set by software when the main PLL closed, before closing PLL, change the system clock to IRC16M or HXTAL */
|
void pmu_ldo_output_select(uint32_t ldo_output)
|
/* select LDO output voltage this bit set by software when the main PLL closed, before closing PLL, change the system clock to IRC16M or HXTAL */
void pmu_ldo_output_select(uint32_t ldo_output)
|
{
PMU_CTL &= ~PMU_CTL_LDOVS;
PMU_CTL |= ldo_output;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Reads data from the specified Data Backup Register. */
|
uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR)
|
/* Reads data from the specified Data Backup Register. */
uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR)
|
{
__IO uint32_t tmp = 0;
assert_param(IS_BKP_DR(BKP_DR));
tmp = (uint32_t)BKP_BASE;
tmp += BKP_DR;
return (*(__IO uint16_t *) tmp);
}
|
gcallipo/RadioDSP-Stm32f103
|
C++
|
Common Creative - Attribution 3.0
| 51
|
/* step12 of enumeration - Get first struct of USB configuration descriptor */
|
static void main_usb_enum_step12(void)
|
/* step12 of enumeration - Get first struct of USB configuration descriptor */
static void main_usb_enum_step12(void)
|
{
main_usb_wait_setup_packet();
main_conf_desc.conf.bDescriptorType = USB_DT_CONFIGURATION;
main_conf_desc.conf.bLength = sizeof(usb_conf_desc_t);
main_conf_desc.conf.bMaxPower = USB_CONFIG_MAX_POWER(USB_DEVICE_POWER);
main_conf_desc.conf.bmAttributes = USB_CONFIG_ATTR_MUST_SET | USB_DEVICE_ATTR,
main_usb_send_in((uint8_t*)&main_conf_desc, sizeof(usb_conf_desc_t));
main_usb_wait_out(NULL,0);
}
|
remotemcu/remcu-chip-sdks
|
C++
| null | 436
|
/* Writes a full string to the VFD display. */
|
void samsungvfdWriteString(const char *str)
|
/* Writes a full string to the VFD display. */
void samsungvfdWriteString(const char *str)
|
{
while(*str)
{
gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 0);
samsungvfd_sendByte(SAMSUNGVFD_SPIDATA);
samsungvfd_sendByte(*str++);
gpioSetValue(SAMSUNGVFD_STB_PORT, SAMSUNGVFD_STB_PIN, 1);
}
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* SYSCTRL EFLASH Bus&Memory Clock Enable and Reset Release. */
|
void LL_SYSCTRL_EFLASH_ClkEnRstRelease(void)
|
/* SYSCTRL EFLASH Bus&Memory Clock Enable and Reset Release. */
void LL_SYSCTRL_EFLASH_ClkEnRstRelease(void)
|
{
__LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL);
__LL_SYSCTRL_EFLASHBusClk_En(SYSCTRL);
__LL_SYSCTRL_EFLASHMemClk_En(SYSCTRL);
__LL_SYSCTRL_EFLASHSoftRst_Release(SYSCTRL);
__LL_SYSCTRL_Reg_Lock(SYSCTRL);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Write a device register. The MCP interface must be enabled to prevent this function hanging. */
|
void mcp_reg_write(struct mcp *mcp, unsigned int reg, unsigned int val)
|
/* Write a device register. The MCP interface must be enabled to prevent this function hanging. */
void mcp_reg_write(struct mcp *mcp, unsigned int reg, unsigned int val)
|
{
unsigned long flags;
spin_lock_irqsave(&mcp->lock, flags);
mcp->ops->reg_write(mcp, reg, val);
spin_unlock_irqrestore(&mcp->lock, flags);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Gets the width in pixels of the LCD screen (varies depending on the current screen orientation) */
|
uint16_t lcdGetWidth(void)
|
/* Gets the width in pixels of the LCD screen (varies depending on the current screen orientation) */
uint16_t lcdGetWidth(void)
|
{
switch (lcdOrientation)
{
case LCD_ORIENTATION_PORTRAIT:
return ili9325Properties.width;
break;
case LCD_ORIENTATION_LANDSCAPE:
default:
return ili9325Properties.height;
}
}
|
microbuilder/LPC1343CodeBase
|
C++
|
Other
| 73
|
/* Elliptic Curve Cryptography Interface.
The information contained herein is confidential property of Nordic Semiconductor. The use, copying, transfer or disclosure of such information is prohibited except by express written agreement with Nordic Semiconductor. */
|
static int ecc_rng(uint8_t *dest, unsigned size)
|
/* Elliptic Curve Cryptography Interface.
The information contained herein is confidential property of Nordic Semiconductor. The use, copying, transfer or disclosure of such information is prohibited except by express written agreement with Nordic Semiconductor. */
static int ecc_rng(uint8_t *dest, unsigned size)
|
{
uint32_t errcode;
errcode = nrf_drv_rng_block_rand(dest, (uint32_t) size);
return errcode == NRF_SUCCESS ? 1 : 0;
}
|
labapart/polymcu
|
C++
| null | 201
|
/* Description: Stops the state machine timer, sets the state to UP (unless it wasn't up yet). This function must be called BEFORE phy_detach. */
|
void phy_stop_machine(struct phy_device *phydev)
|
/* Description: Stops the state machine timer, sets the state to UP (unless it wasn't up yet). This function must be called BEFORE phy_detach. */
void phy_stop_machine(struct phy_device *phydev)
|
{
cancel_delayed_work_sync(&phydev->state_queue);
mutex_lock(&phydev->lock);
if (phydev->state > PHY_UP)
phydev->state = PHY_UP;
mutex_unlock(&phydev->lock);
phydev->adjust_state = NULL;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Add the client to the client list, and call backs the client for each activated offload device */
|
void cxgb3_register_client(struct cxgb3_client *client)
|
/* Add the client to the client list, and call backs the client for each activated offload device */
void cxgb3_register_client(struct cxgb3_client *client)
|
{
struct t3cdev *tdev;
mutex_lock(&cxgb3_db_lock);
list_add_tail(&client->client_list, &client_list);
if (client->add) {
list_for_each_entry(tdev, &ofld_dev_list, ofld_dev_list) {
if (offload_activated(tdev))
client->add(tdev);
}
}
mutex_unlock(&cxgb3_db_lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* This function reads the current RTC time into tm in Gregorian date. */
|
static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
/* This function reads the current RTC time into tm in Gregorian date. */
static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
{
u32 val;
do {
val = get_alarm_or_time(dev, MXC_RTC_TIME);
} while (val != get_alarm_or_time(dev, MXC_RTC_TIME));
rtc_time_to_tm(val, tm);
return 0;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Leave the top bit clear so we have tagspace for userland. The bottom 16 bits are the xmit tick for rexmit/rttavg processing. This driver reserves tag -1 to mean "unused frame." */
|
static int newtag(struct aoetgt *t)
|
/* Leave the top bit clear so we have tagspace for userland. The bottom 16 bits are the xmit tick for rexmit/rttavg processing. This driver reserves tag -1 to mean "unused frame." */
static int newtag(struct aoetgt *t)
|
{
register ulong n;
n = jiffies & 0xffff;
return n |= (++t->lasttag & 0x7fff) << 16;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Reads some data and returns the number of bytes read. The actual data (possibly an empty string) is pushed on the Lua stack. */
|
static int File_read_chars(lua_State *L, FILE_T ft, size_t n)
|
/* Reads some data and returns the number of bytes read. The actual data (possibly an empty string) is pushed on the Lua stack. */
static int File_read_chars(lua_State *L, FILE_T ft, size_t n)
|
{
if (rlen > n) rlen = n;
nri = file_read(buff, (unsigned int)rlen, ft);
if (nri < 1) break;
nr = (size_t) nri;
luaL_addlstring(&b, buff, nr);
n -= nr;
} while (n > 0 && nr == rlen);
luaL_pushresult(&b);
return (n == 0 || lua_rawlen(L, -1) > 0);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Attempt to get lock on driver instance.
The purpose of this is to enable exclusive access to driver instances, so that, e.g., transactions by different services will not interfere with each other. */
|
enum status_code spi_lock(struct spi_module *const module)
|
/* Attempt to get lock on driver instance.
The purpose of this is to enable exclusive access to driver instances, so that, e.g., transactions by different services will not interfere with each other. */
enum status_code spi_lock(struct spi_module *const module)
|
{
enum status_code status;
if (module->locked) {
status = STATUS_BUSY;
} else {
module->locked = true;
status = STATUS_OK;
}
return status;
}
|
memfault/zero-to-main
|
C++
| null | 200
|
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */
|
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
/* Enables or disables I2C Clock Timeout (SCL Timeout detection). */
void I2C_ClockTimeoutCmd(I2C_TypeDef *I2Cx, FunctionalState NewState)
|
{
assert_param(IS_I2C_1_PERIPH(I2Cx));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIMOUTEN;
}
else
{
I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMOUTEN);
}
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* We regard a request as SYNC, if it's either a read or has the SYNC bit set (in which case it could also be direct WRITE). */
|
static bool cfq_bio_sync(struct bio *bio)
|
/* We regard a request as SYNC, if it's either a read or has the SYNC bit set (in which case it could also be direct WRITE). */
static bool cfq_bio_sync(struct bio *bio)
|
{
return bio_data_dir(bio) == READ || bio_rw_flagged(bio, BIO_RW_SYNCIO);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* When a number of calls to _cairo_cache_thaw() is made corresponding to the number of calls to _cairo_cache_freeze() the cache will no longer be "frozen". If the cache had grown larger than max_size while frozen, entries will immediately be ejected (by random) from the cache until the cache is smaller than max_size. Also, the automatic ejection of entries on _cairo_cache_insert() will resume. */
|
void _cairo_cache_thaw(cairo_cache_t *cache)
|
/* When a number of calls to _cairo_cache_thaw() is made corresponding to the number of calls to _cairo_cache_freeze() the cache will no longer be "frozen". If the cache had grown larger than max_size while frozen, entries will immediately be ejected (by random) from the cache until the cache is smaller than max_size. Also, the automatic ejection of entries on _cairo_cache_insert() will resume. */
void _cairo_cache_thaw(cairo_cache_t *cache)
|
{
assert (cache->freeze_count > 0);
if (--cache->freeze_count == 0)
_cairo_cache_shrink_to_accommodate (cache, 0);
}
|
xboot/xboot
|
C++
|
MIT License
| 779
|
/* Flush all buffer from keyboard controller to host */
|
static void i8042_flush(void)
|
/* Flush all buffer from keyboard controller to host */
static void i8042_flush(void)
|
{
int timeout;
while (1) {
timeout = 100;
while (timeout > 0 && !(in8(I8042_STS_REG) & STATUS_OBF)) {
udelay(1);
timeout--;
}
if (in8(I8042_STS_REG) & STATUS_OBF)
in8(I8042_DATA_REG);
else
break;
}
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* Get the date from given NMEA RMC sentence. */
|
static int process_rmc_date(struct nmea_sentence_rmc_t *rmc_p, struct date_t *date_p)
|
/* Get the date from given NMEA RMC sentence. */
static int process_rmc_date(struct nmea_sentence_rmc_t *rmc_p, struct date_t *date_p)
|
{
int res;
res = nmea_decode_fix_time(rmc_p->time_of_fix_p,
&date_p->hour,
&date_p->minute,
&date_p->second);
if (res != 0) {
return (res);
}
date_p->day = -1;
res = nmea_decode_date(rmc_p->date_p,
&date_p->year,
&date_p->month,
&date_p->date);
if (res != 0) {
return (res);
}
return (0);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor capabilities mask */
|
UINT64 CoreConvertResourceDescriptorHobAttributesToCapabilities(EFI_GCD_MEMORY_TYPE GcdMemoryType, UINT64 Attributes)
|
/* Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor capabilities mask */
UINT64 CoreConvertResourceDescriptorHobAttributesToCapabilities(EFI_GCD_MEMORY_TYPE GcdMemoryType, UINT64 Attributes)
|
{
UINT64 Capabilities;
GCD_ATTRIBUTE_CONVERSION_ENTRY *Conversion;
for (Capabilities = 0, Conversion = mAttributeConversionTable; Conversion->Attribute != 0; Conversion++) {
if (Conversion->Memory || ((GcdMemoryType != EfiGcdMemoryTypeSystemMemory) && (GcdMemoryType != EfiGcdMemoryTypeMoreReliable))) {
if (Attributes & Conversion->Attribute) {
Capabilities |= Conversion->Capability;
}
}
}
return Capabilities;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Erase All FLASH.
This performs all operations necessary to erase all user pages in the FLASH memory. The information block is unaffected. */
|
void flash_erase_all_pages(void)
|
/* Erase All FLASH.
This performs all operations necessary to erase all user pages in the FLASH memory. The information block is unaffected. */
void flash_erase_all_pages(void)
|
{
flash_wait_for_last_operation();
FLASH_CR |= FLASH_CR_MER;
FLASH_CR |= FLASH_CR_STRT;
flash_wait_for_last_operation();
FLASH_CR &= ~FLASH_CR_MER;
FLASH_CR2 |= FLASH_CR_MER;
FLASH_CR2 |= FLASH_CR_STRT;
flash_wait_for_last_operation();
FLASH_CR2 &= ~FLASH_CR_MER;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* The MPC824x has an integrated PCI controller known as the MPC107. The following are MPC107 Bridge Controller and PCI Support functions This procedure reads a 32-bit address MPC107 register, and returns a 32 bit value. It swaps the address to little endian before writing it to config address, and swaps the value to big endian before returning to the caller. */
|
unsigned int mpc824x_mpc107_getreg(unsigned int regNum)
|
/* The MPC824x has an integrated PCI controller known as the MPC107. The following are MPC107 Bridge Controller and PCI Support functions This procedure reads a 32-bit address MPC107 register, and returns a 32 bit value. It swaps the address to little endian before writing it to config address, and swaps the value to big endian before returning to the caller. */
unsigned int mpc824x_mpc107_getreg(unsigned int regNum)
|
{
unsigned int temp;
*(volatile unsigned int *) CHRP_REG_ADDR = PCISWAP (regNum);
temp = *(volatile unsigned int *) CHRP_REG_DATA;
return PCISWAP (temp);
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Length cannot be used in these functions, big problem if a element dissector is not defined for these. */
|
static guint16 elem_t(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, elem_idx_t idx, guint32 offset, const gchar *name_add, ansi_a_shared_data_t *data_p _U_)
|
/* Length cannot be used in these functions, big problem if a element dissector is not defined for these. */
static guint16 elem_t(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, elem_idx_t idx, guint32 offset, const gchar *name_add, ansi_a_shared_data_t *data_p _U_)
|
{
guint8 oct;
guint32 curr_offset;
guint16 consumed;
curr_offset = offset;
consumed = 0;
if ((int) idx < 0 || idx >= ansi_a_elem_1_max-1)
{
return tvb_reported_length_remaining(tvb, offset);
}
oct = tvb_get_guint8(tvb, curr_offset);
if (oct == (guint8) ansi_a_elem_1_strings[idx].value)
{
proto_tree_add_uint_format(tree, hf_ansi_a_elem_id, tvb, curr_offset, 1, oct,
"%s%s",
ansi_a_elem_1_strings[idx].strptr,
(name_add == NULL) || (name_add[0] == '\0') ? "" : name_add);
consumed = 1;
}
return(consumed);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Checks whether the specified DMA Channelx flag is set or not. */
|
FlagStatus DMA_GetFlagStatus(uint32_t DMAFlag, DMA_Module *DMAy)
|
/* Checks whether the specified DMA Channelx flag is set or not. */
FlagStatus DMA_GetFlagStatus(uint32_t DMAFlag, DMA_Module *DMAy)
|
{
FlagStatus bitstatus = RESET;
uint32_t tmpregister = 0;
assert_param(IS_DMA_GET_FLAG(DMAFlag));
tmpregister = DMAy->INTSTS;
if ((tmpregister & DMAFlag) != (uint32_t)RESET)
{
bitstatus = SET;
}
else
{
bitstatus = RESET;
}
return bitstatus;
}
|
pikasTech/PikaPython
|
C++
|
MIT License
| 1,403
|
/* an inline helper for the "simple" if statement below checks if parameter problem report is caused by an unrecognized IPv6 option that has the Option Type highest-order two bits set to 10 */
|
static __inline__ int opt_unrec(struct sk_buff *skb, __u32 offset)
|
/* an inline helper for the "simple" if statement below checks if parameter problem report is caused by an unrecognized IPv6 option that has the Option Type highest-order two bits set to 10 */
static __inline__ int opt_unrec(struct sk_buff *skb, __u32 offset)
|
{
u8 _optval, *op;
offset += skb_network_offset(skb);
op = skb_header_pointer(skb, offset, sizeof(_optval), &_optval);
if (op == NULL)
return 1;
return (*op & 0xC0) == 0x80;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* klist_add_before - Init a klist_node and add it before an existing node */
|
void klist_add_before(struct klist_node *n, struct klist_node *pos)
|
/* klist_add_before - Init a klist_node and add it before an existing node */
void klist_add_before(struct klist_node *n, struct klist_node *pos)
|
{
struct klist *k = knode_klist(pos);
klist_node_init(k, n);
spin_lock(&k->k_lock);
list_add_tail(&n->n_node, &pos->n_node);
spin_unlock(&k->k_lock);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* If configured, or requested by the commandline, devtmpfs will be auto-mounted after the kernel mounted the root filesystem. */
|
int devtmpfs_mount(const char *mntdir)
|
/* If configured, or requested by the commandline, devtmpfs will be auto-mounted after the kernel mounted the root filesystem. */
int devtmpfs_mount(const char *mntdir)
|
{
int err;
if (!dev_mount)
return 0;
if (!dev_mnt)
return 0;
err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
if (err)
printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
else
printk(KERN_INFO "devtmpfs: mounted\n");
return err;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Perform cable detection for C2 and later revisions */
|
static int ali_c2_cable_detect(struct ata_port *ap)
|
/* Perform cable detection for C2 and later revisions */
static int ali_c2_cable_detect(struct ata_port *ap)
|
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u8 ata66;
if (ali_cable_override(pdev))
return ATA_CBL_PATA40_SHORT;
pci_read_config_byte(pdev, 0x4A, &ata66);
if (ata66 & (1 << ap->port_no))
return ATA_CBL_PATA40;
else
return ATA_CBL_PATA80;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Returns the domainname which the specified PID is in on success, empty string otherwise. The PID is specified by tomoyo_write_pid() so that the user can obtain using read()/write() interface rather than sysctl() interface. */
|
static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
|
/* Returns the domainname which the specified PID is in on success, empty string otherwise. The PID is specified by tomoyo_write_pid() so that the user can obtain using read()/write() interface rather than sysctl() interface. */
static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
|
{
if (head->read_avail == 0 && !head->read_eof) {
const int pid = head->read_step;
struct task_struct *p;
struct tomoyo_domain_info *domain = NULL;
read_lock(&tasklist_lock);
p = find_task_by_vpid(pid);
if (p)
domain = tomoyo_real_domain(p);
read_unlock(&tasklist_lock);
if (domain)
tomoyo_io_printf(head, "%d %u %s", pid, domain->profile,
domain->domainname->name);
head->read_eof = true;
}
return 0;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* On UNIX, returns the process ID as a decimal string. On Windows, returns the result of GetProcessId() also as a string. */
|
const gchar* g_subprocess_get_identifier(GSubprocess *subprocess)
|
/* On UNIX, returns the process ID as a decimal string. On Windows, returns the result of GetProcessId() also as a string. */
const gchar* g_subprocess_get_identifier(GSubprocess *subprocess)
|
{
g_return_val_if_fail (G_IS_SUBPROCESS (subprocess), NULL);
if (subprocess->pid)
return subprocess->identifier;
else
return NULL;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function will attempt to read BufferSize bytes from the TLS object and places the data in Buffer. */
|
INTN EFIAPI TlsCtrlTrafficOut(IN VOID *Tls, IN OUT VOID *Buffer, IN UINTN BufferSize)
|
/* This function will attempt to read BufferSize bytes from the TLS object and places the data in Buffer. */
INTN EFIAPI TlsCtrlTrafficOut(IN VOID *Tls, IN OUT VOID *Buffer, IN UINTN BufferSize)
|
{
TLS_CONNECTION *TlsConn;
TlsConn = (TLS_CONNECTION *)Tls;
if ((TlsConn == NULL) || (TlsConn->OutBio == 0)) {
return -1;
}
return BIO_read (TlsConn->OutBio, Buffer, (UINT32)BufferSize);
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Enables the ip checksum offloading in receive path. When set GMAC calculates 16 bit 1's complement of all received ethernet frame payload. It also checks IPv4 Header checksum is correct. GMAC core appends the 16 bit checksum calculated for payload of IP datagram and appends it to Ethernet frame transferred to the application. */
|
void synopGMAC_enable_rx_chksum_offload(synopGMACdevice *gmacdev)
|
/* Enables the ip checksum offloading in receive path. When set GMAC calculates 16 bit 1's complement of all received ethernet frame payload. It also checks IPv4 Header checksum is correct. GMAC core appends the 16 bit checksum calculated for payload of IP datagram and appends it to Ethernet frame transferred to the application. */
void synopGMAC_enable_rx_chksum_offload(synopGMACdevice *gmacdev)
|
{
synopGMACSetBits(gmacdev->MacBase, GmacConfig, GmacRxIpcOffload);
return;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* The function locates PerformanceEx protocol and Performance Protocol from protocol database. */
|
EFI_STATUS GetPerformanceMeasurementProtocol(VOID)
|
/* The function locates PerformanceEx protocol and Performance Protocol from protocol database. */
EFI_STATUS GetPerformanceMeasurementProtocol(VOID)
|
{
EFI_STATUS Status;
EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
if (mPerformanceMeasurement != NULL) {
return EFI_SUCCESS;
}
Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **)&PerformanceMeasurement);
if (!EFI_ERROR (Status)) {
ASSERT (PerformanceMeasurement != NULL);
mPerformanceMeasurement = PerformanceMeasurement;
return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This function handles External line 10..15 interrupt request. */
|
void EXTI15_10_IRQHandler(void)
|
/* This function handles External line 10..15 interrupt request. */
void EXTI15_10_IRQHandler(void)
|
{
HAL_GPIO_EXTI_IRQHandler(SD_DETECT_PIN);
}
|
STMicroelectronics/STM32CubeF4
|
C++
|
Other
| 789
|
/* State table: RE DE Result 1 1 XMIT 0 0 RCV 1 0 Shutdown */
|
static void set_rs485re(unsigned char rs485re_state)
|
/* State table: RE DE Result 1 1 XMIT 0 0 RCV 1 0 Shutdown */
static void set_rs485re(unsigned char rs485re_state)
|
{
if(rs485re_state)
*CPLD_RS485_RE = 0x010000;
else
*CPLD_RS485_RE = 0x0;
}
|
EmcraftSystems/u-boot
|
C++
|
Other
| 181
|
/* Returns: the start of the new #GList, which equals @list1 if not NULL */
|
GList* g_list_concat(GList *list1, GList *list2)
|
/* Returns: the start of the new #GList, which equals @list1 if not NULL */
GList* g_list_concat(GList *list1, GList *list2)
|
{
GList *tmp_list;
if (list2)
{
tmp_list = g_list_last (list1);
if (tmp_list)
tmp_list->next = list2;
else
list1 = list2;
list2->prev = tmp_list;
}
return list1;
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* This function processes the results of changes in configuration. */
|
EFI_STATUS EFIAPI BootManagerRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
/* This function processes the results of changes in configuration. */
EFI_STATUS EFIAPI BootManagerRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
|
{
if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
return EFI_NOT_FOUND;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Get the previous window size, ramp it up, and return it as the new window size. */
|
static unsigned long get_next_ra_size(struct file_ra_state *ra, unsigned long max)
|
/* Get the previous window size, ramp it up, and return it as the new window size. */
static unsigned long get_next_ra_size(struct file_ra_state *ra, unsigned long max)
|
{
unsigned long cur = ra->size;
unsigned long newsize;
if (cur < max / 16)
newsize = 4 * cur;
else
newsize = 2 * cur;
return min(newsize, max);
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Get UEFI image protection policy based upon loaded image device path. */
|
UINT32 GetUefiImageProtectionPolicy(IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath)
|
/* Get UEFI image protection policy based upon loaded image device path. */
UINT32 GetUefiImageProtectionPolicy(IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage, IN EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath)
|
{
BOOLEAN InSmm;
UINT32 ImageType;
UINT32 ProtectionPolicy;
InSmm = FALSE;
if (gSmmBase2 != NULL) {
gSmmBase2->InSmm (gSmmBase2, &InSmm);
}
if (InSmm) {
return FALSE;
}
if (LoadedImage == gDxeCoreLoadedImage) {
ImageType = IMAGE_FROM_FV;
} else {
ImageType = GetImageType (LoadedImageDevicePath);
}
ProtectionPolicy = GetProtectionPolicyFromImageType (ImageType);
return ProtectionPolicy;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* This file is part of the Simba project. */
|
int board_pin_string_to_device_index(const char *str_p)
|
/* This file is part of the Simba project. */
int board_pin_string_to_device_index(const char *str_p)
|
{
long pin;
if (strcmp(str_p, "led") == 0) {
pin = 9;
} else {
return (-ENODEV);
}
return (pin);
}
|
eerimoq/simba
|
C++
|
Other
| 337
|
/* Clear IT status in SX8651 interrupt status clear registers. */
|
int32_t SX8651_ClearIT(SX8651_Object_t *pObj)
|
/* Clear IT status in SX8651 interrupt status clear registers. */
int32_t SX8651_ClearIT(SX8651_Object_t *pObj)
|
{
(void)(pObj);
return SX8651_OK;
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* ADC Set Dual/Triple Mode.
The various modes possible are described in the reference manual. */
|
void adc_set_multi_mode(uint32_t adc, uint32_t mode)
|
/* ADC Set Dual/Triple Mode.
The various modes possible are described in the reference manual. */
void adc_set_multi_mode(uint32_t adc, uint32_t mode)
|
{
ADC_CCR(adc) |= mode;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* Set the blockcount field in a bmap extent record. */
|
void xfs_bmbt_set_blockcount(xfs_bmbt_rec_host_t *r, xfs_filblks_t v)
|
/* Set the blockcount field in a bmap extent record. */
void xfs_bmbt_set_blockcount(xfs_bmbt_rec_host_t *r, xfs_filblks_t v)
|
{
ASSERT((v & xfs_mask64hi(43)) == 0);
r->l1 = (r->l1 & (xfs_bmbt_rec_base_t)xfs_mask64hi(43)) |
(xfs_bmbt_rec_base_t)(v & xfs_mask64lo(21));
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Given a number and NULL address, return the num'th entry in the device table, if any. Given an address and num == -1, search the device table for a device with that address and return if it's still present. Given both, return the num'th driver only if its address matches. Return error code if not. */
|
struct mtd_info* get_mtd_device(struct mtd_info *mtd, int num)
|
/* Given a number and NULL address, return the num'th entry in the device table, if any. Given an address and num == -1, search the device table for a device with that address and return if it's still present. Given both, return the num'th driver only if its address matches. Return error code if not. */
struct mtd_info* get_mtd_device(struct mtd_info *mtd, int num)
|
{
struct mtd_info *ret = NULL, *other;
int err = -ENODEV;
mutex_lock(&mtd_table_mutex);
if (num == -1) {
mtd_for_each_device(other) {
if (other == mtd) {
ret = mtd;
break;
}
}
} else if (num >= 0) {
ret = idr_find(&mtd_idr, num);
if (mtd && mtd != ret)
ret = NULL;
}
if (!ret) {
ret = ERR_PTR(err);
goto out;
}
err = __get_mtd_device(ret);
if (err)
ret = ERR_PTR(err);
out:
mutex_unlock(&mtd_table_mutex);
return ret;
}
|
4ms/stm32mp1-baremetal
|
C++
|
Other
| 137
|
/* DAC960_V2_ReportProgress prints an appropriate progress message for Logical Device Long Operations. */
|
static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller, unsigned char *MessageString, unsigned int LogicalDeviceNumber, unsigned long BlocksCompleted, unsigned long LogicalDeviceSize)
|
/* DAC960_V2_ReportProgress prints an appropriate progress message for Logical Device Long Operations. */
static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller, unsigned char *MessageString, unsigned int LogicalDeviceNumber, unsigned long BlocksCompleted, unsigned long LogicalDeviceSize)
|
{
Controller->EphemeralProgressMessage = true;
DAC960_Progress("%s in Progress: Logical Drive %d (/dev/rd/c%dd%d) "
"%d%% completed\n", Controller,
MessageString,
LogicalDeviceNumber,
Controller->ControllerNumber,
LogicalDeviceNumber,
(100 * (BlocksCompleted >> 7)) / (LogicalDeviceSize >> 7));
Controller->EphemeralProgressMessage = false;
}
|
robutest/uclinux
|
C++
|
GPL-2.0
| 60
|
/* Do not register the internal protocols AX25_P_TEXT, AX25_P_SEGMENT, AX25_P_IP or AX25_P_ARP ... */
|
void ax25_register_pid(struct ax25_protocol *ap)
|
/* Do not register the internal protocols AX25_P_TEXT, AX25_P_SEGMENT, AX25_P_IP or AX25_P_ARP ... */
void ax25_register_pid(struct ax25_protocol *ap)
|
{
write_lock_bh(&protocol_list_lock);
ap->next = protocol_list;
protocol_list = ap;
write_unlock_bh(&protocol_list_lock);
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Power up the USB PLL.
USERCC2 must have been set by a call to */
|
void rcc_usb_pll_on(void)
|
/* Power up the USB PLL.
USERCC2 must have been set by a call to */
void rcc_usb_pll_on(void)
|
{
SYSCTL_RCC2 &= ~SYSCTL_RCC2_USBPWRDN;
}
|
insane-adding-machines/unicore-mx
|
C++
|
GNU General Public License v3.0
| 50
|
/* This routine is called to add a selection combo_box to the dialog box. The combo_box choices are determined by the dissector. The default choice for the combo_box is also determined by the dissector. */
|
static GtkWidget* decode_add_multivalue_combo_box(GtkWidget *page, decode_as_t *entry)
|
/* This routine is called to add a selection combo_box to the dialog box. The combo_box choices are determined by the dissector. The default choice for the combo_box is also determined by the dissector. */
static GtkWidget* decode_add_multivalue_combo_box(GtkWidget *page, decode_as_t *entry)
|
{
GtkWidget *combo_box, *alignment;
guint value;
gchar prompt[MAX_DECODE_AS_PROMPT_LEN];
combo_box = ws_combo_box_new_text_and_pointer();
for (value = 0; value < entry->num_items; value++)
{
entry->values[value].label_func(&cfile.edt->pi, prompt);
ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(combo_box), prompt, GINT_TO_POINTER(value));
}
ws_combo_box_set_active(GTK_COMBO_BOX(combo_box), entry->default_index_value);
g_object_set_data(G_OBJECT(page), E_COMBO_BOX_MULTIVALUE, combo_box);
alignment = decode_add_pack_combo_box(combo_box);
return(alignment);
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* Returns the current setting of the ADC reference. */
|
uint32_t ADCReferenceGet(uint32_t ui32Base)
|
/* Returns the current setting of the ADC reference. */
uint32_t ADCReferenceGet(uint32_t ui32Base)
|
{
ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE));
return (HWREG(ui32Base + ADC_O_CTL) & ADC_CTL_VREF_M);
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This function is called by ZCL foundation dissector in order to decode */
|
static void dissect_zcl_msg_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
/* This function is called by ZCL foundation dissector in order to decode */
static void dissect_zcl_msg_attr_data(proto_tree *tree, tvbuff_t *tvb, guint *offset, guint16 attr_id, guint data_type)
|
{
switch (attr_id) {
case ZBEE_ZCL_ATTR_ID_SE_ATTR_REPORT_STATUS:
proto_tree_add_item(tree, hf_zbee_zcl_msg_attr_reporting_status, tvb, *offset, 1, ENC_NA);
*offset += 1;
break;
default:
dissect_zcl_attr_data(tvb, tree, offset, data_type);
break;
}
}
|
seemoo-lab/nexmon
|
C++
|
GNU General Public License v3.0
| 2,330
|
/* param base PXP peripheral base address. param config Pointer to the configuration. */
|
void PXP_SetProcessSurfaceBufferConfig(PXP_Type *base, const pxp_ps_buffer_config_t *config)
|
/* param base PXP peripheral base address. param config Pointer to the configuration. */
void PXP_SetProcessSurfaceBufferConfig(PXP_Type *base, const pxp_ps_buffer_config_t *config)
|
{
assert(config);
base->PS_CTRL = ((base->PS_CTRL & ~(PXP_PS_CTRL_FORMAT_MASK | PXP_PS_CTRL_WB_SWAP_MASK)) |
PXP_PS_CTRL_FORMAT(config->pixelFormat) | PXP_PS_CTRL_WB_SWAP(config->swapByte));
base->PS_BUF = config->bufferAddr;
base->PS_UBUF = config->bufferAddrU;
base->PS_VBUF = config->bufferAddrV;
base->PS_PITCH = config->pitchBytes;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* This API is used to parse the accelerometer data from the FIFO data and store it in the instance of the structure bmi160_sensor_data. */
|
static void unpack_accel_data(struct bmi160_sensor_data *accel_data, uint16_t data_start_index, const struct bmi160_dev *dev)
|
/* This API is used to parse the accelerometer data from the FIFO data and store it in the instance of the structure bmi160_sensor_data. */
static void unpack_accel_data(struct bmi160_sensor_data *accel_data, uint16_t data_start_index, const struct bmi160_dev *dev)
|
{
uint16_t data_lsb;
uint16_t data_msb;
data_lsb = dev->fifo->data[data_start_index++];
data_msb = dev->fifo->data[data_start_index++];
accel_data->x = (int16_t)((data_msb << 8) | data_lsb);
data_lsb = dev->fifo->data[data_start_index++];
data_msb = dev->fifo->data[data_start_index++];
accel_data->y = (int16_t)((data_msb << 8) | data_lsb);
data_lsb = dev->fifo->data[data_start_index++];
data_msb = dev->fifo->data[data_start_index++];
accel_data->z = (int16_t)((data_msb << 8) | data_lsb);
}
|
eclipse-threadx/getting-started
|
C++
|
Other
| 310
|
/* Enable the clock to the TPIU module.
This function enables the clock to the TPIU module. */
|
void am_hal_tpiu_clock_enable(void)
|
/* Enable the clock to the TPIU module.
This function enables the clock to the TPIU module. */
void am_hal_tpiu_clock_enable(void)
|
{
AM_REG(MCUCTRL, TPIUCTRL) |= AM_REG_MCUCTRL_TPIUCTRL_ENABLE_M;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Internal variable setting function. Allows for setting of the read only variables. */
|
EFI_STATUS InternalEfiShellSetEnv(IN CONST CHAR16 *Name, IN CONST CHAR16 *Value, IN BOOLEAN Volatile)
|
/* Internal variable setting function. Allows for setting of the read only variables. */
EFI_STATUS InternalEfiShellSetEnv(IN CONST CHAR16 *Name, IN CONST CHAR16 *Value, IN BOOLEAN Volatile)
|
{
EFI_STATUS Status;
if ((Value == NULL) || (StrLen (Value) == 0)) {
Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Name);
if (!EFI_ERROR (Status)) {
ShellRemvoeEnvVarFromList (Name);
}
} else {
SHELL_DELETE_ENVIRONMENT_VARIABLE (Name);
Status = ShellAddEnvVarToList (
Name,
Value,
StrSize (Value),
EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE)
);
if (!EFI_ERROR (Status)) {
Status = Volatile
? SHELL_SET_ENVIRONMENT_VARIABLE_V (Name, StrSize (Value) - sizeof (CHAR16), Value)
: SHELL_SET_ENVIRONMENT_VARIABLE_NV (Name, StrSize (Value) - sizeof (CHAR16), Value);
if (EFI_ERROR (Status)) {
ShellRemvoeEnvVarFromList (Name);
}
}
}
return Status;
}
|
tianocore/edk2
|
C++
|
Other
| 4,240
|
/* Description: Perform a label mapping to translate a CIPSO level to the correct local MLS level using the given DOI definition. Returns zero on success, negative values otherwise. */
|
static int cipso_v4_map_lvl_ntoh(const struct cipso_v4_doi *doi_def, u32 net_lvl, u32 *host_lvl)
|
/* Description: Perform a label mapping to translate a CIPSO level to the correct local MLS level using the given DOI definition. Returns zero on success, negative values otherwise. */
static int cipso_v4_map_lvl_ntoh(const struct cipso_v4_doi *doi_def, u32 net_lvl, u32 *host_lvl)
|
{
struct cipso_v4_std_map_tbl *map_tbl;
switch (doi_def->type) {
case CIPSO_V4_MAP_PASS:
*host_lvl = net_lvl;
return 0;
case CIPSO_V4_MAP_TRANS:
map_tbl = doi_def->map.std;
if (net_lvl < map_tbl->lvl.cipso_size &&
map_tbl->lvl.cipso[net_lvl] < CIPSO_V4_INV_LVL) {
*host_lvl = doi_def->map.std->lvl.cipso[net_lvl];
return 0;
}
return -EPERM;
}
return -EINVAL;
}
|
EmcraftSystems/linux-emcraft
|
C++
|
Other
| 266
|
/* Write the hash length to the SHA/MD5 module. */
|
void SHAMD5HashLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
/* Write the hash length to the SHA/MD5 module. */
void SHAMD5HashLengthSet(uint32_t ui32Base, uint32_t ui32Length)
|
{
ASSERT(ui32Base == SHAMD5_BASE);
HWREG(ui32Base + SHAMD5_O_LENGTH) = ui32Length;
}
|
RT-Thread/rt-thread
|
C++
|
Apache License 2.0
| 9,535
|
/* Return with tail node of the linked list */
|
void* lv_ll_get_tail(const lv_ll_t *ll_p)
|
/* Return with tail node of the linked list */
void* lv_ll_get_tail(const lv_ll_t *ll_p)
|
{
void * tail = NULL;
if(ll_p != NULL) {
tail = ll_p->tail;
}
return tail;
}
|
RavenSystem/esp-homekit-devices
|
C++
|
Other
| 2,577
|
/* returns a pointer to a free area with at least 'sz' bytes */
|
LUALIB_API char* luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
|
/* returns a pointer to a free area with at least 'sz' bytes */
LUALIB_API char* luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
|
{
char *newbuff;
size_t newsize = B->size * 2;
if (newsize - B->n < sz)
newsize = B->n + sz;
if (newsize < B->n || newsize - B->n < sz)
luaL_error(L, "buffer too large");
if (buffonstack(B))
newbuff = (char *)resizebox(L, -1, newsize);
else {
newbuff = (char *)newbox(L, newsize);
memcpy(newbuff, B->b, B->n * sizeof(char));
}
B->b = newbuff;
B->size = newsize;
}
return &B->b[B->n];
}
|
nodemcu/nodemcu-firmware
|
C++
|
MIT License
| 7,566
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.