예제 #1
0
void uart_send_str ( char * str )
{
    if ( str != NULL )
    {
        char * end = str + UART_OUT_BUFFER_SIZE;

        while ( str != end )
        {
            if ( *str == '\0' ) break;

            uart_send_char ( *str );

            str++;
        }

        if( str == end )
        {
#if( FEATURE_RED_LED )
            led_red_on();
#endif
        }
    }
    else
    {
#if( FEATURE_RED_LED )
        led_red_on();
#endif
    }
}
예제 #2
0
파일: main.c 프로젝트: PaulMougel/msp430
int main(void)
{
  uint8_t data;
  watchdog_stop();
  
  set_mcu_speed_dco_mclk_16MHz_smclk_8MHz();

  led_red_on();
  
  uart_init(UART_9600_SMCLK_8MHZ);
  serial_ring_init();
  uart_register_cb( serial_cb);
  
  printf("serial test application: echo\n");
  led_green_on();
  eint();
  
  for(;;)
    {
      LPM(1);
      
      if (serial_ring_get(&data))
	{
	  putchar(data);
	  led_green_switch();
	}
      else
	{
	  printf("\n\n serial_ring_get() returns 0 : empty ring\n\n");
	  led_red_switch();
	}
    }
}
예제 #3
0
void hal_clocksource_init(void){
    //for debugging clocksource problems
    led_red_on();
    led_green_on();

    //power up osc (?)
    SLEEP &= ~CLOCKSOURCE_OSC_PD_BIT;
    //wait for XOSC stable
    while(!CLOCKSOURCE_XOSC_STABLE()){}
    NOP();

    //start crystal osc as HS clocksource, OSC32 is int rc osc
    CLKCON = 0x80;

    //wait for selection to be active
    while(!CLOCKSOURCE_XOSC_STABLE()){}
    NOP();

    //power down the unused oscillator
    SLEEP |= CLOCKSOURCE_OSC_PD_BIT;


    //for debugging clocksource problems
    led_red_off();
    led_green_off();
}
예제 #4
0
파일: bcm2836_gpio.c 프로젝트: xdai/smiley
void
led_red_blink(int ms)
{
    led_red_on();
    stall(ms);
    led_red_off();
    stall(ms);
}
예제 #5
0
void show_boot_progress(int status)
{
	printf ("Status: %d\n", status);
        led_red_off();
	led_blue_off();

	if (status < -2 ) {
		led_red_on();
		return;
	}
	switch(status){
		case -1: /* Image Header has bad magic number */
			led_red_on();
			break;
						
                case 1:
                        break;
                case 2:
                        break;
                case 3:
                        break;
                case 4:
                        break;
                case 5:
                case 6:
                        break;
                case 7:
                case 8:	/* Image Type check ok */
			led_blue_on();
                        break;
                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15: /* All preparation done, transferring control to OS */
			led_blue_on();
                        break;
                default:
                        break;
        }
}
예제 #6
0
int8_t module(void *state, Message *msg)
#endif
{
  app_state *s = (app_state*) state;
  uint8_t data[1];
  switch (msg->type){
  case MSG_INIT:
	{
	  s->pid = msg->did;
	  s->state = BLUE_OFF_IDLE;
	  if (ker_pushbutton_register(s->pid)==-EINVAL) {led_red_on();}
	  break;
	}
  case MSG_PUSHBUTTON_PRESSED:
	{
	  if (s->state == BLUE_OFF_IDLE)
		{
		  s->state = BLUE_ON_BUSY;
		  s->data = 0x41;
		  ker_i2c_send_data(IRMAN_ADDRESS, &(s->data), 1, s->pid);
		  led_yellow_toggle();
		}
	  else if (s->state == BLUE_ON_IDLE)
		{
		  s->state = BLUE_OFF_BUSY;
		  s->data = 0x40;
		  ker_i2c_send_data(IRMAN_ADDRESS, &(s->data), 1, s->pid);
		  led_yellow_toggle();
		}
	  break;
	}
  case MSG_I2C_SEND_DONE:
	{
	  if (s->state == BLUE_ON_BUSY)
		{
		  s->state = BLUE_ON_IDLE;
		  led_red_toggle();
		}
	  else if (s->state == BLUE_OFF_BUSY)
		{
		  s->state = BLUE_OFF_IDLE;
		  led_red_toggle();
		}
	  break;
	}
  case MSG_FINAL:
	{
	  ker_pushbutton_deregister(s->pid);
	  break;
	}
  }
  
  return SOS_OK;
}
예제 #7
0
void default_handler (void) {
	uint64_t i;
	led_red_on();
	while (1) {
		for (i=0; i<0x00FFFFF; i++) {}
		led_green_off();
		for (i=0; i<0x00FFFFF; i++) {}
		led_green_on();
	}
	while (1);
}
예제 #8
0
파일: led.c 프로젝트: nesl/sos-2x
int8_t ker_led(uint8_t action)
{
  switch (action){
  case LED_RED_ON:        led_red_on();        break;
  case LED_GREEN_ON:      led_green_on();      break;
  case LED_YELLOW_ON:     led_yellow_on();     break;
  case LED_RED_OFF:       led_red_off();       break;
  case LED_GREEN_OFF:     led_green_off();     break;
  case LED_YELLOW_OFF:    led_yellow_off();    break;
  case LED_RED_TOGGLE:    led_red_toggle();    break;
  case LED_GREEN_TOGGLE:  led_green_toggle();  break;
  case LED_YELLOW_TOGGLE: led_yellow_toggle(); break;
  }
  return 0;
}
예제 #9
0
파일: main.c 프로젝트: PaulMougel/msp430
int main(void)
{
    watchdog_stop();

    set_mcu_speed_dco_mclk_8MHz_smclk_1MHz();
    leds_init();

    led_red_on();
    for(;;)
    {
        delay_ms(1000);
        led_red_switch();
        led_green_switch();
    }
}
예제 #10
0
파일: error.c 프로젝트: cnvogelg/plip2slip
void error_worker(void)
{
  if(count > 0) {
    if(delay == 0) {
      toggle = 1 - toggle;
      if(toggle) {
        led_red_on();
      } else {
        led_red_off();
        count--;
      }
      delay = ERROR_SPEED;
    } else {
      delay--;
    }
  }
}
예제 #11
0
static void sfi_err_code_led_display(uint8_t errcode)
{
  uint8_t _led_display;				
  _led_display = errcode;				
  if (_led_display & 0x01)			
    led_yellow_on();				
  else					
    led_yellow_off();				
  _led_display >>= 1;				
  if (_led_display & 0x01)			
    led_green_on();				
  else					
    led_green_off();				
  _led_display >>= 1;				
  if (_led_display & 0x01)			
    led_red_on();				
  else					
    led_red_off();
  return;
}
예제 #12
0
void uart_send_char ( char c )
{
    UART_ENTER_CRITICAL();

    if ( is_full == TRUE )
    {
#if( FEATURE_RED_LED )
        led_red_on();
#endif
        UART_EXIT_CRITICAL();
        return;
    }

    uart_out_buff[uart_out_head++] = c;

    if ( uart_out_head >= UART_OUT_BUFFER_SIZE )
    {
        uart_out_head = 0;
    }

    if ( uart_out_head == uart_out_tail )
    {
        is_full = TRUE;
    }

    while ( uart_out_head != uart_out_tail  && UART_IS_EMPTY() )
    {
        UDR = uart_out_buff[ uart_out_tail++ ];

        if ( uart_out_tail >= UART_OUT_BUFFER_SIZE )
        {
            uart_out_tail = 0;
        }

        is_full = FALSE;
    }

    UART_EXIT_CRITICAL();
}
예제 #13
0
/**
 * Program entry point 
 */
