Skip to content

Instantly share code, notes, and snippets.

/* Copyright (c) Microsoft Corporation. All rights reserved. */
#include <string.h>
/* ISO/IEC 9899 7.11.5.8 strtok. DEPRECATED.
* Split string into tokens, and return one at a time while retaining state
* internally.
*
* WARNING: Only one set of state is held and this means that the
* WARNING: function is not thread-safe nor safe for multiple uses within
__strtok_r(char *s, const char *delim, char **last)
{
char *spanp, *tok;
int c, sc;
if (s == NULL &#038;&#038; (s = *last) == NULL)
return (NULL);
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
@stu9458
stu9458 / gist:6e2cbea432b5d3007253
Created January 20, 2015 03:38
MSP430F5529-I2C(Master)
// MSP430F552x Demo - USCI_B0 I2C Master TX single bytes to MSP430 Slave
//
// Description: This demo connects two MSP430's via the I2C bus. The master
// transmits to the slave. This is the master code. It continuously
// transmits 00h, 01h, ..., 0ffh and demonstrates how to implement an I2C
// master transmitter sending a single byte using the USCI_B0 TX interrupt.
// ACLK = n/a, MCLK = SMCLK = BRCLK = default DCO = ~1.045MHz
//
// ***to be used with "MSP430F55xx_uscib0_i2c_07.c" ***
//
@stu9458
stu9458 / gist:64892f44dc3989a1f271
Created January 20, 2015 03:37
MSP430F5529-I2C(Slave)
//******************************************************************************
// MSP430F552x Demo - USCI_B0 I2C Slave RX single bytes from MSP430 Master
//
// Description: This demo connects two MSP430's via the I2C bus. The master
// transmits to the slave. This is the slave code. The interrupt driven
// data receiption is demonstrated using the USCI_B0 RX interrupt.
// ACLK = n/a, MCLK = SMCLK = default DCO = ~1.045MHz
//
// ***to be used with "MSP430F55xx_uscib0_i2c_06.c" ***
//
@stu9458
stu9458 / rootfs->boot->uEnv.txt(Mapabone)
Created December 10, 2014 15:43
rootfs -> boot -> uEnv.txt
uname_r=3.8.13-bone67
#dtb=
cmdline=quiet init=/lib/systemd/systemd
##Example
#cape_disable=capemgr.disable_partno=
#cape_enable=capemgr.enable_partno=
loadximage=load mmc 0:2 ${loadaddr} /boot/vmlinuz-${uname_r}
loadxfdt=load mmc 0:2 ${fdtaddr} /boot/dtbs/${uname_r}/${fdtfile}
loadxrd=load mmc 0:2 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}
loaduEnvtxt=load mmc 0:2 ${loadaddr} /boot/uEnv.txt ; env import -t ${loadaddr} ${filesize};
check_dtb=if test -n ${dtb}; then setenv fdtfile ${dtb};fi;
loadall=run loaduEnvtxt; run check_dtb; run loadximage; run loadxrd; run loadxfdt;
mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} root=/dev/mmcblk0p2 rootfstype=${mmcrootfstype} ${cmdline}
uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr};
/***************
Use the code to drive interrupt function.
When input "high" to GPIO-20, the GPIO-7 will output a signal between high and low.
****************/
#include <linux/fs.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <rtdm/rtdm_driver.h>
@stu9458
stu9458 / Makefile
Last active August 29, 2015 14:10
Use that to make the oscillateur-gpio-rtdm.c
EXTRA_CFLAGS := -I/home/emp-chen/git/bbb/xenomai-2.6.4/include
ifneq (${KERNELRELEASE},)
obj-m += oscillateur-gpio-rtdm.o
else
ARCH ?= arm
CROSS_COMPILE ?= /home/emp-chen/linux-arm-genuhbi-
KERNEL_DIR = /home/emp-chen/git/bbb/beagle-kernel/kernel
@stu9458
stu9458 / Oscillateur-gpio-rtdm.c
Created November 28, 2014 09:39
That's describe the xenomai gpio module in beaglebone black
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/version.h>
#include <asm/uaccess.h>
@stu9458
stu9458 / SPI_Slave
Created November 3, 2014 03:31
MSP430f5529 SPI slave.(TI example but some error)
/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.