Ejemplo n.º 1
0
void main(void)
{
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];
  uint8_t packet_cnt = 0;
  uint8_t rx_packet_cnt = 0;
  uint8_t rx_packet_byte0 = 0;

  mcu_init();
  gzll_init();

  // Set P0 as output
  P0DIR = 0;    

  EA = 1;

  for(;;)
  {      
    // If gazell link layer idle
    if(gzll_get_state() == GZLL_IDLE)
    {
      if(gzll_rx_fifo_read(payload, NULL, NULL))
      {
        P0 = ~payload[0];
      }

      // Put P0 contents in payload[0]
      payload[0] = P2;
       
      // Transmits payload[] to pipe 0 address
      gzll_tx_data(payload, 1, 0);   
    }
  }  
}
Ejemplo n.º 2
0
/**
Gazell Link Layer Configuration tool main application.
*/
void main(void)
{
  bool radio_activity;
  uint8_t buttons;
  
  mcu_init();
 
  gzll_init();
  app_init();
  lcd_init();
     
  EA = 1;

  app_execute(0);

  while(1)
  {       
    buttons = buttons_read();
    radio_activity = com_execute();
   
    if(buttons || radio_activity)
    {
      app_execute(buttons);       
    }
  }
}
Ejemplo n.º 3
0
void main() 
{
    char devid1, devid2; 
    int16 unique_id;

    mcu_init();    
    //output_high(BUZZER);
    
    output_high(LED); 
    
    //lcd_init();
    /*    
    devid1 = read_program_eeprom(DEVID1_ADDR);
    devid2 = read_program_eeprom(DEVID2_ADDR);
    unique_id = ((devid1 & 0xE0) >> 5) | ((int16)devid2 << 3);*/

    //printf(lcd_putc, "\f%Lu", unique_id);

    //
   while (1) 
   {
        /*printf(lcd_putc, "\f\xc7Hello \nCharles");
        delay_ms(1000);
        printf(lcd_putc, "\fPGM !!!!");
        delay_ms(1000);
        printf(lcd_putc, "\f J'aime \n");
        delay_ms(1000);
        printf(lcd_putc, "\f les \n FRITES");
        delay_ms(1000);*/

      enable_interrupts(INT_TIMER0); 
   } 
} 
Ejemplo n.º 4
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  main_init_hw();
  main_enable_hw();

}
Ejemplo n.º 5
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_init();
  led_init();
  usb_serial_init();
  mcu_int_enable();
}
Ejemplo n.º 6
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  ActuatorsPwmInit();
}
Ejemplo n.º 7
0
STATIC_INLINE void main_init(void)
{
  // fbw_init
  fbw_mode = FBW_MODE_FAILSAFE;

  mcu_init();

  actuators_init();

  electrical_init();

#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  modules_init();

  mcu_int_enable();

  intermcu_init();

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1. / MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1. / 60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  telemetry_tid = sys_time_register_timer((1. / 20.), NULL);
}
Ejemplo n.º 8
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  uart0_init_tx();
  mcu_int_enable();
}
Ejemplo n.º 9
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_init();
  led_init();
  gps_init();
  mcu_int_enable();
}
Ejemplo n.º 10
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / 100), NULL);
  downlink_init();
  adc_init();

#ifdef ADC_0
  adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
#endif
#ifdef ADC_1
  adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
#endif
#ifdef ADC_2
  adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
#endif
#ifdef ADC_3
  adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
#endif
#ifdef ADC_4
  adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
#endif
#ifdef ADC_5
  adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#endif
#ifdef ADC_6
  adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
  adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif

  mcu_int_enable();
}
Ejemplo n.º 11
0
/**
 * @fn halBoardInit
 * @brief
 * Initialize the hardware target board. After this initialization, you can run your 
 * application or startup the operating system(OS).
 *
 * @param   none
 * @return  none
 */
