master
parent
e14f8b06aa
commit
5622103817
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file BitField.h
|
|
||||||
* @author Edwin Koch (eddyed.k@gmail.com)
|
|
||||||
* @brief
|
|
||||||
* @version 0.1
|
|
||||||
* @date 2020-12-19
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2020
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Based on:
|
|
||||||
// https://www.youtube.com/watch?v=TYqbgvHfxjM
|
|
||||||
// https://stackoverflow.com/questions/31726191/is-there-a-portable-alternative-to-c-bitfields
|
|
||||||
// https://stackoverflow.com/questions/1392059/algorithm-to-generate-bit-mask
|
|
||||||
#ifndef _BITFIELDS_HPP_
|
|
||||||
#define _BITFIELDS_HPP_
|
|
||||||
#include <stdint.h>
|
|
||||||
/**
|
|
||||||
* @brief Template class for portable Bitfields
|
|
||||||
*
|
|
||||||
* @tparam T type of variable in which the bitfield resides
|
|
||||||
* @tparam START bit index starting from LSB where the bitfield starts
|
|
||||||
* @tparam SIZE number of bits
|
|
||||||
*/
|
|
||||||
template<typename T, uint8_t START, uint8_t SIZE>
|
|
||||||
struct BitField
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @brief Construct a new Bit Field object
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
BitField()
|
|
||||||
{
|
|
||||||
static_assert(SIZE != 0, "Bitfield SIZE must be > 0!");
|
|
||||||
static_assert(START < sizeof(T) * 8, "START exceeds number of bits of the chosen typename T!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief assignment operator
|
|
||||||
*
|
|
||||||
* @param v value to be written in the bitfield
|
|
||||||
* @return BitField&
|
|
||||||
*/
|
|
||||||
BitField& operator =(T v)
|
|
||||||
{
|
|
||||||
// use bit band alias if system permits
|
|
||||||
_raw = ((v & ((1ULL << SIZE)-1)) << START) | (_raw & ~(((1ULL << SIZE)-1) << START));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief return the value inside the bitfield
|
|
||||||
*
|
|
||||||
* @return T
|
|
||||||
*/
|
|
||||||
operator T() const
|
|
||||||
{
|
|
||||||
return (_raw >> START) & ((1ULL << SIZE) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief return the raw value
|
|
||||||
*
|
|
||||||
* @return T
|
|
||||||
*/
|
|
||||||
T operator ()() const
|
|
||||||
{
|
|
||||||
return (_raw >> START) & ((1ULL << SIZE) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T _raw;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _BITFIELDS_HPP_
|
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Authors : Kerem Yollu & Edwin Koch
|
|
||||||
* Date : 07.03.2021
|
|
||||||
* Version : 0.1
|
|
||||||
* License : MIT-0
|
|
||||||
*
|
|
||||||
* Description : An easy way to intereact with argv for passing commands.
|
|
||||||
*
|
|
||||||
* TODO : Inplement singleton pattern
|
|
||||||
* TODO : Write description
|
|
||||||
* TODO : Comment the code wiht odxygen
|
|
||||||
* TODO : write a standart string Output function and implment it (will come with the BSL) 08.08.21
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "commandManager.h"
|
|
||||||
|
|
||||||
|
|
||||||
CommandManager::CommandManager():emptyIndex(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandManager::addNewCommand( const std::string& commmand,
|
|
||||||
const std::string& description,
|
|
||||||
commanCallback_t callBack)
|
|
||||||
{
|
|
||||||
if(emptyIndex >= MAX_MUNBER_OF_COMMANDS) // Check if the command list is full
|
|
||||||
{
|
|
||||||
std::cout << "Error | Intern | Command list is full!" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if(getLookUpIndex(commmand) >= 0) // Chek for command duplicats
|
|
||||||
{
|
|
||||||
std::cout << "Error | Intern | Command already exitst!" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
commandLookup[emptyIndex].commmand = commmand;
|
|
||||||
commandLookup[emptyIndex].description = description;
|
|
||||||
commandLookup[emptyIndex].callBack = callBack;
|
|
||||||
emptyIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandManager::operator()(const std::string cmdName)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
if(cmdName == "help" || cmdName == "Help")
|
|
||||||
{
|
|
||||||
printHelp();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cmdName == "-h" || cmdName == "-H")
|
|
||||||
{
|
|
||||||
printCommads();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
index = getLookUpIndex(cmdName);
|
|
||||||
|
|
||||||
if(index < 0)
|
|
||||||
{
|
|
||||||
std::cout << "Error | Intern | Invalid Command!" << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
commandLookup[index].callBack();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Privat memeber functions
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
int CommandManager::getLookUpIndex(const std::string& cmd)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
for (index = 0; index < emptyIndex; index++)
|
|
||||||
{
|
|
||||||
if(commandLookup[index].commmand == cmd)
|
|
||||||
{
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandManager::printHelp()
|
|
||||||
{
|
|
||||||
std::cout << "Function : printHelp is under construction" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandManager::printCommads()
|
|
||||||
{
|
|
||||||
std::cout << "Function : printCommads is under construction" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Authors : Kerem Yollu & Edwin Koch
|
|
||||||
* Date : 07.03.2021
|
|
||||||
*
|
|
||||||
* Description :
|
|
||||||
* TODO : Inplement singleton pattern
|
|
||||||
* TODO : Write description
|
|
||||||
* TODO : Comment the code wiht odxygen
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _COMMMANDMANAGER_H_
|
|
||||||
#define _COMMMANDMANAGER_H_
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <array>
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#define MAX_MUNBER_OF_COMMANDS 10
|
|
||||||
|
|
||||||
class CommandManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::function<void(void)> commanCallback_t;
|
|
||||||
CommandManager();
|
|
||||||
void addNewCommand( const std::string& commmand,
|
|
||||||
const std::string& description,
|
|
||||||
commanCallback_t callBack);
|
|
||||||
|
|
||||||
void operator()(const std::string cmdName);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned int emptyIndex;
|
|
||||||
|
|
||||||
struct commant_t{
|
|
||||||
std::string commmand;
|
|
||||||
std::string description;
|
|
||||||
commanCallback_t callBack; // The Callback function could only be a void returning a void.
|
|
||||||
};
|
|
||||||
|
|
||||||
std::array <commant_t, MAX_MUNBER_OF_COMMANDS> commandLookup;
|
|
||||||
int getLookUpIndex(const std::string& cmd); // If command exists retunrs the index otherwise -1
|
|
||||||
void printHelp(); // Prints all awailbale commands and their description.
|
|
||||||
void printCommads(); // Prints all awailable commnads without description.
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _COMMMANDMANAGER_H_
|
|
@ -1,14 +0,0 @@
|
|||||||
#include "graphics.h"
|
|
||||||
|
|
||||||
display_s *lcd;
|
|
||||||
|
|
||||||
void display_init(display_s *d)
|
|
||||||
{
|
|
||||||
lcd = d;
|
|
||||||
printf("LCD : Init Ok\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_print(int val)
|
|
||||||
{
|
|
||||||
lcd->print(val);
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
typedef struct display
|
|
||||||
{
|
|
||||||
int size_x,size_y;
|
|
||||||
void (*enable)();
|
|
||||||
void (*disable)();
|
|
||||||
|
|
||||||
void (*reset_hard)();
|
|
||||||
void (*reset_soft)();
|
|
||||||
|
|
||||||
uint8_t (*is_ready)();
|
|
||||||
|
|
||||||
void (*sleep)();
|
|
||||||
void (*wake)();
|
|
||||||
|
|
||||||
void (*draw_pixel)(uint16_t, uint16_t, uint8_t);
|
|
||||||
void (*draw_line)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t);
|
|
||||||
void (*draw_rectangle)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t, uint8_t);
|
|
||||||
void (*draw_circle)(uint16_t, uint16_t, uint16_t, uint8_t, uint8_t);
|
|
||||||
|
|
||||||
void (*scroll_right)(uint16_t, uint16_t);
|
|
||||||
void (*scroll_left)(uint16_t, uint16_t);
|
|
||||||
|
|
||||||
void (*scroll_up)(uint16_t, uint16_t);
|
|
||||||
void (*scroll_down)(uint16_t, uint16_t);
|
|
||||||
|
|
||||||
void (*set_font)(uint8_t*, uint8_t, uint8_t spacing);
|
|
||||||
void (*print_char)(uint16_t, uint16_t, uint8_t, uint8_t);
|
|
||||||
void (*print_text)(uint16_t, uint16_t, uint8_t, uint16_t, uint8_t);
|
|
||||||
void (*print_cursor)(uint8_t);
|
|
||||||
|
|
||||||
void (*goto_pos)(uint16_t, uint16_t);
|
|
||||||
|
|
||||||
uint8_t (*display)();
|
|
||||||
uint8_t (*clear)();
|
|
||||||
|
|
||||||
void (*change_brightness)(uint8_t);
|
|
||||||
void (*change_contrast)(uint8_t);
|
|
||||||
|
|
||||||
void (*rotate)(uint8_t);
|
|
||||||
void (*inverse)(uint8_t);
|
|
||||||
void (*invert)(uint8_t);
|
|
||||||
void (*print)(int);
|
|
||||||
} display_s;
|
|
||||||
|
|
||||||
void display_init(display_s *d);
|
|
||||||
void display_print(int val);
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ui.h"
|
|
||||||
|
|
||||||
|
|
||||||
display_s display;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
oled_init(&display);
|
|
||||||
display_init(&display);
|
|
||||||
ui_print_number(50);
|
|
||||||
display_print(10);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "oled.h"
|
|
||||||
|
|
||||||
void oled_print(int a)
|
|
||||||
{
|
|
||||||
printf("oled_print(int a) : %d\n", a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_init(display_s *lcd)
|
|
||||||
{
|
|
||||||
lcd->size_x = 10;
|
|
||||||
lcd->size_y = 20;
|
|
||||||
lcd->print = &oled_print;
|
|
||||||
|
|
||||||
printf("LCD_OLED_REG : Init Ok\n");
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "graphics.h"
|
|
||||||
|
|
||||||
void oled_init(display_s *lcd);
|
|
||||||
void oled_print(int a);
|
|
||||||
|
|
Binary file not shown.
@ -1,7 +0,0 @@
|
|||||||
#include "ui.h"
|
|
||||||
|
|
||||||
void ui_print_number(int num)
|
|
||||||
{
|
|
||||||
printf("UI : Init Ok\n");
|
|
||||||
display_print(33);
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "oled.h"
|
|
||||||
|
|
||||||
void ui_print_number(int num);
|
|
||||||
void ui_init();
|
|
||||||
|
|
@ -1,12 +1,34 @@
|
|||||||
#Declareing header directory for the project
|
###################################################################################################
|
||||||
#To add a new directory
|
# Declaring new directories to be added to the project
|
||||||
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
###################################################################################################
|
||||||
# list() = List declaration "DON'T CHANGE"
|
# list() = List declaration "DON'T CHANGE"
|
||||||
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
# PROJECT_ADDITIONAL_DIRS = Variable containing the listed direcotries "DON'T CHANCE"
|
||||||
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
# . = This indicates that the root file needs to de included "DON'T REMOVE"
|
||||||
|
#
|
||||||
|
# To include a new folder containing headers or sources that you want to compile
|
||||||
|
# - The root of the project is where the main.c is located
|
||||||
|
# - Let's suppose your main.c is under : /home/yourUserName/YOurProjectName/main.c
|
||||||
|
# - If we Make a new "Src" folder under /home/yourUserName/YOurProjectName/Src
|
||||||
|
# - To add it to the project,
|
||||||
|
# - Just include the Direwctory name "Src" the the Declarion WITHOUT THE LAST "/"
|
||||||
|
# - the declaration should look like this : list(APPEND PROJECT_ADDITIONAL_DIRS . Src)
|
||||||
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
||||||
|
|
||||||
#Declaring sources to be compiled for the project.
|
###################################################################################################
|
||||||
#CMake will look in each previsouly declarec sources directory until to find this files.
|
# Declaring sources to be compiled for the project.
|
||||||
|
###################################################################################################
|
||||||
|
# KED will look in every PROJECT_ADDITIONAL_DIRS list an search for sources
|
||||||
|
# decalred by PROJECT_TO_COMPILE_LIST list
|
||||||
|
#
|
||||||
|
# To add a source file to the compilation
|
||||||
|
# - Let's continue where we left off for the Directory inclusion.
|
||||||
|
# - Now let's say you have source file named sensor.c located as follow :
|
||||||
|
# -> /home/yourUserName/YOurProjectName/Src/sensor.c
|
||||||
|
# - To let KED know that you want this source to be compiled, you simply ned to add it the list
|
||||||
|
# - This would look like this : set(PROJECT_TO_COMPILE_LIST sensors.c)
|
||||||
set(PROJECT_TO_COMPILE_LIST)
|
set(PROJECT_TO_COMPILE_LIST)
|
||||||
|
|
||||||
|
# If you still have some question please have a look under : ked/libraries/examples/
|
||||||
|
# There you can find some example projects with their corresponding "projectDefinitions.cmake".
|
||||||
|
# To try one of them just copy the entirety of one example folders contend to the root of your
|
||||||
|
# project where ked/ is located.
|
||||||
|
@ -1,189 +0,0 @@
|
|||||||
#include "main.h"
|
|
||||||
#include "delay.h"
|
|
||||||
#include "deviceSetup.h"
|
|
||||||
#include "usart.h"
|
|
||||||
#include "ascii.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#include "i2c.h"
|
|
||||||
|
|
||||||
void timer_test(timerNo_t timer, pinNo_t pin)
|
|
||||||
{
|
|
||||||
|
|
||||||
timerInitCounter(timer, 4000, 999, downCounting);
|
|
||||||
timerSart(timer);
|
|
||||||
|
|
||||||
for(int i = 0; i < 10 ; i++)
|
|
||||||
{
|
|
||||||
while(!timerGetUpdateInterrupt(timer));
|
|
||||||
timerClearUpdateInterrupt(timer);
|
|
||||||
pinToggle(pin);
|
|
||||||
}
|
|
||||||
pinWrite(pin,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void timer_capture_compare_test(timerNo_t timer)
|
|
||||||
{
|
|
||||||
uint16_t i = 0;
|
|
||||||
timerInitCounter(timer, 100, 99, downCounting);
|
|
||||||
// We use pin PA3 (Arduino header A2)
|
|
||||||
//timerInitOutputCompare(timer, toggle, 4, pinA3, 2,0, 300);
|
|
||||||
timerInitOutputCompare(timer, pwm_normal, 2, pinB3, 2,0, 900);
|
|
||||||
timerSart(timer);
|
|
||||||
|
|
||||||
while(1){
|
|
||||||
delayMs(200);
|
|
||||||
timerSetCounterCompareValue(timer, 2, i);
|
|
||||||
i += 10;
|
|
||||||
if(i>99) i = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void printBinary32(uint32_t toPrint, uint8_t lsbFirst)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char pt;
|
|
||||||
if(lsbFirst)
|
|
||||||
{
|
|
||||||
print_Usart(usart2, "Bit Pos | 0| 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|");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "Bits |");
|
|
||||||
for(i=0; i < 32; i++)
|
|
||||||
{
|
|
||||||
pt = (toPrint >> i) & 1;
|
|
||||||
usartSendChar(usart2, ' ');
|
|
||||||
usartSendChar(usart2, pt + 0x30);
|
|
||||||
usartSendChar(usart2, '|');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print_Usart(usart2, "Bit Pos |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "Bits |");
|
|
||||||
for(i=0; i < 32; i++)
|
|
||||||
{
|
|
||||||
pt = (toPrint >> (31-i)) & 1;
|
|
||||||
usartSendChar(usart2, ' ');
|
|
||||||
usartSendChar(usart2, pt + 0x30);
|
|
||||||
usartSendChar(usart2, '|');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void printBinary8(uint8_t toPrint, uint8_t lsbFirst)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char pt;
|
|
||||||
if(lsbFirst)
|
|
||||||
{
|
|
||||||
print_Usart(usart2, "Bit Pos | 0| 1| 2| 3| 4| 5| 6| 7|");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "Bits |");
|
|
||||||
for(i=0; i < 8; i++)
|
|
||||||
{
|
|
||||||
pt = (toPrint >> i) & 1;
|
|
||||||
usartSendChar(usart2, ' ');
|
|
||||||
usartSendChar(usart2, pt + 0x30);
|
|
||||||
usartSendChar(usart2, '|');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print_Usart(usart2, "Bit Pos | 7| 6| 5| 4| 3| 2| 1| 0|");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "Bits |");
|
|
||||||
for(i=0; i < 8; i++)
|
|
||||||
{
|
|
||||||
pt = (toPrint >> (7-i)) & 1;
|
|
||||||
usartSendChar(usart2, ' ');
|
|
||||||
usartSendChar(usart2, pt + 0x30);
|
|
||||||
usartSendChar(usart2, '|');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
uint8_t i2cDataLenght = 1;
|
|
||||||
i2c_t i2c_1;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
|
|
||||||
i2c_init(&i2c_1, I2C_CH_1, i2c_mode_master, 0x00,0x00, i2c_address_count_single, i2c_address_size_7b, i2c_clk_speed_standart, i2c_clk_stretching_disable, i2c_wake_disabled);
|
|
||||||
|
|
||||||
slaveAddress = 0x40;
|
|
||||||
registerToRead = 0x02;
|
|
||||||
registerToRead = 0x06;
|
|
||||||
i2cData = 0xAA;
|
|
||||||
|
|
||||||
print_Usart(usart2, "Register Address To Write \n\r");
|
|
||||||
printBinary8(registerToRead,0);
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
|
|
||||||
print_Usart(usart2, "Data To Sent\n\r");
|
|
||||||
printBinary8(i2cData,0);
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
|
|
||||||
|
|
||||||
i2c_check_device(&i2c_1, &slaveAddress);
|
|
||||||
|
|
||||||
i2c_write(&i2c_1, &slaveAddress, ®isterToRead, &i2cData, &i2cDataLenght);
|
|
||||||
i2c_read(&i2c_1, &slaveAddress, ®isterToRead, &i2cRecieved,&i2cDataLenght);
|
|
||||||
|
|
||||||
|
|
||||||
print_Usart(usart2, "Data Recieved\n\r");
|
|
||||||
printBinary8(i2cRecieved,0);
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
|
|
||||||
print_Usart(usart2, "\n\r");
|
|
||||||
print_Usart(usart2, "All is working fine\n\r");
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
delayMs(100);
|
|
||||||
pinToggle(pinB3);
|
|
||||||
delayMs(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
#ifndef MAIN_H
|
|
||||||
#define MAIN_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* MAIN_H */
|
|
@ -1,20 +1,34 @@
|
|||||||
#Declareing header directory for the project
|
###################################################################################################
|
||||||
#To add a new directory
|
# Declaring new directories to be added to the project
|
||||||
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
###################################################################################################
|
||||||
# list() = List declaration "DON'T CHANGE"
|
# list() = List declaration "DON'T CHANGE"
|
||||||
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
# PROJECT_ADDITIONAL_DIRS = Variable containing the listed direcotries "DON'T CHANCE"
|
||||||
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
# . = This indicates that the root file needs to de included "DON'T REMOVE"
|
||||||
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR})
|
#
|
||||||
|
# To include a new folder containing headers or sources that you want to compile
|
||||||
|
# - The root of the project is where the main.c is located
|
||||||
|
# - Let's suppose your main.c is under : /home/yourUserName/YOurProjectName/main.c
|
||||||
|
# - If we Make a new "Src" folder under /home/yourUserName/YOurProjectName/Src
|
||||||
|
# - To add it to the project,
|
||||||
|
# - Just include the Direwctory name "Src" the the Declarion WITHOUT THE LAST "/"
|
||||||
|
# - the declaration should look like this : list(APPEND PROJECT_ADDITIONAL_DIRS . Src)
|
||||||
|
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
||||||
|
|
||||||
#Declaring sources directory for the project
|
###################################################################################################
|
||||||
#To add a new directory
|
# Declaring sources to be compiled for the project.
|
||||||
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
###################################################################################################
|
||||||
# list() = List declaration "DON'T CHANGE"
|
# KED will look in every PROJECT_ADDITIONAL_DIRS list an search for sources
|
||||||
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
# decalred by PROJECT_TO_COMPILE_LIST list
|
||||||
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
#
|
||||||
list(APPEND PROJECT_SOURCES_DIR)
|
# To add a source file to the compilation
|
||||||
|
# - Let's continue where we left off for the Directory inclusion.
|
||||||
#Declaring sources to be compiled for the project.
|
# - Now let's say you have source file named sensor.c located as follow :
|
||||||
#CMake will look in each previsouly declarec sources directory until to find this files.
|
# -> /home/yourUserName/YOurProjectName/Src/sensor.c
|
||||||
set(PROJECT_SOURCES_DIR_LIST)
|
# - To let KED know that you want this source to be compiled, you simply ned to add it the list
|
||||||
|
# - This would look like this : set(PROJECT_TO_COMPILE_LIST sensors.c)
|
||||||
|
set(PROJECT_TO_COMPILE_LIST)
|
||||||
|
|
||||||
|
# If you still have some question please have a look under : ked/libraries/examples/
|
||||||
|
# There you can find some example projects with their corresponding "projectDefinitions.cmake".
|
||||||
|
# To try one of them just copy the entirety of one example folders contend to the root of your
|
||||||
|
# project where ked/ is located.
|
||||||
|
@ -1,21 +1,34 @@
|
|||||||
#Declareing header directory for the project
|
###################################################################################################
|
||||||
#To add a new directory
|
# Declaring new directories to be added to the project
|
||||||
# -> list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
###################################################################################################
|
||||||
# list() = List declaration "DON'T CHANGE"
|
# list() = List declaration "DON'T CHANGE"
|
||||||
# PROJECT_HEADERS_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
# PROJECT_ADDITIONAL_DIRS = Variable containing the listed direcotries "DON'T CHANCE"
|
||||||
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
# . = This indicates that the root file needs to de included "DON'T REMOVE"
|
||||||
list(APPEND PROJECT_HEADERS_DIR ${PROJECT_DIR}/headers)
|
#
|
||||||
|
# To include a new folder containing headers or sources that you want to compile
|
||||||
|
# - The root of the project is where the main.c is located
|
||||||
|
# - Let's suppose your main.c is under : /home/yourUserName/YOurProjectName/main.c
|
||||||
|
# - If we Make a new "Src" folder under /home/yourUserName/YOurProjectName/Src
|
||||||
|
# - To add it to the project,
|
||||||
|
# - Just include the Direwctory name "Src" the the Declarion WITHOUT THE LAST "/"
|
||||||
|
# - the declaration should look like this : list(APPEND PROJECT_ADDITIONAL_DIRS . Src)
|
||||||
|
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
||||||
|
|
||||||
#Declaring sources directory for the project
|
###################################################################################################
|
||||||
#To add a new directory
|
# Declaring sources to be compiled for the project.
|
||||||
# -> list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/YOUR_DESIRED_DIRECTORY)
|
###################################################################################################
|
||||||
# list() = List declaration "DON'T CHANGE"
|
# KED will look in every PROJECT_ADDITIONAL_DIRS list an search for sources
|
||||||
# PROJECT_SOURCES_DIR = Variable containing the listed direcotries "DON'T CHANCE
|
# decalred by PROJECT_TO_COMPILE_LIST list
|
||||||
# ${PROJECT_DIR} = Direcotry of the main project this is per default the current direcotry it is defined in ked/CMakeLists.txt
|
#
|
||||||
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/src)
|
# To add a source file to the compilation
|
||||||
list(APPEND PROJECT_SOURCES_DIR ${PROJECT_DIR}/sensors)
|
# - Let's continue where we left off for the Directory inclusion.
|
||||||
|
# - Now let's say you have source file named sensor.c located as follow :
|
||||||
#Declaring sources to be compiled for the project.
|
# -> /home/yourUserName/YOurProjectName/Src/sensor.c
|
||||||
#CMake will look in each previsouly declarec sources directory until to find this files.
|
# - To let KED know that you want this source to be compiled, you simply ned to add it the list
|
||||||
set(PROJECT_SOURCES_DIR_LIST uartComm sensor)
|
# - This would look like this : set(PROJECT_TO_COMPILE_LIST sensors.c)
|
||||||
|
set(PROJECT_TO_COMPILE_LIST)
|
||||||
|
|
||||||
|
# If you still have some question please have a look under : ked/libraries/examples/
|
||||||
|
# There you can find some example projects with their corresponding "projectDefinitions.cmake".
|
||||||
|
# To try one of them just copy the entirety of one example folders contend to the root of your
|
||||||
|
# project where ked/ is located.
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
###################################################################################################
|
||||||
|
# Declaring new directories to be added to the project
|
||||||
|
###################################################################################################
|
||||||
|
# list() = List declaration "DON'T CHANGE"
|
||||||
|
# PROJECT_ADDITIONAL_DIRS = Variable containing the listed direcotries "DON'T CHANCE"
|
||||||
|
# . = This indicates that the root file needs to de included "DON'T REMOVE"
|
||||||
|
#
|
||||||
|
# To include a new folder containing headers or sources that you want to compile
|
||||||
|
# - The root of the project is where the main.c is located
|
||||||
|
# - Let's suppose your main.c is under : /home/yourUserName/YOurProjectName/main.c
|
||||||
|
# - If we Make a new "Src" folder under /home/yourUserName/YOurProjectName/Src
|
||||||
|
# - To add it to the project,
|
||||||
|
# - Just include the Direwctory name "Src" the the Declarion WITHOUT THE LAST "/"
|
||||||
|
# - the declaration should look like this : list(APPEND PROJECT_ADDITIONAL_DIRS . Src)
|
||||||
|
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# Declaring sources to be compiled for the project.
|
||||||
|
###################################################################################################
|
||||||
|
# KED will look in every PROJECT_ADDITIONAL_DIRS list an search for sources
|
||||||
|
# decalred by PROJECT_TO_COMPILE_LIST list
|
||||||
|
#
|
||||||
|
# To add a source file to the compilation
|
||||||
|
# - Let's continue where we left off for the Directory inclusion.
|
||||||
|
# - Now let's say you have source file named sensor.c located as follow :
|
||||||
|
# -> /home/yourUserName/YOurProjectName/Src/sensor.c
|
||||||
|
# - To let KED know that you want this source to be compiled, you simply ned to add it the list
|
||||||
|
# - This would look like this : set(PROJECT_TO_COMPILE_LIST sensors.c)
|
||||||
|
set(PROJECT_TO_COMPILE_LIST)
|
||||||
|
|
||||||
|
# If you still have some question please have a look under : ked/libraries/examples/
|
||||||
|
# There you can find some example projects with their corresponding "projectDefinitions.cmake".
|
||||||
|
# To try one of them just copy the entirety of one example folders contend to the root of your
|
||||||
|
# project where ked/ is located.
|
@ -0,0 +1,34 @@
|
|||||||
|
###################################################################################################
|
||||||
|
# Declaring new directories to be added to the project
|
||||||
|
###################################################################################################
|
||||||
|
# list() = List declaration "DON'T CHANGE"
|
||||||
|
# PROJECT_ADDITIONAL_DIRS = Variable containing the listed direcotries "DON'T CHANCE"
|
||||||
|
# . = This indicates that the root file needs to de included "DON'T REMOVE"
|
||||||
|
#
|
||||||
|
# To include a new folder containing headers or sources that you want to compile
|
||||||
|
# - The root of the project is where the main.c is located
|
||||||
|
# - Let's suppose your main.c is under : /home/yourUserName/YOurProjectName/main.c
|
||||||
|
# - If we Make a new "Src" folder under /home/yourUserName/YOurProjectName/Src
|
||||||
|
# - To add it to the project,
|
||||||
|
# - Just include the Direwctory name "Src" the the Declarion WITHOUT THE LAST "/"
|
||||||
|
# - the declaration should look like this : list(APPEND PROJECT_ADDITIONAL_DIRS . Src)
|
||||||
|
list(APPEND PROJECT_ADDITIONAL_DIRS .)
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# Declaring sources to be compiled for the project.
|
||||||
|
###################################################################################################
|
||||||
|
# KED will look in every PROJECT_ADDITIONAL_DIRS list an search for sources
|
||||||
|
# decalred by PROJECT_TO_COMPILE_LIST list
|
||||||
|
#
|
||||||
|
# To add a source file to the compilation
|
||||||
|
# - Let's continue where we left off for the Directory inclusion.
|
||||||
|
# - Now let's say you have source file named sensor.c located as follow :
|
||||||
|
# -> /home/yourUserName/YOurProjectName/Src/sensor.c
|
||||||
|
# - To let KED know that you want this source to be compiled, you simply ned to add it the list
|
||||||
|
# - This would look like this : set(PROJECT_TO_COMPILE_LIST sensors.c)
|
||||||
|
set(PROJECT_TO_COMPILE_LIST)
|
||||||
|
|
||||||
|
# If you still have some question please have a look under : ked/libraries/examples/
|
||||||
|
# There you can find some example projects with their corresponding "projectDefinitions.cmake".
|
||||||
|
# To try one of them just copy the entirety of one example folders contend to the root of your
|
||||||
|
# project where ked/ is located.
|
Loading…
Reference in new issue