Exemple #1
0
/*
 *  ======== clockTickFxn ========
 *
 *  250ms Watchdog Timer interrupt handler.
 */
static void clockTickFxn(uintptr_t arg)
{
    /*
     * Bump Clock tick count by 249. 
     * Clock_tick() will bump it one more
     */
    ((ti_sysbios_knl_Clock_Module_State *)(&ti_sysbios_knl_Clock_Module__state__V))->ticks += 249;

    Clock_tick();
}
Exemple #2
0
/*
 *  ======== HdmiWa_tick ========
 */
Void HdmiWa_tick(UArg arg)
{
    if (module->matchTmrEnable) {
        /* If match timer is enabled, call only its ISR */
        HdmiWa_matchTmrIsr();
        return;
    }

    /* Provide Tick and periodic HdmiWa ISR */
    Clock_tick();
    HdmiWa_autoRldTmrIsr();
}
Exemple #3
0
int main(void)
{
	struct Clock_Struct clock;
	//char str_buf[CLOCK_STRING_LENGTH];

	buffer *rx_buf = NULL;
	buffer *tx_buf = NULL;

	uint8_t bytes_read;

	GPIO_init();
	Timer_init();
	UART_init();
	NVIC_init();

	// 16000000hz
	// 0.0000000625s
	//
	// prescale 16000
	// 1000hz
	// 0.001s

	Clock_reset(&clock);

	Timer_set_mode(WTIMER0A, PERIODIC);
	Timer_set_config(WTIMER0A, INDEPENDENT);
	Timer_set_prescale(WTIMER0A, 16000);
	Timer_set_load(WTIMER0A, _wide_timer_load);
	Timer_enable_interrupt(WTIMER0A);
	Timer_enable(WTIMER0A);

	/*Timer_set_mode(TIMER0A, PERIODIC);
	Timer_set_config(TIMER0A, INDEPENDENT);
	Timer_set_prescale(TIMER0A, 160);
	Timer_set_load(TIMER0A, 50000);
	Timer_enable_interrupt(TIMER0A);
	Timer_enable(TIMER0A);*/

	tx_buf = get_buffer();
	strncpy(tx_buf->buf, "Clock application starting...\n\r", 32);
	tx_buf->fill = 32;
	UART_tx_message(tx_buf);
	tx_buf = NULL;

	tx_buf = get_buffer();
	Clock_to_string(&clock, tx_buf->buf, CLOCK_STRING_LENGTH);
	tx_buf->fill = CLOCK_STRING_LENGTH;
	UART_tx_message(tx_buf);
	tx_buf = NULL;

	while (1)
	{
		if (_output_flag)
		{
			Clock_tick(&clock);
			if (_current_time_message_flag)
			{
				/*str_buf = get_buffer();
				Clock_to_string(&clock, str_buf->buf, CLOCK_STRING_LENGTH);
				str_buf->fill = CLOCK_STRING_LENGTH;
				//UART_out_string(str_buf);
				UART_tx_message(str_buf);*/

				tx_buf = get_buffer();
				Clock_to_string(&clock, tx_buf->buf, CLOCK_STRING_LENGTH);
				tx_buf->fill = CLOCK_STRING_LENGTH;
				UART_tx_message(tx_buf);
				tx_buf = NULL;
			}
			_output_flag = 0;
		}

		// UART RX FIFO is half filled
		if (_rx_fill_flag)
		{
			if (rx_buf == NULL)
			{
				rx_buf = UART_rx_message();
			}

			bytes_read = UART_read_bytes(rx_buf->buf + rx_buf->fill, FILL_LEVEL_BYTES);
			rx_buf->fill += bytes_read;

			_rx_carriage_return_received_flag = received_carriage_return(rx_buf->buf + rx_buf->fill, bytes_read);

			_rx_fill_flag = 0;
		}

		// UART RX FIFO timed out
		if (_rx_timeout_flag)
		{
			if (rx_buf == NULL)
			{
				rx_buf = UART_rx_message();
			}

			bytes_read = UART_read_bytes(rx_buf->buf + rx_buf->fill, FILL_LEVEL_BYTES);
			rx_buf->fill += bytes_read;

			_rx_carriage_return_received_flag = received_carriage_return(rx_buf->buf + rx_buf->fill, bytes_read);
			_rx_timeout_flag = 0;
		}

		if (_rx_carriage_return_received_flag)
		{
			rx_buf->buf[(rx_buf->fill)++] = '\n';
			rx_buf->buf[(rx_buf->fill)++] = '\0';

			_rx_input_flag = 1;
			_rx_carriage_return_received_flag = 0;
		}

		if (_rx_input_flag)
		{
			char h_str[3];
			char m_str[3];
			uint8_t h;
			uint8_t m;

			_rx_input_command_enum = parse_command(rx_buf->buf);
			switch (_rx_input_command_enum)
			{
				case SET_TIME:
					h_str[0] = rx_buf->buf[1];	m_str[0] = rx_buf->buf[4];
					h_str[1] = rx_buf->buf[2];	m_str[1] = rx_buf->buf[5];
					h_str[2] = '\0';			m_str[2] = '\0';
					h = atoi(h_str);
					m = atoi(m_str);
					Clock_set(&clock, h, m, 0);
					break;
				case PAUSE:
					pause_output();
					break;
				case CONTINUE:
					continue_output();
					break;
				case FASTER:
					faster_timer();
					break;
				case SLOWER:
					slower_timer();
					break;
				case INVALID:
				default:
					break;
			}

			tx_buf = rx_buf;
			rx_buf = NULL;

			_rx_input_flag = 0;
		}

		if (tx_buf != NULL)
		{
			if (_rx_input_command_enum != INVALID)
			{
				UART_tx_message(tx_buf);
				tx_buf = NULL;
			}
			else
			{
				release_buffer(tx_buf);
				tx_buf = NULL;
			}
		}

		if (_button_pressed_flag)
		{
			tx_buf = get_buffer();
			strncpy(tx_buf->buf, "Button Pressed\r\n", 17);
			tx_buf->fill = 17;
			UART_tx_message(tx_buf);
			tx_buf = NULL;

			_button_pressed_flag = 0;
		}
	}

	buffer_queue_clean();
}