Skip to content

Instantly share code, notes, and snippets.

View Arachnid's full-sized avatar

Nick Johnson Arachnid

View GitHub Profile
#define register(exporter, var) ExportedVariable _exported ## #var (exporter, #var, &var)
Exporter ex;
int blah;
register(ex, blah);
CommsLink cl("My device", 12345);
int my_int;
void ioinit() {
cl.register(&my_int);
}
void loop() {
while(1) {
>>> struct.pack("B", 0x38) + struct.pack("H", 0)
'8\x00\x00'
>>> struct.pack("BH", 0x38, 0)
'8\x00\x00\x00'
Archive member included because of file (symbol)
.\CortexM0\ARM_GCC_473\Release\Bootloader.a(cyfitter_cfg.o)
.\CortexM0\ARM_GCC_473\Release\Cm0Start.o (cyfitter_cfg)
.\CortexM0\ARM_GCC_473\Release\Bootloader.a(Bootloader.o)
.\CortexM0\ARM_GCC_473\Release\Cm0Start.o (CyBtldr_CheckLaunch)
.\CortexM0\ARM_GCC_473\Release\Bootloader.a(UART.o)
.\CortexM0\ARM_GCC_473\Release\main.o (UART_Start)
.\CortexM0\ARM_GCC_473\Release\Bootloader.a(UART_SPI_UART.o)
.\CortexM0\ARM_GCC_473\Release\main.o (UART_SpiUartGetRxBufferSize)
I want to make better tools for electronics makers and hobbyists, and I want you
to help me do it.
About a year ago, I was working on a project with a power supply I needed to
test, and I designed the original Re:load. As it happens, I'm not the only one
that needed one, and the Re:load became my first commercial product, and led to
the formation of Arachnid Labs. The Re:load's hugely popular with anyone who
needs to test a power supply, check battery life or discharge rates, or anything
else that requires a steady current source - especially if they don't have
thousands of dollars to throw at expensive lab equipment.
const char splashscreen_data[] = {
// 0-37: Page 0
0x01, 0xFF, 0xFF, 0xE0, 0xFF, 0x00, 0xE0, 0xFF, 0x00, 0xE0,
0x0A, 0x00, 0x00, 0x00, 0x40, 0x13, 0x01, 0x00, 0x80, 0x40,
0x05, 0xE0, 0x10, 0x00, 0x02, 0x02, 0xFD, 0xFD, 0x20, 0x23,
0x60, 0x29, 0xE0, 0x21, 0x00, 0x01, 0xFF, 0xFF,
// 38-109: Page 1
0x04, 0xFF, 0xDF, 0xFF, 0xBF, 0xFF, 0xE0, 0xFF, 0x03, 0xE1,
0x34, 0x07, 0x03, 0xEF, 0xB8, 0xFF, 0xC0, 0x21, 0x4B, 0x02,
0xFF, 0xFF, 0xFE, 0x20, 0x03, 0xE0, 0xC5, 0x00, 0x00, 0x00,
// Maps current state (index) to next state for a forward transition.
const int8 quadrature_states[] = {0x1, 0x3, 0x0, 0x2};
CY_ISR(quadrature_event_isr) {
static int8 last_levels = 3;
static int8 count = 0;
int levels = Quadrature_Read();
Quadrature_ClearInterrupt();
@Arachnid
Arachnid / main.c
Created December 21, 2013 13:12
Recovery mode bootloader
void main()
{
int i;
if(Bootloader_GET_RUN_TYPE == Bootloader_START_BTLDR)
Bootloader_Start();
for(i = 0; i < 2000; i++) {
uint8 status = Button_Read();
if(status)
@Arachnid
Arachnid / main.c
Created December 21, 2013 13:08
Everything you need to bootload with an SCB UART in PSoC 4
void CyBtldrCommStart(void) {
UART_Start();
}
void CyBtldrCommStop (void) {
UART_Stop();
}
void CyBtldrCommReset(void) {
UART_SpiUartClearRxBuffer();
uint8_t row_counts[4];
for(int row = 0; row < NUM_ROWS; row++)
for(int col = 0; col < NUM_COLUMNS; col++)
row_counts[row] += (scan[col] >> row) & 1;
for(int col = 0; col < NUM_COLUMNS; col++) {
uint8_t column_count = set_bits[scan[col]];
for(int row = 0; row < NUM_ROWS; row++) {
if(row_counts[row] > 1 && column_count > 1)