feat(ex04): better control char handling and commenting unused functions
This commit is contained in:
parent
87ba742807
commit
a1e53a911f
4 changed files with 10 additions and 40 deletions
|
|
@ -12,7 +12,7 @@ SERIAL=-P /dev/ttyUSB0 -b 115200
|
|||
SRC_DIR=src
|
||||
OBJ_DIR=build
|
||||
|
||||
SRC_FILES=main.c utils.c uart.c timer.c
|
||||
SRC_FILES=main.c utils.c uart.c
|
||||
OBJ_FILES=$(patsubst %.c,%.o,$(SRC_FILES))
|
||||
|
||||
SRC=$(addprefix $(SRC_DIR)/,$(SRC_FILES))
|
||||
|
|
|
|||
|
|
@ -94,6 +94,10 @@ int main(void) {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// this is a control char -> we dont want it !
|
||||
if (data < ' ' || data > '~')
|
||||
continue;
|
||||
uart_tx(data);
|
||||
|
||||
if (cursor + 1 >= BUFFERSIZE) {
|
||||
|
|
@ -119,6 +123,9 @@ int main(void) {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
// this is a control char -> we dont want it !
|
||||
if (data < ' ' || data > '~')
|
||||
continue;
|
||||
uart_tx('*');
|
||||
|
||||
if (cursor + 1 >= BUFFERSIZE) {
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "mystd.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define PRESCALER 256
|
||||
#define TIMER_FREQ (F_CPU / PRESCALER)
|
||||
|
||||
// at a high level:
|
||||
// Set the OC1B (PB2) pin as output
|
||||
// set the TIMER1 mode to COMPARE (CTC)
|
||||
// say to compare against OC1A
|
||||
// set the value to be compated at X count
|
||||
// say the presacler for the timer is 512
|
||||
//
|
||||
// all these information are on page ~140
|
||||
void timer1_init(void) {
|
||||
// Set PB1 (OC1A) as output
|
||||
DDRB |= _BV(PB1);
|
||||
|
||||
// CTC mode (WGM12 = 1)
|
||||
TCCR1B |= _BV(WGM12);
|
||||
|
||||
// Toggle OC1B on compare match (COM1B0 = 1)
|
||||
// TCCR1A |= _BV(COM1A0);
|
||||
|
||||
// Set compare values
|
||||
OCR1A = TIMER_FREQ / 2;
|
||||
|
||||
// Start timer with prescaler 256 (CS12)
|
||||
TCCR1B |= _BV(CS12);
|
||||
|
||||
// set OCR1A interrupt
|
||||
TIMSK1 = _BV(1);
|
||||
|
||||
sei();
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ void uart_sendstring(const char* str) {
|
|||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void uart_send_u8(uint8_t val) {
|
||||
char buf[4] = {0, 0, 0, 0};
|
||||
uint8_t idx = 0;
|
||||
|
|
@ -102,3 +102,4 @@ void uart_send_u16_hex(uint16_t val) {
|
|||
buf[3] = "0123456789abcdef"[(val >> 0) & 0x0F];
|
||||
uart_sendstring(buf);
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue