This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree -L 2 | |
. | |
├── Debug | |
├── Drivers | |
│ ├── CMSIS | |
│ └── STM32F1xx_HAL_Driver | |
├── Inc | |
│ ├── FreeRTOSConfig.h | |
│ ├── main.h | |
│ ├── stm32f1xx_hal_conf.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t caclChannelValue(uint8_t level) | |
{ | |
uint32_t val = 0; | |
// 0 | |
if(level == 0) { | |
val = 0x88888888; | |
} | |
// 255 | |
else if (level == 255) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |