-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
42 lines (32 loc) · 859 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* SMBus_Bridge.c
*
* Created: 6/28/2024 7:23:56 AM
* Author : aparady
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include "bridge_commands_328P.h"
#include "peripheral_drivers_328P.h"
#include "errors_328P.h"
uint8_t I2C_status = I2C_NO_ERROR;
int main(void)
{
DDRB |= 0b001111111; // Make PB0-5 outputs for error indicators
PORTB &= ~(0b00111111); // Make PB0-5 LOW by default
DDRD |= 0b11100000; // Make PD7/6/5 an output
PORTD |= 0b01000000; // Make PD6 HIGH by default for negative pulses
DDRC |= 0b00110000; // Make only the I2C pins (PC4/5) outputs
UART_init(1000000, 1);
I2C_init();
/* Replace with your application code */
while (1)
{
if (I2C_status != I2C_NO_ERROR){
PORTB |= (1 << PORTB5);
}else{
PORTB &= ~(1 << PORTB5);
}
I2C_status = UART_receive_array(I2C_status);
}
}