From 8fef07135aaa65f8f163bf1791c53b49ef0f3f9d Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sat, 15 Mar 2025 16:12:09 +0100 Subject: [PATCH] init mod06 --- module06/ex00/header.h | 15 +++------------ module06/ex00/main.c | 28 +++++++--------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/module06/ex00/header.h b/module06/ex00/header.h index 810b00f..9cd2b9d 100644 --- a/module06/ex00/header.h +++ b/module06/ex00/header.h @@ -21,18 +21,9 @@ extern volatile uint8_t adc_channel; // PROTOTYPES // // main.c -// timer.c -void timer_1B_init(); -// math.c -void int_to_hex_string(uint64_t value, char *out, uint8_t num_digits); -// adc.c -void adc_init(uint8_t prescaler_value); -uint16_t adc_read(uint8_t channel); -// uart.c -void uart_init(); -void uart_tx(char c); -void uart_printstr(const char* str); -void uart_printstr_endl(const char* str); +void i2c_init(void); +void i2c_start(void); +void i2c_stop(void); // // MACROS diff --git a/module06/ex00/main.c b/module06/ex00/main.c index a6c84a4..2299fe4 100644 --- a/module06/ex00/main.c +++ b/module06/ex00/main.c @@ -1,29 +1,15 @@ #include "header.h" -// 1.1.7 : AVCC is the supply voltage pin for the A/D Converter, PC3:0, and ADC7:6 -// 1.1.8 : AREF is the analog reference pin for the A/D Converter -// 24.4 : frequency needs to be between 50kHz and 200kHz, for less than 10bits accuracy it can be >200kHz -// -> Frequence_ADC = Frequance_CPU / Prescaler (Fadc = Fcpu/P): -// - P = 2 -> Fadc = 16,000,000 / 2 = 8,000,000 = 8MHz -// - P = 4 -> Fadc = 16,000,000 / 4 = 4,000,000 = 4MHz -// - P = 8 -> Fadc = 16,000,000 / 8 = 2,000,000 = 2MHz -// - P = 16 -> Fadc = 16,000,000 / 16 = 1,000,000 = 1MHz -// - P = 32 -> Fadc = 16,000,000 / 32 = 500,000 = 500KHz -// - P = 64 -> Fadc = 16,000,000 / 64 = 250,000 = 250KHz -> OK -// - P = 128 -> Fadc = 16,000,000 / 128 = 125,000 = 125KHz -> OK +void i2c_init(void) { +} +void i2c_start(void) { +} +void i2c_stop(void) { +} -#define ADC_PRESCALER 64 // Table 24-5 : can only be 2, 4, 8, 16, 32, 64, or 128 - -volatile uint8_t adc_channel = 0; - -// read potentiometer value and print it in uart as hexadecimal 2-number +// description int main() { - char buffer[4]; - SREG |= ENABLE_GLOBAL_INTERRUPT; // 7.3.1 : Status Register, bit 7 : I – Global Interrupt Enable - uart_init(); - adc_init(ADC_PRESCALER); - timer_1B_init(); while(1); }