Remove UART
This commit is contained in:
parent
57a0c0979b
commit
f657a7d0c7
@ -54,10 +54,6 @@ extern "C" {
|
|||||||
|
|
||||||
#endif /* XC_HEADER_TEMPLATE_H */
|
#endif /* XC_HEADER_TEMPLATE_H */
|
||||||
|
|
||||||
void USART3_init(void);
|
|
||||||
void USART3_sendChar(char c);
|
|
||||||
void USART3_sendString(char *str);
|
|
||||||
static int USART3_printChar(char c, FILE *stream);
|
|
||||||
void led_init(void);
|
void led_init(void);
|
||||||
void ADC0_init(void);
|
void ADC0_init(void);
|
||||||
void ADC0_start(void);
|
void ADC0_start(void);
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
#define F_CPU 4000000UL
|
#define F_CPU 4000000UL
|
||||||
#define RTC_PERIOD (511)
|
#define RTC_PERIOD (511)
|
||||||
#define DELAY_TIME 1000
|
#define DELAY_TIME 1000
|
||||||
#define USART3_BAUD_RATE(BAUD_RATE) ((float) (64*F_CPU /(16*(float)BAUD_RATE) )+0.5)
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
@ -16,23 +15,12 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static FILE USART_stream = FDEV_SETUP_STREAM(USART3_printChar, NULL, _FDEV_SETUP_WRITE);
|
|
||||||
|
|
||||||
void sensor_init(void) {
|
void sensor_init(void) {
|
||||||
/* Disable digital input buffer */
|
/* Disable digital input buffer */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void USART3_init(void) {
|
|
||||||
PORTB.DIRCLR &= ~PIN1_bm;
|
|
||||||
PORTB.DIRSET |= PIN0_bm;
|
|
||||||
PORTB.DIRCLR = PIN2_bm;
|
|
||||||
PORTB.PIN2CTRL |= PORT_PULLUPEN_bm;
|
|
||||||
USART3.CTRLB |= USART_RXEN_bm | USART_TXEN_bm; /* Enable both TX and
|
|
||||||
RX */
|
|
||||||
USART3.BAUD = USART3_BAUD_RATE(9600); /* Setting the baudrate */
|
|
||||||
}
|
|
||||||
|
|
||||||
void ADC0_init(void) {
|
void ADC0_init(void) {
|
||||||
PORTD.PIN6CTRL &= ~PORT_ISC_gm;
|
PORTD.PIN6CTRL &= ~PORT_ISC_gm;
|
||||||
PORTD.PIN6CTRL |= PORT_ISC_INPUT_DISABLE_gc;
|
PORTD.PIN6CTRL |= PORT_ISC_INPUT_DISABLE_gc;
|
||||||
@ -46,23 +34,6 @@ void ADC0_init(void) {
|
|||||||
ADC0.MUXPOS = ADC_MUXPOS_AIN6_gc;
|
ADC0.MUXPOS = ADC_MUXPOS_AIN6_gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void USART3_sendChar(char c) {
|
|
||||||
while (!(USART3.STATUS & USART_DREIF_bm)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
USART3.TXDATAL = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void USART3_sendString(char *str) {
|
|
||||||
for (size_t i = 0; i < strlen(str); i++) {
|
|
||||||
USART3_sendChar(str[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int USART3_printChar(char c, FILE *stream) {
|
|
||||||
USART3_sendChar(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ADC0_read(void) {
|
uint16_t ADC0_read(void) {
|
||||||
/* Start ADC conversion */
|
/* Start ADC conversion */
|
||||||
@ -88,9 +59,7 @@ bool ADC0_conversationDone(void) {
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
sensor_init();
|
sensor_init();
|
||||||
ADC0_init();
|
ADC0_init();
|
||||||
USART3_init();
|
|
||||||
stdout = &USART_stream;
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
//printf("loop\n");
|
//printf("loop\n");
|
||||||
if (ADC0_conversationDone()) {
|
if (ADC0_conversationDone()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user