Пример #1
0
/******************************************************************************
* Name       : uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt)
* Function   : IEC870 physical layer test
* Input      : uint8 u8Evt  1~254     Event for the task
* Output:    : None
* Return     : SW_OK   Successful operation
*            : SW_ERR  Failed operation
*              1~254   Event which is not processed.
* description: To be done
* Version    : V1.00
* Author     : Ian
* Date       : 13th Jul 2016
******************************************************************************/
uint8 Task_PT_IEC870_PL_Process(uint8 u8Evt)
{   
    PT_INIT();
    
    PT_BEGIN();

    /******************************************************************/
    MOE_MANDATORY_INIT();  /* Mandatory init, shout call it here only */
    /******************************************************************/

    CC1101_Init();
    PT_DELAY(1000);

    CC1101_Global_Config(sg_au8RxConfig);
    CC1101_PA_Config(sg_au8PaTabal);

    while(1)
    {
#ifdef __PL_RCV_ENABLE
        //TASK_PT_DEMO_LED_On(LED_RED);
        PL_RECEIVE(sg_au8RxFIFO);
        TASK_PT_DEMO_LED_Off(LED_RED);

        Manchester_Decode(&(sg_au8RxFIFO[1]), sg_au8RxData);

        Print_RF_Info();
#endif

#ifdef __PL_SND_ENABLE
        PT_DELAY(1000);
           
        TASK_PT_DEMO_LED_On(LED_BLUE);
#if defined (__PL_RCV_ENABLE) && defined (__PL_RCV_ENABLE)        
        PL_SEND(sg_au8RxFIFO);
#else
        PL_SEND(sg_au8Test);
#endif 
        TASK_PT_DEMO_LED_Off(LED_BLUE);
        
        PT_DELAY(500);
#endif
    }

    PT_END();

    return SW_OK;

}
Пример #2
0
void  BSP_Init (void)
{
    uint8_t retval = 0;
    
    LED_Init();
    UART1_Init();

    retval = CC1101_Init();
#ifdef DEUBG
    if(retval != 0)
    {
        while(1);
    }
#endif

}
Пример #3
0
/**@brief Application main function.
 */
int main(void)
{
		/*
		beginning of Initializing services for the Nordic Board	
		
		
		*/
    uint32_t err_code;
    bool erase_bonds;
		//print start string to terminal
    uint8_t  start_string[] = START_STRING;
    printf("%s",start_string);
    // Initialize timer.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
		nrf_drv_gpiote_init();
    uart_init();
    //buttons_leds_init(&erase_bonds);
    ble_stack_init();
        
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);

    APP_ERROR_CHECK(err_code);
		
      //More SPI Additions
         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,
    };
    ret_code_t err_code1 = nrf_drv_spi_init(&m_spi_master, &config, spi_master_event_handler);
    APP_ERROR_CHECK(err_code1);
		
		/*
		
		End of Initializing services for the Nordic Board	
		
		Beginning of CC1101 initializing.
		
		*/

    CC1101_Init();
		
		
		// Enter main loop.
		for (;;)
    {	
			//
			//for setting in receive mode
			//
			RecvDataPacket();
			SEGGER_RTT_WriteString(0,"RX data:");
			for(uint32_t i = 0; i<8;i++){
				SEGGER_RTT_printf(0,"%x",m_rx_data[i]);
			}
			SEGGER_RTT_WriteString(0,"\n");
            
			//
			//for sending data that was recieved from the BTLE event			
			//
       if(m_transfer_completed & newData)
       {
				m_transfer_completed = false;
        newData = false;
				SendDataPacket(txt_data, strlen((char *) txt_data) + 1);//Additional byte (5+1) is header byte
        nrf_delay_ms(1);
                    
       }
                
    }
}
void CC1101_Init(void){
	
	//sequence of SS pin on/off to indicate we are going to reset the system
	
	nrf_gpio_pin_clear(SPIM0_SS_PIN);
	nrf_delay_ms(1);
	nrf_gpio_pin_set(SPIM0_SS_PIN);
	nrf_delay_ms(1);
	nrf_gpio_pin_clear(SPIM0_SS_PIN);
	
	//strobe CC1101 reset
	uint8_t SRES = 0x30;
	SpiStrobe(SRES);	
	nrf_delay_ms(5);
	
	//calibrate CC1101
	CC1101_Calibrate();
	nrf_delay_ms(1);
	
}