Skip to content

Instantly share code, notes, and snippets.

View stm32-returns-2.c
Conway64 conway(&hspi2);
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
View stm32-returns-1.sh
$ tree -L 2
.
├── Debug
├── Drivers
│   ├── CMSIS
│   └── STM32F1xx_HAL_Driver
├── Inc
│   ├── FreeRTOSConfig.h
│   ├── main.h
│   ├── stm32f1xx_hal_conf.h
View main6.c
volatile uint8_t g_demo_mode = 0;
volatile bool g_i2s_start = true;
volatile bool g_i2s_running = false;
static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
switch(p_data[0]) {
case '1':
{
g_demo_mode = 0;
View main5.c
for (;;)
{
// start I2S
if(g_i2s_start && !g_i2s_running) {
err_code = nrf_drv_i2s_start(0, m_buffer_tx, I2S_BUFFER_SIZE, 0);
APP_ERROR_CHECK(err_code);
g_i2s_running = true;
}
// stop I2S
@electronut
electronut / main5.c
Created Aug 18, 2017
caclChannelValue
View main5.c
uint32_t caclChannelValue(uint8_t level)
{
uint32_t val = 0;
// 0
if(level == 0) {
val = 0x88888888;
}
// 255
else if (level == 255) {
View main4.c
void set_led_data()
{
for(int i = 0; i < 3*NLEDS; i += 3) {
if (i == 3*nled) {
switch(g_demo_mode)
{
case 0:
{
m_buffer_tx[i] = 0x88888888;
m_buffer_tx[i+1] = caclChannelValue(128);
View main3.c
#define NLEDS 16
#define RESET_BITS 6
#define I2S_BUFFER_SIZE 3*NLEDS + RESET_BITS
static uint32_t m_buffer_tx[I2S_BUFFER_SIZE];
static volatile int nled = 1;
@electronut
electronut / main2.c
Created Aug 18, 2017
I2S data handler
View main2.c
// This is the I2S data handler - all data exchange related to the I2S transfers
// is done here.
static void data_handler(uint32_t const * p_data_received,
uint32_t * p_data_to_send,
uint16_t number_of_words)
{
// Non-NULL value in 'p_data_to_send' indicates that the driver needs
// a new portion of data to send.
if (p_data_to_send != NULL)
{
View main1.c
nrf_drv_i2s_config_t config = NRF_DRV_I2S_DEFAULT_CONFIG;
config.sdin_pin = I2S_SDIN_PIN;
config.sdout_pin = I2S_SDOUT_PIN;
config.mck_setup = NRF_I2S_MCK_32MDIV10; ///< 32 MHz / 10 = 3.2 MHz.
config.ratio = NRF_I2S_RATIO_32X; ///< LRCK = MCK / 32.
config.channels = NRF_I2S_CHANNELS_STEREO;
err_code = nrf_drv_i2s_init(&config, data_handler);
APP_ERROR_CHECK(err_code);
@electronut
electronut / bluey-beacon-3.py
Created Jul 9, 2017
bluey-beacon - parse sensor data
View bluey-beacon-3.py
# constant
pow_16 = 65536.0
# decode temperature
def decodeT(temp_val):
return ((temp_val / pow_16) * 165 - 40)
# decode humidity
def decodeH(humid_val):
return ((humid_val / pow_16) * 100)
You can’t perform that action at this time.