/* * This example uses only one instance of the SPI master. * Please make sure that only one instance of the SPI master is enabled in config file. */ #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ #define APP_TIMER_MAX_TIMERS BSP_APP_TIMERS_NUMBER /**< Maximum number of simultaneously created timers. */ #define APP_TIMER_OP_QUEUE_SIZE 2 /**< Size of timer operation queues. */ #define DELAY_MS 1000 /**< Timer Delay in milli-seconds. */ #define TX_RX_BUF_LENGTH 16u /**< SPI transaction buffer length. */ #if (SPI0_ENABLED == 1) static const nrf_drv_spi_t m_spi_master = NRF_DRV_SPI_INSTANCE(0); #elif (SPI1_ENABLED == 1) static const nrf_drv_spi_t m_spi_master = NRF_DRV_SPI_INSTANCE(1); #elif (SPI2_ENABLED == 1) static const nrf_drv_spi_t m_spi_master = NRF_DRV_SPI_INSTANCE(2); #else #error "No SPI enabled." #endif // Data buffers. static uint8_t m_tx_data[TX_RX_BUF_LENGTH] = {0}; /**< A buffer with data to transfer. */ static uint8_t m_rx_data[TX_RX_BUF_LENGTH] = {0}; /**< A buffer for incoming data. */ static volatile bool m_transfer_completed = true; /**< A flag to inform about completed transfer. */
(uint32_t) SPI1_TWI1_IRQHandler }, #endif #if SPI2_ENABLED { SPIS2_IRQ, (uint32_t) SPIM2_SPIS2_SPI2_IRQHandler }, #endif }; static sdk_driver_instances_t m_instances[SPI_COUNT] = { #if SPI0_ENABLED { NRF_DRV_SPI_INSTANCE(0), NRF_DRV_SPIS_INSTANCE(0) }, #endif #if SPI1_ENABLED { NRF_DRV_SPI_INSTANCE(1), NRF_DRV_SPIS_INSTANCE(1) }, #endif #if SPI2_ENABLED { NRF_DRV_SPI_INSTANCE(2), NRF_DRV_SPIS_INSTANCE(2) }, #endif
WRITE, READ, CONVERT, DUMMY } intan_function; static intan_function m_intan_function = DUMMY; //initialize state for DUMMY static uint8_t m_tx_data_spi[TX_MSG_LENGTH]; ///< SPI master TX buffer. static uint8_t m_rx_data_spi[RX_MSG_LENGTH]; ///< SPI master RX buffer. static volatile bool m_transfer_completed = true; //static spi_master_ex_state_t m_spi_master_ex_state = (spi_master_ex_state_t)0; static const nrf_drv_spi_t m_spi_master_0 = NRF_DRV_SPI_INSTANCE(0); /********************************** COMPRESSION DEFINITIONS ************************************************/ #define NUM_DATA_BUFFERS 2 /**<Number of data buffers to use> */ #define DATA_BUF_SIZE (2048U) /**<buffer size for each data buffer.> */ #define TRANSMISSION_BUF_SIZE (DATA_BUF_SIZE + (DATA_BUF_SIZE / 2) + 4) /**<buffer size for the transmission buffer.> */ static data_buffer db = {0}; static int intan_convert_channel = 0; static uint8_t *transmission_buffer; /**<Buffer for storing and sending the compressed data>*/ static heatshrink_encoder hse; /********************************** DATA ACQUISITION PROTOTYPE ************************************************/
if ((R1) & ~(SDC_FLAG_IN_IDLE_STATE | SDC_FLAG_ERASE_RESET)) \ { \ SDC_BREAK((PT), SDC_ERROR_COMMUNICATION); \ } \ } while(0) /**< Check the result of an SDC operation and break on failure. */ #define SDC_RESULT_CHECK(PT, RESULT) do { \ if ((RESULT) != SDC_SUCCESS) \ { \ SDC_BREAK((PT), RESULT); \ } \ } while(0); static const nrf_drv_spi_t m_spi = NRF_DRV_SPI_INSTANCE(APP_SDCARD_SPI_INSTANCE); /**< SPI instance. */ /** * @brief SDC response type. */ typedef enum { SDC_RNONE = 0, SDC_R1, SDC_R3, SDC_R7 } sdc_response_t; /** * @brief SDC operation state. */ typedef enum {
#define ST7735_GMCTRP1 0xE0 #define ST7735_GMCTRN1 0xE1 #define ST7735_MADCTL_MY 0x80 #define ST7735_MADCTL_MX 0x40 #define ST7735_MADCTL_MV 0x20 #define ST7735_MADCTL_ML 0x10 #define ST7735_MADCTL_RGB 0x00 #define ST7735_MADCTL_BGR 0x08 #define ST7735_MADCTL_MH 0x04 /* @} */ #define RGB2BGR(x) (x << 11) | (x & 0x07E0) | (x >> 11) static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ST7735_SPI_INSTANCE); /**< SPI instance. */ /** * @brief Structure holding ST7735 controller basic parameters. */ typedef struct { uint8_t tab_color; /**< Color of tab attached to the used screen. */ }st7735_t; /** * @brief Enumerator with TFT tab colors. */ typedef enum{ INITR_GREENTAB = 0, /**< Green tab. */ INITR_REDTAB, /**< Red tab. */
#define ILI9341_TIMCTRA 0xE8 #define ILI9341_TIMCTRB 0xEA #define ILI9341_ENGMCTR 0xF2 #define ILI9341_INCTR 0xF6 #define ILI9341_PUMP 0xF7 #define ILI9341_MADCTL_MY 0x80 #define ILI9341_MADCTL_MX 0x40 #define ILI9341_MADCTL_MV 0x20 #define ILI9341_MADCTL_ML 0x10 #define ILI9341_MADCTL_RGB 0x00 #define ILI9341_MADCTL_BGR 0x08 #define ILI9341_MADCTL_MH 0x04 static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ILI9341_SPI_INSTANCE); static inline void spi_write(const void * data, size_t size) { APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, data, size, NULL, 0)); } static inline void write_command(uint8_t c) { nrf_gpio_pin_clear(ILI9341_DC_PIN); spi_write(&c, sizeof(c)); } static inline void write_data(uint8_t c) { nrf_gpio_pin_set(ILI9341_DC_PIN);
#include "nrf_log_ctrl.h" #include "nrf_drv_spi.h" #include "nrf_drv_clock.h" #include "nrf_drv_rtc.h" #include "app_uart.h" #include "app_error.h" #include "max6675.h" // see nrf_drv_config.h for defining RTC1 #define RTC1_PRESCALE 8 // Softdevice S110, S120, S130 blocks RTC0 const nrf_drv_rtc_t rtc1 = NRF_DRV_RTC_INSTANCE(1); /**< Declaring an instance of nrf_drv_rtc for RTC1. */ // defining SPI0 const nrf_drv_spi_t my_spi_0 = NRF_DRV_SPI_INSTANCE(0); /**< Declaring an instance of nrf_drv_spi for SPI0. */ const uint32_t led_pin1 = 19; static max6675_config_t max6675_config = MAX6675_DEFAULT_CONFIG; static uint32_t pos=0; /** @brief Function initialization and configuration of RTC driver instance. */ static void gpio_config() { // Configure LED-pin as outputs and clear. NRF_LOG_DEBUG("nrf_gpio_cfg_output %d\n\r",led_pin1); nrf_gpio_cfg_output(led_pin1); nrf_gpio_pin_clear(led_pin1); }