program for conv1, universal converter before including conv2 code

Dependencies:   mbed-src

Fork of _8_CONV_1_SLAVE by Marek Trojan

Committer:
marcus255
Date:
Fri Jan 08 13:47:03 2016 +0000
Revision:
11:3f1020fcd090
Parent:
10:7eaae60dc9e4
Latest version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcus255 9:58c110e686f0 1 /*
marcus255 9:58c110e686f0 2 * Project: I2C to UART converter
marcus255 11:3f1020fcd090 3 * File: main.h
marcus255 11:3f1020fcd090 4 * Author: Marek Trojan
marcus255 9:58c110e686f0 5 */
marcus255 9:58c110e686f0 6
marcus255 0:ab0f6f4ef7ac 7 #ifndef MAIN_H
marcus255 0:ab0f6f4ef7ac 8 #define MAIN_H
marcus255 0:ab0f6f4ef7ac 9
marcus255 0:ab0f6f4ef7ac 10 #include <mbed.h>
marcus255 9:58c110e686f0 11 #define SET_CONV2_FUNCT 0x22
marcus255 9:58c110e686f0 12 #define UART_CONFIRMATION_CHAR 0x33
marcus255 9:58c110e686f0 13 #define UART_CHAR_INCOMING 0x44
marcus255 9:58c110e686f0 14 #define END_OF_TRANSMISSION 0x66
marcus255 9:58c110e686f0 15 #define DATA_TO_READ_CHAR 0x99
marcus255 0:ab0f6f4ef7ac 16 #define UART_NON_CONFIRMATION_CHAR 0xAA
marcus255 9:58c110e686f0 17 #define DATA_TO_WRITE_CHAR 0xCC
marcus255 9:58c110e686f0 18 #define I2C_FREQUENCY_STANDARD 100000 /* Hz */
marcus255 0:ab0f6f4ef7ac 19
marcus255 0:ab0f6f4ef7ac 20 I2CSlave slave(PTB4, PTB3);
marcus255 8:47ae8b74cd43 21 I2C i2c(PTB4, PTB3);
marcus255 0:ab0f6f4ef7ac 22 Serial device(USBTX, USBRX);
marcus255 0:ab0f6f4ef7ac 23 InterruptIn SDA_interrupt(PTB7);
marcus255 7:e86480c767ea 24 InterruptIn SCL_interrupt(PTA12);
marcus255 0:ab0f6f4ef7ac 25 DigitalIn SDA_state(PTB6);
marcus255 0:ab0f6f4ef7ac 26
marcus255 0:ab0f6f4ef7ac 27 char buffer;
marcus255 0:ab0f6f4ef7ac 28 int count;
marcus255 7:e86480c767ea 29 volatile int discovered_address;
marcus255 7:e86480c767ea 30 volatile int clk_count;
marcus255 7:e86480c767ea 31 int frequency;
marcus255 8:47ae8b74cd43 32 int transmission;
marcus255 0:ab0f6f4ef7ac 33
marcus255 7:e86480c767ea 34 void on_SDA_falling_slope_interrupt(void);
marcus255 7:e86480c767ea 35 void on_SCL_rising_slope_interrupt(void);
marcus255 8:47ae8b74cd43 36 void onUartChar(void);
marcus255 7:e86480c767ea 37
marcus255 8:47ae8b74cd43 38 void init_conv1(int, char);
marcus255 8:47ae8b74cd43 39 void init_conv2(int);
marcus255 7:e86480c767ea 40 void init_conv(void);
marcus255 0:ab0f6f4ef7ac 41
marcus255 0:ab0f6f4ef7ac 42 #endif