You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.0 KiB
123 lines
3.0 KiB
#include "main.h"
|
|
#include "delay.h"
|
|
#include "deviceSetup.h"
|
|
#include "usart.h"
|
|
#include "ascii.h"
|
|
#include "timer.h"
|
|
#include "i2c.h"
|
|
#include "ssd1306_i2c.h"
|
|
#include "lcd_oled.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
uint8_t i = 0;
|
|
uint16_t slaveAddress = 0xC0;
|
|
uint8_t registerToRead = 0x00;
|
|
uint8_t i2cRecieved = 0;
|
|
uint8_t i2cData = 0xFF;
|
|
|
|
i2c_t i2c_1 = { I2C_CH_1, /*!< The harware channel to be used */
|
|
i2c_mode_master, /*!< Master Mode */
|
|
0x00, /*!< First and Main address of the device */
|
|
0x00, /*!< Second address if dual addresse mode is configured */
|
|
i2c_address_count_single, /*!< Single address */
|
|
i2c_address_size_7b, /*!< 10 or 7 bit address size */
|
|
i2c_clk_speed_standart, /*!< Bus Speed: standart */
|
|
i2c_clk_stretching_disable, /*!< Clock Streching disabeled */
|
|
i2c_wake_disabled /*!< Wake up condition : None */
|
|
};
|
|
|
|
delayInitMs(8000000, 1000); // Clock Freq and Divider for ARM library
|
|
|
|
pinConfig(pinB3, output, pushPull, def_res, def_speed);
|
|
pinConfig(pinA0, input, def_stage, pullDown, def_speed);
|
|
|
|
setupInit(); // This is the sescond call of System init the assebly start code is calling it before the main.
|
|
|
|
usartInit( usart2,
|
|
pinA2,
|
|
pinA15,
|
|
115200,
|
|
eight,
|
|
NO_PARITY_CTRL,
|
|
noFlowControl);
|
|
|
|
//clears screen and send the wellcome messgae
|
|
print_Usart(usart2, ASCII_clear);
|
|
print_Usart(usart2, "Hello to our KED project\n\r");
|
|
|
|
|
|
//blinks 10 times to indicate the sicsessfull init if the device
|
|
for(i = 0 ; i < 2 ; i++) {
|
|
delayMs(100);
|
|
pinToggle(pinB3);
|
|
delayMs(100);
|
|
}
|
|
|
|
pinWrite(pinB3,0);
|
|
|
|
i2c_init(&i2c_1);
|
|
|
|
slaveAddress = SSD1306_I2C_ADDRESS;
|
|
registerToRead = 0x02;
|
|
registerToRead = 0x06;
|
|
i2cData = 0xAA;
|
|
uint8_t text[30]="KED Wellcomes You";
|
|
|
|
i2c_check_device(&i2c_1, &slaveAddress);
|
|
|
|
/* Pin Connections of of OLED
|
|
* GND = GND
|
|
* VCC = 5V
|
|
* DO = SCL
|
|
* D1 = SDA
|
|
* RES = Require a low to high transition
|
|
* DC = GND
|
|
* CS = GND
|
|
* ADDRESS = 0X3C
|
|
* FOR I2C opperation
|
|
* -> R4 & R1 : Has resistor | R2 & R3 : Has no Resistor
|
|
* -> R8 Needs to be bridged
|
|
*/
|
|
|
|
lcd_oled_init(&i2c_1 , SSD1306_I2C_ADDRESS);
|
|
lcd_oled_display(); //Adafruit logo is visible
|
|
delayMs(500);
|
|
|
|
lcd_oled_clear();
|
|
|
|
lcd_oled_print_text(0,5,text,18,WHITE);
|
|
lcd_oled_draw_line(64, 32, 0, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 45, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 90, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 135, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 180, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 225, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 270, 10, WHITE);
|
|
lcd_oled_draw_line(64, 32, 315, 10, WHITE);
|
|
|
|
lcd_oled_draw_circle(64, 32, 15, EMPTY, WHITE);
|
|
lcd_oled_draw_circle(10, 30, 10, FILLED, WHITE);
|
|
|
|
lcd_oled_draw_rectangle(10, 50, 10, 10, EMPTY, WHITE);
|
|
lcd_oled_draw_rectangle(30, 50, 10, 10, FILLED, WHITE);
|
|
|
|
|
|
lcd_oled_display(&i2c_1);
|
|
|
|
|
|
|
|
print_Usart(usart2, "\n\r");
|
|
print_Usart(usart2, "All Is Working fine ");
|
|
print_Usart(usart2, "\n\r");
|
|
|
|
while(1)
|
|
{
|
|
delayMs(100);
|
|
pinToggle(pinB3);
|
|
delayMs(100);
|
|
}
|
|
|
|
return 1;
|
|
}
|