Пример #1
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    gpiote_init();
    bsp_configuration();
    ppi_init();
    timer2_init();

    // Enabling constant latency as indicated by PAN 11 "HFCLK: Base current with HFCLK 
    // running is too high" found at Product Anomaly document found at
    // https://www.nordicsemi.com/eng/Products/Bluetooth-R-low-energy/nRF51822/#Downloads
    //
    // @note This example does not go to low power mode therefore constant latency is not needed.
    //       However this setting will ensure correct behaviour when routing TIMER events through 
    //       PPI (shown in this example) and low power mode simultaneously.
    NRF_POWER->TASKS_CONSTLAT = 1;

    // Enable interrupt on Timer 2.
    NVIC_EnableIRQ(TIMER2_IRQn);
    __enable_irq();

    // Workaround for PAN-73: Use of an EVENT from any TIMER module to trigger a TASK in GPIOTE or 
    // RTC using the PPI could fail under certain conditions.
    *(uint32_t *)0x4000AC0C = 1;    
    // Start the timer.
    NRF_TIMER2->TASKS_START = 1;

    while (true)
    {
        // Do nothing.
    }
}
Пример #2
0
/** @brief Function for main application entry.
 */
int main(void)
{
    // Setup bsp module.
    bsp_configuration();
	
    //uart initialization
    uint32_t err_code;
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_ENABLED,
          false,
          UART_BAUDRATE_BAUDRATE_Baud115200
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                          UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOW,
                         err_code);

		
    APP_ERROR_CHECK(err_code);

			
		while(app_uart_put(86) != NRF_SUCCESS);
		intan_setup();
			
	  while(app_uart_put(87) != NRF_SUCCESS);
    // initialize the buffer 
    buffer_init(&db, DATA_BUF_SIZE, sizeof(uint8_t));
			
		while(app_uart_put(88) != NRF_SUCCESS);
    for (;;)
    {
		//	printf("ldsakjf;ljdsaflkjlljlk\n");
 			while(app_uart_put(89) != NRF_SUCCESS);
			
        if (m_transfer_completed)
        {
            m_transfer_completed = false;

            intan_convert(m_tx_data_spi, m_rx_data_spi,intan_convert_channel);
	 
            //print m_rx_data_spi results
            switch_state();
					  for (int i; i< RX_MSG_LENGTH; i++){
							while(app_uart_put(m_rx_data_spi[i]) != NRF_SUCCESS);
						}
            nrf_delay_ms(DELAY_MS);
						//printf("Hi\n");
        }
				//printf("Yo\n");
    }
}
Пример #3
0
/**@brief Function for application main entry. Does not return.
 */ 
int main(void)
{
    // Setup bsp module.
    bsp_configuration();
    
    const uint32_t err_code = spi_slave_example_init();
    APP_ERROR_CHECK(err_code);
    
    // Enter application main processing loop.
    for (;;)
    {
        // No implementation needed.
    }   
}
Пример #4
0
/** @brief Function for main application entry.
 */
