new structure wth driver folder for all the generic code

pull/2/head
polymurph 3 years ago
parent 2962ebd6e3
commit 34ef9bf307

@ -24,7 +24,7 @@ set(EXECUTABLE ${PROJECT_NAME}) #Create the executable
####################################################################################################
set(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/csl/interfaces)
set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils/assert)
set(DRIVERS_DIR ${CMAKE_DRIVERS_DIR}/drivers)
set(DRIVERS_DIR ${CMAKE_SOURCE_DIR}/drivers)
####################################################################################################
#SUBDIRECTORIES Will add the given folders to the porject an check for CmakeLists.txt
@ -40,6 +40,7 @@ message("${Blue} |--> Compiler Def\t: ${COMPILER_DEFS} ${ColourReset}")
message("${Blue} |--> Project Def\t: ${PROJECT_DEFS} ${ColourReset}")
message("${Blue} |--> Interfaces Dir\t: ${INTERFACES_DIR} ${ColourReset}")
message("${Blue} |--> Libs used\t\t: ${EXTRA_LIBS} ${ColourReset}")
message("${Blue} |--> Drivers Dir\t: ${DRIVERS_DIR} ${ColourReset}")
####################################################################################################
#EXECUTABLE

@ -29,9 +29,9 @@ target_compile_definitions(stmTimer PRIVATE ${C_DEFS})
target_include_directories(stmTimer PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES})
add_library(sub::timer ALIAS stmTimer)
add_library(stmSPI spi.c)
add_library(stmSPI imp_spi.c)
target_compile_options(stmSPI PRIVATE ${C_FLAGS})
target_compile_definitions(stmSPI PRIVATE ${C_DEFS})
target_include_directories(stmSPI PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES})
add_library(sub::spi ALIAS stmSPI)
add_library(sub::imp_spi ALIAS stmSPI)

@ -69,11 +69,13 @@ uint8_t spi_trx(spiCH_t spi_hw_ch, uint8_t tx_data)
// example
while (((SPI1->SR)&(1<<7))); // wait for BSY bit to Reset -> This will indicate that SPI is not busy in communication
// wait for BSY bit to Reset -> This will indicate that SPI is not busy in communication
while (((SPI1->SR)&(1<<7)));
SPI1->DR = tx_data; // send data
while (!((SPI1->SR) &(1<<0))); // Wait for RXNE to set -> This will indicate that the Rx buffer is not empty
// Wait for RXNE to set -> This will indicate that the Rx buffer is not empty
while (!((SPI1->SR) &(1<<0)));
data = SPI1->DR;
return data;

@ -77,4 +77,5 @@ list(APPEND EXTRA_LIBS sub::pin)
list(APPEND EXTRA_LIBS sub::usart)
list(APPEND EXTRA_LIBS sub::timer)
list(APPEND EXTRA_LIBS sub::init)
list(APPEND EXTRA_LIBS sub::imp_spi)
list(APPEND EXTRA_LIBS sub::spi)

@ -1 +1,5 @@
# add_subdirectory(${CSL_USED})
add_library(SPI spi.c)
target_compile_options(SPI PRIVATE ${C_FLAGS})
target_compile_definitions(SPI PRIVATE ${C_DEFS})
target_include_directories(SPI PUBLIC ${INTERFACES_DIR} ${CSL_INCLUDES})
add_library(sub::spi ALIAS SPI)

@ -1,7 +0,0 @@
add_library(ledDriver led.cpp)
target_compile_options(ledDriver PRIVATE ${C_FLAGS})
target_compile_definitions(ledDriver PRIVATE ${C_DEFS})
target_include_directories(ledDriver PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(sub::led ALIAS ledDriver)

@ -1,30 +0,0 @@
#include "led.hpp"
Led::Led(Pin* pin_ptr)
{
pin = pin_ptr;
pin->init();
pin->setMode(Pin::mode::output);
pin->setSpeed(Pin::speed::fast);
}
Led::~Led()
{
}
void Led::on()
{
pin->write(true);
}
void Led::off()
{
pin->write(false);
}
void Led::toggle()
{
pin->toggle();
}

@ -1,20 +0,0 @@
#ifndef _LED_HPP
#define _LED_HPP
class Led
{
public:
Led(Pin *pin_ptr);
~Led();
void on();
void off();
void toggle();
private:
Pin *pin;
};
#endif /* __LED_HPP */

@ -5,7 +5,7 @@
#include "ascii.h"
#include "timer.h"
#include "spi.h"
#include "spi_ch.h"
#include "ked/csl/interfaces/spi_ch.h"
int main(int argc, char *argv[])
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
pinInit(pinA4);
pinConfig(pinA5, alternate, pushPull, none, veryFast);
pinConfig(pinA6, alternate, pushPull, none, veryFast);
pinConfig(pinA6, alternate, floating, none , veryFast);
pinConfig(pinA7, alternate, pushPull, none, veryFast);
//pinConfig(pinA6, alternate, floating, pullDown, veryFast);
pinConfig(pinA4, output, pushPull, none, veryFast);

Loading…
Cancel
Save