shared_fooの不要ディレクトリ削除前のもの
修訂 | bc6671aad6d8bb8dfe1941cbd426f97d43f9faa2 (tree) |
---|---|
時間 | 2018-02-15 23:04:45 |
作者 | takemasa <suikan@user...> |
Commiter | takemasa |
Change the name of the SPI slave specifier from
AbstractSpiMasterDecolator to AbstractSpiSlaveSpecifier
@@ -9,7 +9,7 @@ | ||
9 | 9 | #ifndef ABSTRACTSPIMASTER_HPP_ |
10 | 10 | #define ABSTRACTSPIMASTER_HPP_ |
11 | 11 | |
12 | -#include "abstractspimasterdecorator.hpp" | |
12 | +#include <abstractspislavespecifier.hpp> | |
13 | 13 | |
14 | 14 | namespace murasaki { |
15 | 15 |
@@ -42,7 +42,7 @@ class AbstractSpiMaster | ||
42 | 42 | virtual bool Transfer(uint8_t * tx_data, |
43 | 43 | uint8_t * rx_data, |
44 | 44 | uint16_t count, |
45 | - murasaki::AbstractSpiMasterDecorator * decorator, | |
45 | + murasaki::AbstractSpiSlaveSpecifier * decorator, | |
46 | 46 | murasaki::WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely)=0; |
47 | 47 | /** |
48 | 48 | * @brief Callback to notifiy the end of transfer |
@@ -1,56 +0,0 @@ | ||
1 | -/* | |
2 | - * abstractspimasterdecorator.cpp | |
3 | - * | |
4 | - * Created on: 2018/02/11 | |
5 | - * Author: takemasa | |
6 | - */ | |
7 | - | |
8 | -#include <abstractspimasterdecorator.hpp> | |
9 | -#include "murasaki_assert.hpp" | |
10 | - | |
11 | -namespace murasaki { | |
12 | - | |
13 | - | |
14 | - | |
15 | -AbstractSpiMasterDecorator::~AbstractSpiMasterDecorator() | |
16 | -{ | |
17 | - // Do nothing. | |
18 | -} | |
19 | - | |
20 | -void AbstractSpiMasterDecorator::AssertCs() | |
21 | -{ | |
22 | - // Do nothing here | |
23 | - // Must be overriden | |
24 | -} | |
25 | - | |
26 | -void AbstractSpiMasterDecorator::DeassertCs() | |
27 | -{ | |
28 | - // Do nothing here | |
29 | - // Must be overriden | |
30 | -} | |
31 | - | |
32 | -murasaki::SpiClockPhase AbstractSpiMasterDecorator::GetCpha() | |
33 | -{ | |
34 | - return cpha_; | |
35 | -} | |
36 | - | |
37 | -murasaki::SpiClockPolarity AbstractSpiMasterDecorator::GetCpol() | |
38 | -{ | |
39 | - return cpol_; | |
40 | -} | |
41 | - | |
42 | - | |
43 | -AbstractSpiMasterDecorator::AbstractSpiMasterDecorator(murasaki::SpiClockPolarity pol, murasaki::SpiClockPhase pha) | |
44 | -{ | |
45 | - cpol_ = pol; | |
46 | - cpha_ = pha; | |
47 | -} | |
48 | - | |
49 | -AbstractSpiMasterDecorator::AbstractSpiMasterDecorator(unsigned int pol, unsigned int pha) | |
50 | -{ | |
51 | - cpol_ = static_cast<murasaki::SpiClockPolarity>(pol); | |
52 | - cpha_ = static_cast<murasaki::SpiClockPhase>(pha); | |
53 | -} | |
54 | - | |
55 | - | |
56 | -} /* namespace murasaki */ |
@@ -0,0 +1,56 @@ | ||
1 | +/* | |
2 | + * abstractspimasterdecorator.cpp | |
3 | + * | |
4 | + * Created on: 2018/02/11 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | + | |
8 | +#include <abstractspislavespecifier.hpp> | |
9 | +#include "murasaki_assert.hpp" | |
10 | + | |
11 | +namespace murasaki { | |
12 | + | |
13 | + | |
14 | + | |
15 | +AbstractSpiSlaveSpecifier::~AbstractSpiSlaveSpecifier() | |
16 | +{ | |
17 | + // Do nothing. | |
18 | +} | |
19 | + | |
20 | +void AbstractSpiSlaveSpecifier::AssertCs() | |
21 | +{ | |
22 | + // Do nothing here | |
23 | + // Must be overriden | |
24 | +} | |
25 | + | |
26 | +void AbstractSpiSlaveSpecifier::DeassertCs() | |
27 | +{ | |
28 | + // Do nothing here | |
29 | + // Must be overriden | |
30 | +} | |
31 | + | |
32 | +murasaki::SpiClockPhase AbstractSpiSlaveSpecifier::GetCpha() | |
33 | +{ | |
34 | + return cpha_; | |
35 | +} | |
36 | + | |
37 | +murasaki::SpiClockPolarity AbstractSpiSlaveSpecifier::GetCpol() | |
38 | +{ | |
39 | + return cpol_; | |
40 | +} | |
41 | + | |
42 | + | |
43 | +AbstractSpiSlaveSpecifier::AbstractSpiSlaveSpecifier(murasaki::SpiClockPolarity pol, murasaki::SpiClockPhase pha) | |
44 | +{ | |
45 | + cpol_ = pol; | |
46 | + cpha_ = pha; | |
47 | +} | |
48 | + | |
49 | +AbstractSpiSlaveSpecifier::AbstractSpiSlaveSpecifier(unsigned int pol, unsigned int pha) | |
50 | +{ | |
51 | + cpol_ = static_cast<murasaki::SpiClockPolarity>(pol); | |
52 | + cpha_ = static_cast<murasaki::SpiClockPhase>(pha); | |
53 | +} | |
54 | + | |
55 | + | |
56 | +} /* namespace murasaki */ |
@@ -1,34 +1,34 @@ | ||
1 | 1 | /* |
2 | - * @file abstractspimasterdecorator.hpp | |
2 | + * @file abstractspislavespecifier.hpp | |
3 | 3 | * |
4 | 4 | * @date 2018/02/11 |
5 | 5 | * @author: takemasa |
6 | 6 | */ |
7 | 7 | |
8 | -#ifndef ABSTRACTSPIMASTERDECORATOR_HPP_ | |
9 | -#define ABSTRACTSPIMASTERDECORATOR_HPP_ | |
8 | +#ifndef ABSTRACTSPISLAVESPECIFIER_HPP_ | |
9 | +#define ABSTRACTSPISLAVESPECIFIER_HPP_ | |
10 | 10 | |
11 | 11 | #include "murasaki_defs.hpp" |
12 | 12 | |
13 | 13 | namespace murasaki { |
14 | 14 | /** |
15 | - * \brief Definition of the root class of SPI master decorator. | |
15 | + * \brief Definition of the root class of SPI slave specifier. | |
16 | 16 | * \details |
17 | - * A prototype of the SPI master peripheral decorator. | |
17 | + * A prototype of the SPI slave device specifier. | |
18 | 18 | * |
19 | - * The decorator adds the following SPI attributes : | |
19 | + * The specifier adds the following SPI attributes : | |
20 | 20 | * @li CPOL |
21 | 21 | * @li CPHA |
22 | 22 | * @li Chip select control for slave. |
23 | 23 | * |
24 | - * Because SPI slave has different setting device by device, this decorator should be | |
24 | + * Because SPI slave has different setting device by device, this specifier should be | |
25 | 25 | * passed to the each transactions. |
26 | 26 | * |
27 | 27 | * AssetCs() and DeassertCs() have to be overriden to control the chip select output. |
28 | 28 | * These member functions will be called from the AbstractSpiMaster. |
29 | 29 | * @ingroup MURASAKI_ABSTRACT_GROUP |
30 | 30 | */ |
31 | -class AbstractSpiMasterDecorator | |
31 | +class AbstractSpiSlaveSpecifier | |
32 | 32 | { |
33 | 33 | public: |
34 | 34 | /** |
@@ -36,17 +36,17 @@ class AbstractSpiMasterDecorator | ||
36 | 36 | * @param pol Polarity setting |
37 | 37 | * @param pha Phase setting |
38 | 38 | */ |
39 | - AbstractSpiMasterDecorator(murasaki::SpiClockPolarity pol, murasaki::SpiClockPhase pha); | |
39 | + AbstractSpiSlaveSpecifier(murasaki::SpiClockPolarity pol, murasaki::SpiClockPhase pha); | |
40 | 40 | /** |
41 | 41 | * @brief Constructor |
42 | 42 | * @param pol Polarity setting |
43 | 43 | * @param pha Phase setting |
44 | 44 | */ |
45 | - AbstractSpiMasterDecorator(unsigned int pol, unsigned int pha); | |
45 | + AbstractSpiSlaveSpecifier(unsigned int pol, unsigned int pha); | |
46 | 46 | /** |
47 | 47 | * @brief Destructor |
48 | 48 | */ |
49 | - virtual ~AbstractSpiMasterDecorator(); | |
49 | + virtual ~AbstractSpiSlaveSpecifier(); | |
50 | 50 | /** |
51 | 51 | * @brief Chip select assertion |
52 | 52 | * @details |
@@ -87,4 +87,4 @@ class AbstractSpiMasterDecorator | ||
87 | 87 | |
88 | 88 | } /* namespace murasaki */ |
89 | 89 | |
90 | -#endif /* ABSTRACTSPIMASTERDECORATOR_HPP_ */ | |
90 | +#endif /* ABSTRACTSPISLAVESPECIFIER_HPP_ */ |
@@ -39,14 +39,14 @@ SpiMaster::~SpiMaster() | ||
39 | 39 | bool SpiMaster::Transfer(uint8_t* tx_data, |
40 | 40 | uint8_t* rx_data, |
41 | 41 | uint16_t count, |
42 | - murasaki::AbstractSpiMasterDecorator* decorator, | |
42 | + murasaki::AbstractSpiSlaveSpecifier* spi_spec, | |
43 | 43 | murasaki::WaitMilliSeconds timeout_ms) |
44 | 44 | { |
45 | 45 | bool result; |
46 | 46 | |
47 | 47 | MURASAKI_ASSERT(NULL!= tx_data); |
48 | 48 | MURASAKI_ASSERT(NULL!= rx_data); |
49 | - MURASAKI_ASSERT(NULL != decorator); | |
49 | + MURASAKI_ASSERT(NULL != spi_spec); | |
50 | 50 | |
51 | 51 | // exclusive operation |
52 | 52 | critical_section_->Enter(); |
@@ -55,12 +55,12 @@ bool SpiMaster::Transfer(uint8_t* tx_data, | ||
55 | 55 | // todo is following right? |
56 | 56 | MURASAKI_ASSERT(HAL_SPI_DeInit(peripheral_) == HAL_OK); |
57 | 57 | peripheral_->Init.CLKPolarity = |
58 | - (decorator->GetCpol() == kscpRiseThenFall) ? SPI_POLARITY_LOW : SPI_POLARITY_HIGH; | |
59 | - peripheral_->Init.CLKPhase = (decorator->GetCpha() == kscpLatchThenShift) ? SPI_PHASE_1EDGE : SPI_PHASE_2EDGE; | |
58 | + (spi_spec->GetCpol() == kscpRiseThenFall) ? SPI_POLARITY_LOW : SPI_POLARITY_HIGH; | |
59 | + peripheral_->Init.CLKPhase = (spi_spec->GetCpha() == kscpLatchThenShift) ? SPI_PHASE_1EDGE : SPI_PHASE_2EDGE; | |
60 | 60 | MURASAKI_ASSERT(HAL_SPI_Init(peripheral_) == HAL_OK); |
61 | 61 | |
62 | 62 | // Assert the chip select for slave |
63 | - decorator->AssertCs(); | |
63 | + spi_spec->AssertCs(); | |
64 | 64 | { |
65 | 65 | |
66 | 66 | // Transmit over SPI |
@@ -72,7 +72,7 @@ bool SpiMaster::Transfer(uint8_t* tx_data, | ||
72 | 72 | MURASAKI_ASSERT(result); |
73 | 73 | } |
74 | 74 | // Dessert the chip select for slave |
75 | - decorator->DeassertCs(); | |
75 | + spi_spec->DeassertCs(); | |
76 | 76 | } |
77 | 77 | critical_section_->Leave(); |
78 | 78 |
@@ -66,14 +66,14 @@ class SpiMaster : public AbstractSpiMaster | ||
66 | 66 | * @param tx_data Data to be transmitted |
67 | 67 | * @param rx_data Data buffer to receive data |
68 | 68 | * @param count Transfer data size [byte] for each way. |
69 | - * @param decorator | |
69 | + * @param spi_spec A pointer to the AbstractSpiSpecification to specify the slave device. | |
70 | 70 | * @param timeout_ms Timeout limit [mS] |
71 | 71 | * @return true if transfer complete, false if timeout |
72 | 72 | */ |
73 | 73 | virtual bool Transfer(uint8_t * tx_data, |
74 | 74 | uint8_t * rx_data, |
75 | 75 | uint16_t count, |
76 | - murasaki::AbstractSpiMasterDecorator * decorator, | |
76 | + murasaki::AbstractSpiSlaveSpecifier * spi_spec, | |
77 | 77 | murasaki::WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely); |
78 | 78 | /** |
79 | 79 | * @brief Callback to notifiy the end of transfer |