Ejemplo n.º 1
0
const void *DM002_Cmds(enum ProtoCmds cmd)
{
    switch(cmd) {
        case PROTOCMD_INIT:  initialize(); return 0;
        case PROTOCMD_DEINIT:
        case PROTOCMD_RESET:
            CLOCK_StopTimer();
            return (void *)(NRF24L01_Reset() ? 1L : -1L);
        case PROTOCMD_CHECK_AUTOBIND: return (void *)1L; // always Autobind
        case PROTOCMD_BIND:  initialize(); return 0;
        case PROTOCMD_NUMCHAN: return (void *) 10L;
        case PROTOCMD_DEFAULT_NUMCHAN: return (void *)10L;
        case PROTOCMD_CURRENT_ID: return Model.fixed_id ? (void *)((unsigned long)Model.fixed_id) : 0;
        case PROTOCMD_GETOPTIONS: return (void*)0L;
        case PROTOCMD_TELEMETRYSTATE: return (void *)(long)PROTO_TELEM_UNSUPPORTED;
        default: break;
    }
    return 0;
}
Ejemplo n.º 2
0
int main(void)
{

	/* USER CODE BEGIN 1 */

	/* USER CODE END 1 */

	/* MCU Configuration----------------------------------------------------------*/

	/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
	HAL_Init();

	/* Configure the system clock */
	SystemClock_Config();

	/* Initialize all configured peripherals */
	MX_GPIO_Init();
	MX_USART1_UART_Init();
	MX_SPI1_Init();
	MX_TIM1_Init();
	MX_TIM3_Init();

	HAL_TIM_Base_Start(&htim1);

	static char buf[50];


	NRF24L01_Reset();
	NRF24L01_Initialize();
	HAL_Delay(150);


	CX10_init();
	HAL_Delay(50);
	CX10_bind();

	while (1) {
		process_CX10();
		HAL_Delay(6);
	}

}
Ejemplo n.º 3
0
uintptr_t ASSAN_Cmds(enum ProtoCmds cmd)
{
    switch(cmd) {
        case PROTOCMD_INIT:  initASSAN(0); return 0;
        case PROTOCMD_DEINIT:
        case PROTOCMD_RESET:
            CLOCK_StopTimer();
            return (NRF24L01_Reset() ? 1L : -1L);
        case PROTOCMD_CHECK_AUTOBIND: return 0L;
        case PROTOCMD_BIND:  initASSAN(1); return 0;
        case PROTOCMD_NUMCHAN: return  8L;
        case PROTOCMD_DEFAULT_NUMCHAN: return 8L;
        case PROTOCMD_CURRENT_ID: return Model.fixed_id;
        case PROTOCMD_GETOPTIONS: return 0L;
        case PROTOCMD_CHANNELMAP: return AETRG;
        case PROTOCMD_TELEMETRYSTATE: return PROTO_TELEM_UNSUPPORTED;
        default: break;
    }
    return 0;
}
Ejemplo n.º 4
0
void loop()
{
    uint32_t timeout;
    // reset / rebind
    //Serial.println("begin loop");
    if(reset || ppm[AUX8] > PPM_MAX_COMMAND) {
        reset = false;
        Serial.println("selecting protocol");
        selectProtocol();        
        Serial.println("selected protocol.");
        NRF24L01_Reset();
        Serial.println("nrf24l01 reset.");
        NRF24L01_Initialize();
        Serial.println("nrf24l01 init.");
        init_protocol();
        Serial.println("init protocol.");
    }
    // process protocol
    //Serial.println("processing protocol.");
    switch(current_protocol) {
        case PROTO_CG023:
        case PROTO_YD829:
            timeout = process_CG023();
            break;
        case PROTO_V2X2: 
            timeout = process_V2x2();
            break;
        case PROTO_CX10_GREEN:
        case PROTO_CX10_BLUE:
            timeout = process_CX10(); // returns micros()+6000 for time to next packet. 
            break;
        case PROTO_H7:
            timeout = process_H7();
            break;
        case PROTO_BAYANG:
            timeout = process_Bayang();
            break;
        case PROTO_SYMAX5C1:
            timeout = process_SymaX(); 
            break;
        case PROTO_H8_3D:
            timeout = process_H8_3D();
            break;
    }
    // updates ppm values out of ISR
    //update_ppm();
    overrun_cnt=0;

    if (stringComplete) {
        //Serial.println(inputString);
        // process string
        p = strtok_r(record,",",&i);
        while (p !=0){
          Serial.print(p);
          Serial.print("c");
          p = strtok_r(NULL,",",&i);
        }
        Serial.println("X");
        //ppm[0]=
        
        
        
        // clear the string:
        inputString = "";
        stringComplete = false;
    }
    while (Serial.available()) {
      // get the new byte:
      char inChar = (char)Serial.read();
      // if the incoming character is a newline, set a flag
      // so the main loop can do something about it:
      if (inChar == '\n') {
        stringComplete = true;
      }
      else {      
        // add it to the inputString:
        inputString += inChar;
      }
      
    }
    // wait before sending next packet
    while(micros() < timeout) // timeout for CX-10 blue = 6000microseconds. 
    {
      overrun_cnt+=1;
    };
    if ((overrun_cnt<1000)||(stringComplete)) {
      Serial.println(overrun_cnt);
    }
}