int main(void) {
    setupHardware();
 
    /* 
     * Start the tasks defined within this file/specific to this demo. 
     */
    xTaskCreate( vUserTask1, ( signed portCHAR * ) "Task1", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( vUserTask2, ( signed portCHAR * ) "Task2", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( working_task, ( signed portCHAR * ) "Task3", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( vUserTask4, ( signed portCHAR * ) "Task4", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( spi_task, ( signed portCHAR * ) "Task5", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( protocol_task_runner, ( signed portCHAR * ) "Task6", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( motor_task, ( signed portCHAR * ) "Task7", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( uart0_receive_task_runner, ( signed portCHAR * ) "Task8", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( regulation_task_runner, ( signed portCHAR * ) "Task8", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
    xTaskCreate( joystick_task_runner, ( signed portCHAR * ) "Joystick", USERTASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );

     
    /* 
     * Setup semaphores.
     */
    lcd_buffer_mutex = xSemaphoreCreateMutex();
    if ( lcd_buffer_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    lcd_keyboard_port_mutex = xSemaphoreCreateMutex();
    if ( lcd_keyboard_port_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_one_speed_mutex = xSemaphoreCreateMutex();
    if ( motor_one_speed_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_two_speed_mutex = xSemaphoreCreateMutex();
    if ( motor_two_speed_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_one_direction_mutex = xSemaphoreCreateMutex();
    if ( motor_one_direction_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_two_direction_mutex = xSemaphoreCreateMutex();
    if ( motor_two_direction_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_one_position_mutex = xSemaphoreCreateMutex();
    if ( motor_one_position_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    motor_two_position_mutex = xSemaphoreCreateMutex();
    if ( motor_two_position_mutex == NULL )
    {
        led_red_on();
        while(1);
    }

	y_pos_mutex = xSemaphoreCreateMutex();
    if ( y_pos_mutex == NULL )
    {
        led_red_on();
        while(1);
    }

	x_pos_mutex = xSemaphoreCreateMutex();
    if ( x_pos_mutex == NULL )
    {
        led_red_on();
        while(1);
    }

	y_target_pos_mutex = xSemaphoreCreateMutex();
    if ( y_target_pos_mutex == NULL )
    {
        led_red_on();
        while(1);
    }

	x_target_pos_mutex = xSemaphoreCreateMutex();
    if ( x_target_pos_mutex == NULL )
    {
        led_red_on();
        while(1);
    }
     
    /* 
     * Setup queues.
     */
    motor_command_queue = xQueueCreate(16, sizeof( motor_command ) );
    if (motor_command_queue == NULL)
    {
        led_red_on();
        while(1);
    }
         
    motor_event_queue = xQueueCreate(16, sizeof( motor_event ) );
    if (motor_event_queue == NULL)
    {
        led_red_on();
        while(1);
    }
     
    spi_input_queue = xQueueCreate(16, sizeof( INT16U ) );
    if (spi_input_queue == NULL)
    {
        led_red_on();
        while(1);
    }
     
    spi_output_queue = xQueueCreate(16, sizeof( INT16U ) );
    if (spi_output_queue == NULL)
    {
        led_red_on();
        while(1);
    }
     
    ui_event_queue = xQueueCreate(16, sizeof( ui_event ) );
    if (ui_event_queue == NULL)
    {
        led_red_on();
        while(1);
    }
 
    uart_command_queue = xQueueCreate(16, sizeof( uart_command ) );
    if (uart_command_queue == NULL)
    {
        led_red_on();
        while(1);
    }
     
    /* 
     * Start the scheduler. 
     */
    vTaskStartScheduler();
 
    /* 
     * Will only get here if there was insufficient memory to create the idle task. 
     */
    return 1;
}
예제 #14
0
파일: serial_test.c 프로젝트: nesl/ragobots
SOS_MODULE
int8_t module(void *state, Message *msg)
{
  app_state *s = (app_state*) state;
  switch (msg->type){
  case MSG_INIT:
	{
	  s->pid = msg->did;
	  s->port = 1;
	  if (ker_pushbutton_register(s->pid)==-EINVAL) {led_red_on();}
	  s->state = OPTIONS;
	  ker_serial_write(s->pid, s->port, "*****WELCOME TO RAGOBOT V1.0*****\n\r", 35, 0);
	  ker_timer_start(s->pid, 0, TIMER_ONE_SHOT, 1000);
	  break;
	}
  case MSG_TIMER_TIMEOUT:
	{
	  if(s->state == OPTIONS) 
		{
		  s->state = READ;
		  ker_serial_write(s->pid, s->port, "Please Select From The Following Options:\n\r1. HELLO\n\r2. COOL\n\r", 62, 0);
		  if (ker_serial_read(s->pid, s->port, 1) != SOS_OK)
			led_yellow_on();
		}
	  break;
	}
  case MSG_UART1_READ_DONE:
	{
	  if (*(msg->data) == '1')
		{
		  ker_serial_write(s->pid, s->port, "> Hi, My name is Ragobot.\n\r", 27, 0);
		}
	  else if (*(msg->data) == '2')
		{
		  ker_serial_write(s->pid, s->port, "> Yes, Ragobots are cool!\n\r", 27, 0);
		}
	  else 
		{
		  ker_serial_write(s->pid, s->port, "> Invalid Selection. Please Try Again.\n\r", 40, 0);
		}
	  s->state = OPTIONS;
	  ker_timer_start(s->pid, 0, TIMER_ONE_SHOT, 1000);
	  break;
	}
  case MSG_PUSHBUTTON_PRESSED:
	{
	  s->port = (s->port + 1) % numports;
	  s->state = OPTIONS;
	  ker_serial_write(s->pid, s->port, "*****WELCOME TO RAGOBOT V1.0*****\n\r", 35, 0);
	  ker_timer_start(s->pid, 0, TIMER_ONE_SHOT, 1000);
	  break;
	}
  case MSG_FINAL:
	{
	  ker_timer_stop(s->pid, 0);
	  ker_pushbutton_deregister(s->pid);
	  break;
	}
  }
  
  return SOS_OK;
}
예제 #15
0
파일: main.c 프로젝트: PaulMougel/msp430
int main(void)
{
    watchdog_stop();

    TIMER_ID_INPUT = UINT_MAX;
    node_id = NODE_ID_UNDEFINED;

    /* protothreads init */
    int i;
    for(i = 0; i < NUM_PT; i++)
    {
        PT_INIT(&pt[i]);
    }

    /* clock init */
    set_mcu_speed_dco_mclk_16MHz_smclk_8MHz();

    /* LEDs init */
    leds_init();
    led_red_on();
    led_green_flag = 0;

    /* timer init */
    timerA_init();
    timerA_register_cb(&timer_tick_cb);
    timerA_start_milliseconds(TIMER_PERIOD_MS);

    /* button init */
    button_init();
    button_register_cb(button_pressed_cb);
    antibouncing_flag = 0;
    button_pressed_flag = 0;

    /* UART init (serial link) */
    uart_init(UART_9600_SMCLK_8MHZ);
    uart_register_cb(uart_cb);
    uart_flag = 0;
    uart_data = 0;

    /* ADC10 init (temperature) */
    adc10_start();

    /* radio init */
    spi_init();
    cc2500_init();
    cc2500_rx_register_buffer(radio_tx_buffer, PKTLEN);
    cc2500_rx_register_cb(radio_cb);
    cc2500_rx_enter();
    radio_rx_flag = 0;

    /* retrieve node id from flash */
    node_id = *((char *) NODE_ID_LOCATION);
    //printf("node id retrieved from flash: %d\r\n", node_id);

    button_enable_interrupt();
    __enable_interrupt();

    /* simple cycle scheduling */
    while(1) {
        /*thread_led_red(&pt[0]);
        thread_led_green(&pt[1]);
        thread_uart(&pt[2]);
        thread_antibouncing(&pt[3]);*/
        thread_process_msg(&pt[4]);
        thread_periodic_send(&pt[5]);
        /*thread_button(&pt[6]);*/
    }
}