Skip to content

Instantly share code, notes, and snippets.

View C47D's full-sized avatar
:octocat:
Working...

Carlos Diaz C47D

:octocat:
Working...
  • México
View GitHub Profile
@C47D
C47D / gist:6a60afa194c78d57c0dd47372223ff96
Created November 2, 2017 01:57
FreeRTOS configuration options
// Mandatory configuration
#ifndef configMINIMAL_STACK_SIZE
#error Missing definition: configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h. configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task. Refer to the demo project provided for your port for a suitable value.
#endif
#ifndef configMAX_PRIORITIES
#error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
#endif
#ifndef configUSE_PREEMPTION
@C47D
C47D / gist:f80cf64d3513aa44a25ac5f47fc44727
Created November 4, 2017 00:04
test for using function pointer on the nrf24 component
// vtable
struct nrf_spi_operations {
uint8_t (*spi_read)(void);
void (*spi_write)(uint8_t data);
}
// microcontroller A
uint8_t microA_spi_read(void);
void microA_spi_write(uint8_t data);
@C47D
C47D / main.c
Created December 11, 2017 20:22
test for generating strings
#include <stdio.h>
#include <stdlib.h>
#define NAME(x) "Hola " #x
#define MSG(x) NAME(x)
int main(void)
{
printf("%s\r\n", MSG(World));
@C47D
C47D / spi_xfer.c
Last active January 3, 2018 19:22
test to send an array of uint8_t's via SPI using both polling and interrupts
#include "project.h"
#include <string.h>
enum {
MAX_ITEMS = 10,
};
typedef enum {
TX_IDLE,
TX_TRANSFERING,
@C47D
C47D / bytesArray_to_C.py
Last active February 16, 2019 18:41
Test script to convert from a Python ByteArray to a C array
#!/usr/bin/python3
oggDataArray = []
ogg_decoded_file = 'ogg_decoded'
output_file = 'test.c'
print('Opening {}.'.format(ogg_decoded_file))
with open(ogg_decoded_file, 'rb') as f:
@C47D
C47D / test.c
Created February 23, 2019 17:43
fatfs test on Cortex M0 based microcontroller
// This doesn't work (result in a halt handler) on a Cortex M0 based microcontroller, f_read expect an unsigned int as the last parameter
uint8_t bytesRead = 0;
res = f_read(&MyFile, &wav_test.riff, sizeof wav_test.riff, &bytesRead);
// But it does 'work' in the other Cortex M microcontrollers.
@C47D
C47D / qt_wav_to_ogg_encoder_example.cpp
Created February 27, 2019 03:49 — forked from peteristhegreat/qt_wav_to_ogg_encoder_example.cpp
Qt sample 16 bit Stereo Wav to Ogg Vorbis Encoder - Convert Wav to Ogg
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
@C47D
C47D / main.c
Created March 7, 2019 20:28
String concatenation
#include <stdio.h>
void test_1(void);
void test_2(void);
void test_3(void);
#define USE_TEST(x) (test_##x())
int main(void) {
@C47D
C47D / gist:198ac0d00985087180ad6517c9d2047c
Created April 15, 2019 22:30
CP Translate strings with arguments
/* https://github.com/adafruit/circuitpython/blob/22889ca29a9a8498fd7ba49260e988bfa5ac7011/ports/atmel-samd/common-hal/audioio/AudioOut.c#L377 */
mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate);
@C47D
C47D / mpconfigboard.h
Created June 2, 2019 02:41
Custom board definition for the bast pro mini with a rgb led attached to it
#define MICROPY_HW_BOARD_NAME "Electronic Cats Bast Pro Mini RGB M0"
#define MICROPY_HW_MCU_NAME "samd21e18"
#define MICROPY_PORT_A (0)
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
#define CP_RGB_STATUS_R (&pin_PA15)