int main(void)
{
    // Setup bsp module.
    bsp_configuration();

    for (;; )
    {
        #if defined(SPI_MASTER_0_ENABLE) || defined(SPI_MASTER_1_ENABLE)
        if (m_transfer_completed)
        {
            m_transfer_completed = false;
            switch_state();
        }
        #endif // defined(SPI_MASTER_0_ENABLE) || defined(SPI_MASTER_1_ENABLE)
    }
}
Пример #5
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    clock_initialization();
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    uart_init();
    bsp_configuration();

    err_code = bsp_indication_text_set(actual_state,indications_list[actual_state]);
    APP_ERROR_CHECK(err_code);
    while (true)
    {
        // no implementation needed
    }
}
Пример #6
0
/**@brief Function for application main entry. Does not return. */
int main(void)
{
      unsigned char reg = 0x00; //IC Identity Register
      nrf_gpio_cfg_output(30); //for the CS pin
      nrf_drv_gpiote_out_set(30);   //This should assert the CS for the SPI peripheral

		  m_transfer_completed = false;

    // Setup bsp module.
    bsp_configuration();

    nrf_drv_spi_config_t const config =
    {
        #if (SPI0_ENABLED == 1)
            .sck_pin  = SPIM0_SCK_PIN,
            .mosi_pin = SPIM0_MOSI_PIN,
            .miso_pin = SPIM0_MISO_PIN,
            .ss_pin   = SPIM0_SS_PIN,
        #elif (SPI1_ENABLED == 1)
            .sck_pin  = SPIM1_SCK_PIN,
            .mosi_pin = SPIM1_MOSI_PIN,
            .miso_pin = SPIM1_MISO_PIN,
            .ss_pin   = SPIM1_SS_PIN,
        #elif (SPI2_ENABLED == 1)
            .sck_pin  = SPIM2_SCK_PIN,
            .mosi_pin = SPIM2_MOSI_PIN,
            .miso_pin = SPIM2_MISO_PIN,
            .ss_pin   = SPIM2_SS_PIN,
        #endif
        .irq_priority = APP_IRQ_PRIORITY_LOW,
        .orc          = 0xCC,
        .frequency    = NRF_DRV_SPI_FREQ_1M,
        .mode         = NRF_DRV_SPI_MODE_0,
        .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,
       .ss_pin       = NRF_DRV_SPI_PIN_NOT_USED, //added by DS - if not specified, the nrf_drv_spi_init() will set this to high, which is wrong, CS for AS3911 is active low
    };
    ret_code_t err_code = nrf_drv_spi_init(&m_spi_master, &config, spi_master_event_handler);
    APP_ERROR_CHECK(err_code);

  while(1)
	{
		  SPIWriteReg(0x18,0x27);
		   reg=SPIReadReg(0x18);
		   SEGGER_RTT_printf(0, " r value is %x\n", reg);
	}
}
Пример #7
0
/**@brief Function for application main entry. Does not return. */
int main(void)
{
    // Setup bsp module.
    bsp_configuration();

    nrf_drv_spi_config_t const config =
    {
        #if (SPI0_ENABLED == 1)
            .sck_pin  = SPIM0_SCK_PIN,
            .mosi_pin = SPIM0_MOSI_PIN,
            .miso_pin = SPIM0_MISO_PIN,
            .ss_pin   = SPIM0_SS_PIN,
        #elif (SPI1_ENABLED == 1)
            .sck_pin  = SPIM1_SCK_PIN,
            .mosi_pin = SPIM1_MOSI_PIN,
            .miso_pin = SPIM1_MISO_PIN,
            .ss_pin   = SPIM1_SS_PIN,
        #elif (SPI2_ENABLED == 1)
            .sck_pin  = SPIM2_SCK_PIN,
            .mosi_pin = SPIM2_MOSI_PIN,
            .miso_pin = SPIM2_MISO_PIN,
            .ss_pin   = SPIM2_SS_PIN,
        #endif
        .irq_priority = APP_IRQ_PRIORITY_LOW,
        .orc          = 0xCC,
        .frequency    = NRF_DRV_SPI_FREQ_1M,
        .mode         = NRF_DRV_SPI_MODE_0,
        .bit_order    = NRF_DRV_SPI_BIT_ORDER_LSB_FIRST,
    };
    ret_code_t err_code = nrf_drv_spi_init(&m_spi_master, &config, spi_master_event_handler);
    APP_ERROR_CHECK(err_code);

    for (;;)
    {
        if (m_transfer_completed)
        {
            m_transfer_completed = false;

            // Set buffers and start data transfer.
            spi_send_recv(m_tx_data, m_rx_data, TX_RX_BUF_LENGTH);
        }
    }
}
Пример #8
0
/**@brief Function for application main entry. Does not return. */
int main(void)
{
    // Setup bsp module.
    bsp_configuration();

    uint32_t err_code = spi_master_init();
    APP_ERROR_CHECK(err_code);

    // Register SPI master event handler.
    spi_master_evt_handler_reg(SPI_MASTER_HW, spi_master_event_handler);

    for (;;)
    {
        if (m_transfer_completed)
        {
            m_transfer_completed = false;

            // Set buffers and start data transfer.
            spi_send_recv(m_tx_data, m_rx_data, TX_RX_BUF_LENGTH);
        }
    }
}