void target_init(void)
{
    /* @todo I think you should place disable interrupts here. */

	hal_init( NULL, NULL );
    mcu_init();
    hal_disable_interrupts();
    
    rtl_init( (void*)dbio_open(9600), (TiFunDebugIoPutChar)dbio_putchar, (TiFunDebugIoGetChar)dbio_getchar, 
        hal_assert_report );

	/*
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_1_PORT, HAL_BOARD_IO_LED_1_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_2_PORT, HAL_BOARD_IO_LED_2_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_3_PORT, HAL_BOARD_IO_LED_3_PIN, 0);
    MCU_IO_OUTPUT(HAL_BOARD_IO_LED_4_PORT, HAL_BOARD_IO_LED_4_PIN, 0);

    MCU_IO_INPUT(HAL_BOARD_IO_BTN_1_PORT, HAL_BOARD_IO_BTN_1_PIN, MCU_IO_TRISTATE);
    MCU_IO_INPUT(HAL_BOARD_IO_BTN_2_PORT, HAL_BOARD_IO_BTN_2_PIN, MCU_IO_TRISTATE);

    halLcdSpiInit();
    halLcdInit();
    halAssyInit();
				  
	*/
}
Ejemplo n.º 12
0
int main(void)
{

  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);

  /* Init GPIO for rx pins */
  gpio_setup_input_pullup(A_RX_PORT, A_RX_PIN);
  gpio_setup_input_pullup(B_RX_PORT, B_RX_PIN);

  /* Init GPIO for tx pins */
  gpio_setup_output(A_TX_PORT, A_TX_PIN);
  gpio_setup_output(B_TX_PORT, B_TX_PIN);

  gpio_clear(A_TX_PORT, A_TX_PIN);

  /* */
  while (1) {
    if (sys_time_check_and_ack_timer(0)) {
      main_periodic();
    }
    main_event();
  }

  return 0;
}
Ejemplo n.º 13
0
/**
 * Blink test main function
 *
 * @return Nothing really...
 */
int main(void)
{
	int i, j, dp_id;

	mcu_init();
	led_init();
	debug_pins_init();

	dp_id = 0;

	while (true) {
		for (j = 0; j < 20; j++) {
			for (i = 0; i < 125; i++) {
				dp_on(dp_id);
				my_delay((unsigned long)(50 * j));
				dp_off(dp_id);
				my_delay((unsigned long)(1200 - 50 * j));
			}
		}
		for (j = 0; j < 20; j++) {
			for (i = 0; i < 125; i++) {
				dp_off(dp_id);
				my_delay((unsigned long)(200 + 50 * j));
				dp_on(dp_id);
				my_delay((unsigned long)(1000 - 50 * j));
			}
		}
		dp_off(dp_id);
		dp_id++;
		dp_id %= 4;
	}
}
Ejemplo n.º 14
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((0.5 / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  ppz_can_init(main_on_can_msg);
}
Ejemplo n.º 15
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);

  stateInit();
  actuators_init();

  imu_init();
#if USE_AHRS_ALIGNER
  ahrs_aligner_init();
