MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/application/virtualization/SpiBusAbonent.hh
2024-06-07 11:12:56 +03:00

79 lines
2.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SpiBusAbonent.h
*
* Created on: 24 июн. 2019 г.
* Author: user
*/
#ifndef SOURCE_APPLICATION__BOARD_SPIBUSABONENTSETUP_H_
#define SOURCE_APPLICATION__BOARD_SPIBUSABONENTSETUP_H_
#include "../ISetupStep.hh"
#include "../../peripheral/IGpio.hh"
#include "../../driver/SpiBus.hh"
namespace application { namespace virtualization {
//!Абонент на шине SPI.
struct SpiBusAbonent : public ISetupStep {
driver::SpiBus * spi_bus = nullptr;
peripheral::IGpio * spi_bus_abonent_cs = nullptr;
bool input( Environment & env );
void build( Environment & env );
struct Links {
Environment::Id chip_select; //!<Аппаратный вывод используемый для управления выбором микросхемы на шине SPI.
Environment::Id spi_bus; //!<Шина SPI.
Environment::Id spi_abonent; //!<Абонент на шине SPI.
};
const Links & links;
struct Setting {
uint16_t clocking_scheme :2; //!<Схема тактирования.
uint16_t cs_polarity :1; //!<Полярность чип-селекта.
uint16_t tx_inversion :1; //!<Инверсия данных в линии передачи.
uint16_t rx_inversion :1; //!<Инверсия данных в линии приема.
uint16_t loop_back :1; //!<Виртуально замкнуть линии передачи и приема.
uint16_t transfer_delay; //!<Задержка передачи.
uint32_t baud_rate; //!<Частота клоков.
};
const Setting & config;
SpiBusAbonent( const Links & links,
const Setting & config );
};
struct BadSpiAbonentSetting : public std::exception {
unsigned short abonent_id;
std::pair<const char *, std::size_t> abonent_setting;
BadSpiAbonentSetting( unsigned short abonent_id,
std::pair<const char *, std::size_t> abonent_setting ) noexcept :
abonent_id(abonent_id), abonent_setting(abonent_setting) {}
const char * what() const noexcept { return "Bad spi abonent setting"; }
};
struct BadSerialPort : public std::exception {
unsigned short abonent_id;
BadSerialPort( unsigned short abonent_id ) noexcept :
abonent_id(abonent_id) {}
const char * what() const noexcept { return "Bad serial port"; }
};
} /* namespace board */
} /* namespace application */
#endif /* SOURCE_APPLICATION_BOARD_SPIBUSABONENTSETUP_H_ */