Ran clang-format on project files.
This commit is contained in:
parent
1f652b7c37
commit
427a5d1786
|
@ -13,7 +13,6 @@ void RegEdit_SetRegister(void *reg)
|
|||
*reg_ptr = 0xFF;
|
||||
}
|
||||
|
||||
|
||||
void RegEdit_ClearRegister(void *reg)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
|
@ -23,19 +22,19 @@ void RegEdit_ClearRegister(void *reg)
|
|||
void RegEdit_SetBit(void *reg, uint8_t bit_num)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
*reg_ptr |= (uint8_t)(1<<bit_num);
|
||||
*reg_ptr |= (uint8_t)(1 << bit_num);
|
||||
}
|
||||
|
||||
void RegEdit_ClearBit(void *reg, uint8_t bit_num)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
*reg_ptr &= ~(1<<bit_num);
|
||||
*reg_ptr &= ~(1 << bit_num);
|
||||
}
|
||||
|
||||
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
return *reg_ptr & (1<<bit_num);
|
||||
return *reg_ptr & (1 << bit_num);
|
||||
}
|
||||
|
||||
void RegEdit_OR_Num(void *reg, uint8_t num)
|
||||
|
@ -46,7 +45,6 @@ void RegEdit_OR_Num(void *reg, uint8_t num)
|
|||
|
||||
void RegEdit_AND_Num(void *reg, uint8_t num)
|
||||
{
|
||||
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
*reg_ptr &= num;
|
||||
}
|
||||
|
@ -57,7 +55,6 @@ void RegEdit_SetNum(void *reg, uint8_t num)
|
|||
*reg_ptr = num;
|
||||
}
|
||||
|
||||
|
||||
uint8_t RegEdit_ReadReg(void *reg)
|
||||
{
|
||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
#ifndef REGEDIT_H
|
||||
#define REGEDIT_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -75,4 +74,4 @@ void RegEdit_SetNum(void *reg, uint8_t num);
|
|||
*/
|
||||
uint8_t RegEdit_ReadReg(void *reg);
|
||||
|
||||
#endif //REGEDIT_H
|
||||
#endif // REGEDIT_H
|
||||
|
|
17
src/main.c
17
src/main.c
|
@ -11,28 +11,23 @@
|
|||
|
||||
#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
|
||||
#define __DELAY_BACKWARD_COMPATIBLE__
|
||||
|
||||
#include "config.h"
|
||||
#include "RegEdit.h"
|
||||
#include "config.h"
|
||||
#include "timer.h"
|
||||
#include <avr/cpufunc.h> /* Required header file */
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
||||
|
||||
//Set the function pointer for the delay func
|
||||
// Set the function pointer for the delay func
|
||||
void (*Delay_MicroSeconds)(double us) = _delay_us;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
|
||||
|
||||
while(true){
|
||||
; //Do nothing until new Power cycle/reset occurs
|
||||
while (true)
|
||||
{
|
||||
; // Do nothing until new Power cycle/reset occurs
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* @file module_name.h
|
||||
*/
|
||||
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
// dumb test function
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
#ifndef TIMER
|
||||
#define TIMER
|
||||
|
||||
|
||||
/**
|
||||
* A function that adds two to a number
|
||||
* @param a The first argument
|
||||
*/
|
||||
int add_two(int a);
|
||||
|
||||
|
||||
|
||||
#endif //TIMER
|
||||
#endif // TIMER
|
||||
|
|
|
@ -13,52 +13,50 @@
|
|||
#define F_PER F_CPU / 6
|
||||
#define USART0_BAUD_RATE(BAUD_RATE) ((float)(F_PER * 64 / (16 * (float)BAUD_RATE)) + 0.5)
|
||||
|
||||
//RX PIN6, TX PIN7
|
||||
//ALT: RX PIN12 TX PIN11
|
||||
// RX PIN6, TX PIN7
|
||||
// ALT: RX PIN12 TX PIN11
|
||||
void USART0_init(void)
|
||||
{
|
||||
//Config TxD as output, and rx as input?
|
||||
PORTB.DIR &= ~(1<<3);
|
||||
PORTB.DIR |= (1<<2);
|
||||
// Config TxD as output, and rx as input?
|
||||
PORTB.DIR &= ~(1 << 3);
|
||||
PORTB.DIR |= (1 << 2);
|
||||
|
||||
//setup Alternate pints on PA1 and PA2
|
||||
// setup Alternate pints on PA1 and PA2
|
||||
/*
|
||||
PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc;
|
||||
PORTA.DIRSET |= (1<<1);
|
||||
PORTA.DIRSET &= ~(1<<2);
|
||||
*/
|
||||
|
||||
//It says to set the TX pin high?
|
||||
//PORTB.OUT |= (1<<2);
|
||||
//PORTA.OUT |= (1<<11);
|
||||
// It says to set the TX pin high?
|
||||
// PORTB.OUT |= (1<<2);
|
||||
// PORTA.OUT |= (1<<11);
|
||||
|
||||
//set buad rate.
|
||||
// set buad rate.
|
||||
USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600);
|
||||
|
||||
//set the frame format.
|
||||
USART0.CTRLC = 0x3; //setting 8-bit mode.
|
||||
// set the frame format.
|
||||
USART0.CTRLC = 0x3; // setting 8-bit mode.
|
||||
|
||||
//Enable transmitter and receiver (USARTn.CTRLB)
|
||||
//USART0.CTRLB |= (1<<7)|(1<<6);
|
||||
// Enable transmitter and receiver (USARTn.CTRLB)
|
||||
// USART0.CTRLB |= (1<<7)|(1<<6);
|
||||
USART0.CTRLB |= USART_TXEN_bm;
|
||||
}
|
||||
|
||||
void USART0_sendChar(char c)
|
||||
{
|
||||
while (!(USART0.STATUS & USART_DREIF_bm)){
|
||||
while (!(USART0.STATUS & USART_DREIF_bm))
|
||||
{
|
||||
;
|
||||
}
|
||||
USART0.TXDATAL = c;
|
||||
USART0.TXDATAH = c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void USART0_sendString(char *str)
|
||||
{
|
||||
for(size_t i = 0; i < strlen(str); i++)
|
||||
for (size_t i = 0; i < strlen(str); i++)
|
||||
{
|
||||
USART0_sendChar(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#ifndef USART_H
|
||||
#define USART_H
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the USART0 peripheral.
|
||||
*/
|
||||
|
@ -28,6 +27,4 @@ void USART0_sendChar(char c);
|
|||
*/
|
||||
void USART0_sendString(char *str);
|
||||
|
||||
|
||||
|
||||
#endif //USART_H
|
||||
#endif // USART_H
|
||||
|
|
Loading…
Reference in New Issue