Skip to content

Instantly share code, notes, and snippets.

View wdwalker's full-sized avatar

Willie Walker wdwalker

  • Hollis, NH
View GitHub Profile
@wdwalker
wdwalker / output.txt
Created March 16, 2017 14:00
Output of 'mbed import -vv git@github.com:wdwalker/BBB'
[mbed] Working path "/Users/wwalker/tmp" (directory)
[mbed] Importing program "BBB" from "git@github.com:wdwalker/BBB" at latest revision in the current branch
[mbed] Exec "git clone git@github.com:wdwalker/BBB /Users/wwalker/tmp/BBB -v" in /Users/wwalker/tmp
Cloning into '/Users/wwalker/tmp/BBB'...
remote: Counting objects: 136, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 136 (delta 0), reused 0 (delta 0), pack-reused 133
Receiving objects: 100% (136/136), 42.00 KiB | 0 bytes/s, done.
Resolving deltas: 100% (72/72), done.
[mbed] Query "git remote -v" in /Users/wwalker/tmp/BBB
@wdwalker
wdwalker / main.c
Last active March 13, 2017 16:25
CLKOUT example
/* Enable CLKOUT on pin 43 (P1.27) and have it show the CPU clock
* divided by 16. (p68, p120).
*/
LPC_SC->CLKOUTCFG = 0x000001F0;
LPC_PINCON->PINSEL3 &= ~((1 << 23) | (1 << 22));
LPC_PINCON->PINSEL3 |= (1 << 22);
@wdwalker
wdwalker / makefile
Created March 11, 2017 17:00
LD_FLAGS
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Link-Options.html
LDFLAGS = \
-nodefaultlibs \
-T "LPC1768.ld" \
-Wl,--gc-sections \
-Wl,-Map,"BBB.map" \
-Wl,--start-group -lgcc -lc -lm $(RDIMONLIB) -Wl,--end-group
@wdwalker
wdwalker / makefile
Created March 11, 2017 15:54
Other Flags
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Diagnostic-Message-Formatting-Options.html
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/C-Dialect-Options.html#C-Dialect-Options
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Code-Gen-Options.html
ASFLAGS = \
$(ARM_FLAGS) \
$(WARNING_FLAGS) \
-fmessage-length=0 \
$(OPTIMIZE) \
-ffunction-sections \
-fdata-sections \
@wdwalker
wdwalker / makefile
Created March 11, 2017 15:39
DEBUG
# Define DEBUG to anything if you want debug enabled.
#
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Optimize-Options.html#Optimize-Options
# http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0205g/Bgbjjgij.html
# https://mcuoneclipse.com/2015/05/27/semihosting-for-kinetis-design-studio-v3-0-0-and-gnu-arm-embedded-launchpad/
DEBUG=
ifdef DEBUG
OPTIMIZE=-Os -g -DDEBUG
RDIMONSPECS = --specs=rdimon.specs
RDIMONLIB = -lrdimon
@wdwalker
wdwalker / makefile
Created March 11, 2017 15:28
CPP_FLAGS
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Preprocessor-Options.html
CPPFLAGS = \
-MMD \
-MF"$(@:%.o=%.d)" \
-MT"$(@)"
@wdwalker
wdwalker / makefile
Created March 11, 2017 15:25
WARNING_FLAGS
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Warning-Options.html
WARNING_FLAGS = \
-Wall \
-Wextra \
-pedantic \
-Wbad-function-cast \
-Wconversion \
-Wfloat-equal \
-Wlogical-op \
-Wmissing-declarations \
@wdwalker
wdwalker / makefile
Created March 11, 2017 15:21
ARM_FLAGS
# https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/ARM-Options.html
ARM_FLAGS = \
-mthumb \
-mcpu=cortex-m3
@wdwalker
wdwalker / main.c
Last active March 11, 2017 15:03
Toggle LED1-4 on and off
/* Turn the LEDs on and off at roughly 1Hz.
*/
while (1) {
LPC_GPIO1->FIOSET |= ALL; /* p132 */
delay_ms(500);
LPC_GPIO1->FIOCLR |= ALL; /* p132 */
delay_ms(500);
}
@wdwalker
wdwalker / main.c
Last active March 11, 2017 14:46
Set FIODIR of pins to output for LED1-4
#define P18 (1 << 18)
#define P20 (1 << 20)
#define P21 (1 << 21)
#define P23 (1 << 23)
#define ALL (P18 | P20 | P21 | P23)
...
/* Set the direction as output by setting the associated bits