Skip to content

Instantly share code, notes, and snippets.

View martinribelotta's full-sized avatar
🐒
coding like a monkey

Martin Ribelotta martinribelotta

🐒
coding like a monkey
View GitHub Profile
@martinribelotta
martinribelotta / Makefile
Last active November 9, 2020 17:26
Makefile for arm embedded
TARGET=firmware
SOURCES=$(wildcard src/*.c)
LIBPATH=lib
LIBS=nosys
LDSCRIPTS=link.ld
SPECS=rdimon
OUT=out
OBJECTS=$(addprefix $(OUT)/, $(patsubst %.c, %.o, $(SOURCES)))
TARGET_ELF=$(addsuffix .elf, $(addprefix $(OUT)/, $(TARGET)))
From: Hyun Kwon <hyun.k...@xilinx.com>
Date: Mon, 8 Jul 2019 11:37:03 -0700
Subject: [PATCH 1/1] uio: dmabuf: Merge the dmabuf functions into uio.c
With a separate uio_dmabuf.c, it's tricky to build the uio as
a separate kernel module.
Reported-by: Jean-Francois Dagenais <jeff.dagen...@gmail.com>
Signed-off-by: Hyun Kwon <hyun.k...@xilinx.com>
---
@martinribelotta
martinribelotta / example.c
Created August 19, 2019 16:08
LPC43xx RAM sections
#include "sections.h"
// See section names in linker script (*.ld)
// See: https://github.com/martinribelotta/micropython/blob/master/ciaa-nxp/ciaa_lpc4337.ld
// BSS is for non initialized variables (clear to zero on init)
static __BSS(RAM2) char heap[32*1024];
// DATA is for initialized variables
static __DATA(RAM2) char heap[32*1024] = { 0xff };
@martinribelotta
martinribelotta / sapi_spi.c
Created November 21, 2018 19:35
sAPI SPI shift
// Add this to libs/sapi/sapi_v0.5.2/soc/peripherals/src/sapi_spi.c
void spiShiftBlock( spiMap_t spi, const uint8_t *in, uint8_t *out, uint32_t count)
{
Chip_SSP_DATA_SETUP_T xferConfig;
uint8_t out;
xferConfig.tx_data = &in;
xferConfig.tx_cnt = 0;
xferConfig.rx_data = &out;
xferConfig.rx_cnt = 0;
interface ftdi
ftdi_device_desc "Dual RS232-HS"
ftdi_vid_pid 0x0403 0x6010
ftdi_channel 0
ftdi_layout_init 0x0708 0xFFFB
ftdi_layout_signal nTRST -data 0x0100
ftdi_layout_signal nSRST -data 0x0200
transport select jtag
adapter_khz 2000
#include <programa.h>
using namespace sapi;
struct {
DigitalIn button;
DigitalOut led;
} io[] = {
{ { TEC2 }, { LED1 } },
{ { TEC3 }, { LED2 } },
@martinribelotta
martinribelotta / example.c
Created February 16, 2018 22:14
Static freeRTOS task creation macros
#include "staticTaskFreeRTOS.h"
TASK_DECL(task, configMINIMAL_STACK_SIZE) {
while(1) {
// DO anything
taskYIELD();
}
}
int main(void)
Copyright <year>, <author, authors>
<author> : <author url or mail>
<author> : <author url or mail>
<author> : <author url or mail>
This file is part of CIAA Hardware.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@martinribelotta
martinribelotta / armv7m_irq_svd_to_c.py
Last active October 2, 2017 19:56
Create ARMv7M vendor interrupt table from SVD description file
import re
import sys
if len(sys.argv) < 1:
print("Usage: {} <svdfile.svd>".format(sys.argv[0]))
regex = r"<interrupt>\s*<name>(\S+)<\/name>\s*<value>(\S+)<\/value>\s*<\/interrupt>"
def intname(name): return "0" if not name else "{}_IRQHandler".format(name)
def declname(name): return "void {} __attribute__((weak));".format(intname(name))
@martinribelotta
martinribelotta / generate-bundle.sh
Last active August 29, 2017 21:31
MSYS2 bundled generation
PACKAGES="coreutils git bash"
FILTERED="'/usr/share' perl terminfo"
_F_CMD=$(for f in $FILTERED; do echo -n "grep -v -F $f | "; done)
F_CMD=${_F_CMD::-2}
D_CMD=$(pacman -Q -l $(for p in $PACKAGES; do pactree.exe -lu $p; done)|cut -d ' ' -f 2|sort -u | eval $F_CMD )
for f in $D_CMD
do
test -f $f && cp -v $f tmp$f;
test -d $f && mkdir -vp tmp$f
done