#endif
  ahrs_init();

  settings_init();

  mcu_int_enable();

  downlink_init();

  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_AUTOPILOT_VERSION, send_autopilot_version);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ALIVE, send_alive);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_COMMANDS, send_commands);
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_ACTUATORS, send_actuators);

  // send body_to_imu from here for now
  AbiSendMsgBODY_TO_IMU_QUAT(1, orientationGetQuat_f(&imu.body_to_imu));
}
Ejemplo n.º 16
0
int main(void)
{
	struct nand_chip nand_info;
	struct nand_chip *nand = &nand_info;
	unsigned char *oob_buf = (unsigned char *)TCSM_BANK4;
	struct nand_pipe_buf pipe_buf[2];
	struct pdma_msg *msg;

	pipe_buf[0].pipe_data = (unsigned char *)TCSM_BANK5;
	pipe_buf[1].pipe_data = (unsigned char *)TCSM_BANK6;
	msg = (struct pdma_msg *)TCSM_BANK7; /* TCSM last bank start */

	mcu_init();

	channel_irq = 0;
	nand->ctrl = 0;
	__pdma_irq_enable();

	while (1) {
		__pdma_irq_disable();
		if (!channel_irq)
			__pdma_mwait();
		__pdma_irq_enable();

		pdma_msg_irq_handle(nand, pipe_buf, msg, oob_buf);
		pdma_nand_irq_handle(nand, pipe_buf, oob_buf);
	}
}
Ejemplo n.º 17
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / PERIODIC_FREQUENCY), NULL);
  downlink_init();
  pprz_dl_init();
}
Ejemplo n.º 18
0
/********** INIT *************************************************************/
void init_fbw( void ) {

  mcu_init();

  electrical_init();

#ifdef ACTUATORS
  actuators_init();
  /* Load the failsafe defaults */
  SetCommands(commands_failsafe);
  fbw_new_actuators = 1;
#endif
#ifdef RADIO_CONTROL
  radio_control_init();
#endif
#ifdef INTER_MCU
  inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
  link_mcu_restart();
#endif

  fbw_mode = FBW_MODE_FAILSAFE;

  /**** start timers for periodic functions *****/
  fbw_periodic_tid = sys_time_register_timer((1./60.), NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);

#ifndef SINGLE_MCU
  mcu_int_enable();
#endif
}
Ejemplo n.º 19
0
int main(void)
{

  mcu_init();

  /*
   * Init threads
   */
  chThdCreateStatic(wa_thd_main_periodic_05, sizeof(wa_thd_main_periodic_05), NORMALPRIO, thd_main_periodic_05, NULL);


  while (1) {
    /* sleep for 1s */
    sys_time_ssleep(1);
    main_periodic_1();

    /* sleep for 0.42s */
    /*
    * sys_time_usleep(uint32_t us)
    * Use only for up to 2^32/CH_CFG_ST_FREQUENCY-1 usec
    * e.g. if CH_CFG_ST_FREQUENCY=10000 use max for 420000 us
    * or 420ms, otherwise overflow happens
	*/
    sys_time_usleep(420000);
    main_periodic_15();
  }

  return 0;
}
Ejemplo n.º 20
0
int main(void) {

  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);

  /* init RCC */
  rcc_peripheral_enable_clock(&RCC_APB2ENR, A_PERIPH);
  // rccp_perihperal_enable_clock(&RCC_APB2ENR, B_PERIPH);

  /* Init GPIO for rx pins */
  gpio_set(A_RX_PORT, A_RX_PIN);
  gpio_set_mode(A_RX_PORT, GPIO_MODE_INPUT,
          GPIO_CNF_INPUT_PULL_UPDOWN, A_RX_PIN);
  gpio_set(B_RX_PORT, B_RX_PIN);
  gpio_set_mode(B_RX_PORT, GPIO_MODE_INPUT,
          GPIO_CNF_INPUT_PULL_UPDOWN, B_RX_PIN);

  /* Init GPIO for tx pins */
  gpio_set_mode(A_RX_PORT, GPIO_MODE_OUTPUT_50_MHZ,
          GPIO_CNF_OUTPUT_PUSHPULL, A_TX_PIN);
  gpio_set_mode(B_RX_PORT, GPIO_MODE_OUTPUT_50_MHZ,
          GPIO_CNF_OUTPUT_PUSHPULL, B_TX_PIN);

  gpio_clear(A_TX_PORT, A_TX_PIN);

  /* */
  while (1) {
    if (sys_time_check_and_ack_timer(0))
      main_periodic();
    main_event();
  }

  return 0;
}
Ejemplo n.º 21
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_init();
  led_init();
  uart1_init_tx();
  mcu_int_enable();
}
Ejemplo n.º 22
0
void main(void)
{
  uint8_t payload[GZLL_MAX_PAYLOAD_LENGTH];

  mcu_init();
  gzll_init();

  // Set P0 as output
  P0DIR = 0;                                          

  EA = 1;
  
  // Enter host mode (start monitoring for data)
  gzll_rx_start();                                          
  
  for(;;)
  {      
    // If data received
    if(gzll_rx_fifo_read(payload, NULL, NULL))
    {
      // Write received payload[0] to port 0
      P0 = payload[0];
    }
  } 
}
Ejemplo n.º 23
0
/********** INIT *************************************************************/
void init_fbw( void ) {

  mcu_init();
  sys_time_init();
  electrical_init();

#ifdef ACTUATORS
  actuators_init();
  /* Load the failsafe defaults */
  SetCommands(commands_failsafe);
  fbw_new_actuators = 1;
#endif
#ifdef RADIO_CONTROL
  radio_control_init();
#endif
#ifdef INTER_MCU
  inter_mcu_init();
#endif
#ifdef MCU_SPI_LINK
  link_mcu_restart();
#endif

  fbw_mode = FBW_MODE_FAILSAFE;

#ifndef SINGLE_MCU
  mcu_int_enable();
#endif
}
Ejemplo n.º 24
0
/**
 * CAN test main function
 *
 * @return Nothing really...
 */
