have example program running
This commit is contained in:
parent
2eb2253571
commit
6f878791e8
53
src/main.c
53
src/main.c
|
@ -9,6 +9,7 @@
|
||||||
* extracted into separate source files and headers for configuration.
|
* extracted into separate source files and headers for configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#define F_CPU 3333333UL
|
#define F_CPU 3333333UL
|
||||||
|
|
||||||
// This can prevent issues with utils/delay.h library with the gcc toolchain
|
// This can prevent issues with utils/delay.h library with the gcc toolchain
|
||||||
|
@ -22,28 +23,56 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
/*
|
|
||||||
char msg[] = "Attiny404:\n\r";
|
|
||||||
char maketime_msg[] = "Make Time(10Khz):";
|
|
||||||
char breaktime_msg[] = "Break Time(10Khz):";
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
//char msg[] = "Attiny404:\n\r";
|
||||||
|
char maketime_msg[] = "\r\nMake Time(10Khz):";
|
||||||
|
char hi_msg[] = " Hi byte: ";
|
||||||
|
char lo_msg[] = " Lo byte: ";
|
||||||
|
char overflow_count_msg[] = " Overflows: ";
|
||||||
|
//char breaktime_msg[] = "Break Time(10Khz):";
|
||||||
|
char hex_msg[3];
|
||||||
|
|
||||||
//Set the function pointer for the delay func
|
//Set the function pointer for the delay func
|
||||||
void (*Delay_MicroSeconds)(double us) = _delay_us;
|
void (*Delay_MicroSeconds)(double us) = _delay_us;
|
||||||
|
|
||||||
|
void delay_period()
|
||||||
|
{
|
||||||
|
Timer_Enable();
|
||||||
|
Timer_BlockingWait();
|
||||||
|
Timer_Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
//USART0_Init();
|
USART0_Init();
|
||||||
//Timer_Setup();
|
//Timer_SelectClock();
|
||||||
//Uart_Setup();
|
//Timer_Period();
|
||||||
PORTA.DIR |= (1<<7);
|
PORTA.DIR |= (1<<7);
|
||||||
|
|
||||||
|
uint16_t cnt = 0;
|
||||||
|
uint8_t hi, lo;
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
_delay_ms(500);
|
Timer_Start();
|
||||||
PORTA.OUT ^= (1<<7);
|
_delay_ms(250);
|
||||||
_delay_ms(500);
|
Timer_Disable();
|
||||||
PORTA.OUT ^= (1<<7);
|
cnt = Timer_GetOverflowCount();
|
||||||
|
|
||||||
|
USART0_sendString(maketime_msg);
|
||||||
|
|
||||||
|
hi = (uint8_t)(cnt >> 8);
|
||||||
|
lo = (uint8_t) (cnt & 0x00FF);
|
||||||
|
|
||||||
|
USART0_sendString(hi_msg);
|
||||||
|
USART0_sendChar(hi);
|
||||||
|
//USART0_sendString(hex_msg);
|
||||||
|
|
||||||
|
USART0_sendString(lo_msg);
|
||||||
|
USART0_sendChar(lo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
USART0_sendString(msg);
|
USART0_sendString(msg);
|
||||||
USART0_sendString(maketime_msg);
|
USART0_sendString(maketime_msg);
|
||||||
|
|
Loading…
Reference in New Issue