int main(void)
{
	int timer;
	uint8_t data[1];

	mcu_init();
	led_init();
	sys_tick_init();
	can_setup();

	timer = sys_tick_get_timer();

	data[0] = 10;

	while (true) {
		if (sys_tick_check_timer(timer, 10000)) {
			data[0]++;
			timer = sys_tick_get_timer();
#ifdef CAN__SEND
#ifdef CAN_ADDR
			can_trans(CAN_ADDR, data, 1);
#else
			can_trans(CAN__DEFAULT_ADDR, data, 1);
#endif
#endif
		}
	}
}
Ejemplo n.º 25
0
STATIC_INLINE void main_init( void ) {

  mcu_init();

  electrical_init();

  stateInit();

  actuators_init();
#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  air_data_init();
#if USE_BARO_BOARD
  baro_init();
#endif
  imu_init();
#if USE_IMU_FLOAT
  imu_float_init();
#endif
  ahrs_aligner_init();
  ahrs_init();

  ins_init();

#if USE_GPS
  gps_init();
#endif

  autopilot_init();

  modules_init();

  settings_init();

  mcu_int_enable();

#if DATALINK == XBEE
  xbee_init();
#endif

#if DATALINK == UDP
  udp_init();
#endif

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1./60.), NULL);
  failsafe_tid = sys_time_register_timer(0.05, NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
#if USE_BARO_BOARD
  baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
#endif
}
Ejemplo n.º 26
0
DRIVER_INIT_MEMBER(gstriker_state,vgoalsoc)
{
	m_gametype = 3;
	mcu_init( machine() );

	machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0x200090, 0x200091, write16_delegate(FUNC(gstriker_state::vbl_toggle_w),this)); // vblank toggle
	machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x200090, 0x200091, read16_delegate(FUNC(gstriker_state::vbl_toggle_r),this));
}
Ejemplo n.º 27
0
static DRIVER_INIT( vgoalsoc )
{
	gametype = 3;
	mcu_init( machine );

	memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200090, 0x200091, 0, 0, vbl_toggle_w); // vblank toggle
	memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200090, 0x200091, 0, 0, vbl_toggle_r);
}
Ejemplo n.º 28
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  main_init_hw();

  gyro_ready_for_read = FALSE;

}
Ejemplo n.º 29
0
void gstriker_state::init_vgoalsoc()
{
	m_gametype = VGOAL_SOCCER_MCU;
	mcu_init();

	m_maincpu->space(AS_PROGRAM).install_write_handler(0x200090, 0x200091, write16_delegate(FUNC(gstriker_state::vbl_toggle_w),this)); // vblank toggle
	m_maincpu->space(AS_PROGRAM).install_read_handler(0x200090, 0x200091, read16_delegate(FUNC(gstriker_state::vbl_toggle_r),this));
}
Ejemplo n.º 30
0
static inline void main_init( void ) {
  mcu_init();
  sys_time_init();
  main_init_hw();

  gyro_ready_for_read = FALSE;

}