shared_fooの不要ディレクトリ削除前のもの
Revision | 5f55c2e3c50ac688accb6eb4e35e110844bda442 (tree) |
---|---|
Zeit | 2018-02-11 16:57:54 |
Autor | takemasa <suikan@user...> |
Commiter | takemasa |
Added new abstract classes.
@@ -0,0 +1,119 @@ | ||
1 | +/** | |
2 | + * \file abstracti2cmaster.hpp | |
3 | + * | |
4 | + * \date 2018/02/11 | |
5 | + * \author: takemasa | |
6 | + * \brief Root class definition of the I2C Master. | |
7 | + */ | |
8 | + | |
9 | +#ifndef ABSTRACTI2CMASTER_HPP_ | |
10 | +#define ABSTRACTI2CMASTER_HPP_ | |
11 | + | |
12 | +#include "murasaki_defs.hpp" | |
13 | + | |
14 | +namespace murasaki { | |
15 | +/** | |
16 | + * \ingroup MURASAKI_ABSTRACT_GROUP | |
17 | + * \brief Definition of the root class of I2C master. | |
18 | + * \details | |
19 | + * A prototype of the I2C master peripheral. | |
20 | + * | |
21 | + * This prototype assumes the derived class will transmit / receive data in the | |
22 | + * task context on RTOS. And these member functions should be blocking. | |
23 | + * That men, until the transmit / receive | |
24 | + * terminates, both method doesn't return. | |
25 | + * | |
26 | + * Two call back member functions are prepared to sync with the interrupt which tells the end of | |
27 | + * Transmit/Recieve. | |
28 | + */ | |
29 | + | |
30 | +class AbstractI2CMaster | |
31 | +{ | |
32 | + public: | |
33 | + /** | |
34 | + * \brief Destructor. Declared to enforce the derived destructor is virtual. | |
35 | + */ | |
36 | + virtual ~AbstractI2CMaster() | |
37 | + { | |
38 | + } | |
39 | + ; | |
40 | + | |
41 | + /** | |
42 | + * @brief Thread safe, blocking transmission over I2C. | |
43 | + * @param addrs 7bit address of the I2C device. | |
44 | + * @param tx_data Data array to transmit. | |
45 | + * @param tx_count Data counts[bytes] to transmit. | |
46 | + * @param timeout_ms Time ou [mS]. By default, there is not timeout. | |
47 | + * @return True if transmit complete, false if timeout. | |
48 | + * @details | |
49 | + * This member function is confided to run in the task context of RTOS. This should be internally | |
50 | + * exclusive between multiple task access. In other word, it should be thread save. | |
51 | + */ | |
52 | + virtual bool Transmit(uint addrs, uint8_t * tx_data, uint16_t tx_count, WaitMilliSeconds timeout_ms = | |
53 | + murasaki::kwmsIndefinitely) = 0; | |
54 | + /** | |
55 | + * @brief Thread safe, blocking receiving over I2C. | |
56 | + * @param addrs 7bit address of the I2C device. | |
57 | + * @param rx_data Data array to transmit. | |
58 | + * @param rx_count Data counts[bytes] to transmit. | |
59 | + * @param timeout_ms Time ou [mS]. By default, there is not timeout. | |
60 | + * @return True if receiving complete, false if timeout. | |
61 | + * @details | |
62 | + * This member function is confided to run in the task context of RTOS. This should be internally | |
63 | + * exclusive between multiple task access. In other word, it should be thread save. | |
64 | + */ | |
65 | + virtual bool Receive(uint addrs, uint8_t * rx_data, uint16_t rx_count, WaitMilliSeconds timeout_ms = | |
66 | + murasaki::kwmsIndefinitely) = 0; | |
67 | + /** | |
68 | + * @brief Thread safe, blocking transmission and then receiving over I2C. | |
69 | + * @param addrs 7bit address of the I2C device. | |
70 | + * @param tx_data Data array to transmit. | |
71 | + * @param tx_count Data counts[bytes] to transmit. | |
72 | + * @param rx_data Data array to transmit. | |
73 | + * @param rx_count Data counts[bytes] to transmit. | |
74 | + * @param timeout_ms Time ou [mS]. By default, there is not timeout. | |
75 | + * @return True if receiving complete, false if timeout. | |
76 | + * @details | |
77 | + * First, this member function transmit the data, and the, by repeated start function, | |
78 | + * it receives data. The transmission device address and receiving device address is same. | |
79 | + * | |
80 | + * This member function is confided to run in the task context of RTOS. This should be internally | |
81 | + * exclusive between multiple task access. In other word, it should be thread save. | |
82 | + * | |
83 | + */ | |
84 | + virtual bool TransmitThenReceive(uint addrs, | |
85 | + uint8_t * tx_data, | |
86 | + uint16_t tx_count, | |
87 | + uint8_t * rx_data, | |
88 | + uint16_t rx_count, | |
89 | + WaitMilliSeconds timeout_ms = murasaki::kwmsIndefinitely) =0; | |
90 | + /** | |
91 | + * \brief Call back to be called notify the transfer is complete. | |
92 | + * \param ptr Pointer for generic use. Usually, points a struct of a peripheral control | |
93 | + * \return true: ptr matches with peripheral and handle the call back. false : doesn't match. | |
94 | + * \details | |
95 | + * A call back to notify the end of entire block or byte transfer. The definition of calling timing is | |
96 | + * depend on the implementation. This is called from an DMA ISR. | |
97 | + * | |
98 | + * | |
99 | + * Typically, an implementation may check whether the given ptr parameter matches its own device, and if matched, handle it | |
100 | + * and return true. If it doesn't match, just return false. | |
101 | + */ | |
102 | + virtual bool TransmitCompleteCallback(void* ptr)=0; | |
103 | + /** | |
104 | + * \brief Call back to be called for entire block transfer is complete. | |
105 | + * \param ptr Pointer for generic use. Usually, points a struct of a peripheral control | |
106 | + * \return true: ptr matches with peripheral and handle the call back. false : doesn't match. | |
107 | + * \details | |
108 | + * A call back to notify the end of entire block or byte transfer. The definition of calling timing is | |
109 | + * depend on the implementation. This is called from an DMA ISR. | |
110 | + * | |
111 | + * Typically, an implementation may check whether the given ptr parameter matches its own device, and if matched, handle it | |
112 | + * and return true. If it doesn't match, just return false. | |
113 | + */ | |
114 | + virtual bool ReceiveCompleteCallback(void* ptr) = 0; | |
115 | +}; | |
116 | + | |
117 | +} /* namespace murasaki */ | |
118 | + | |
119 | +#endif /* ABSTRACTI2CMASTER_HPP_ */ |
@@ -0,0 +1,22 @@ | ||
1 | +/* | |
2 | + * abstractspimaster.hpp | |
3 | + * | |
4 | + * Created on: 2018/02/11 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | + | |
8 | +#ifndef ABSTRACTSPIMASTER_HPP_ | |
9 | +#define ABSTRACTSPIMASTER_HPP_ | |
10 | + | |
11 | +namespace murasaki { | |
12 | + | |
13 | +class AbstractSpiMaster | |
14 | +{ | |
15 | + public: | |
16 | + AbstractSpiMaster(); | |
17 | + virtual ~AbstractSpiMaster(); | |
18 | +}; | |
19 | + | |
20 | +} /* namespace murasaki */ | |
21 | + | |
22 | +#endif /* ABSTRACTSPIMASTER_HPP_ */ |
@@ -0,0 +1,22 @@ | ||
1 | +/* | |
2 | + * abstractspimasterdecorator.hpp | |
3 | + * | |
4 | + * Created on: 2018/02/11 | |
5 | + * Author: takemasa | |
6 | + */ | |
7 | + | |
8 | +#ifndef ABSTRACTSPIMASTERDECORATOR_HPP_ | |
9 | +#define ABSTRACTSPIMASTERDECORATOR_HPP_ | |
10 | + | |
11 | +namespace murasaki { | |
12 | + | |
13 | +class AbstractSpiMasterDecorator | |
14 | +{ | |
15 | + public: | |
16 | + AbstractSpiMasterDecorator(); | |
17 | + virtual ~AbstractSpiMasterDecorator(); | |
18 | +}; | |
19 | + | |
20 | +} /* namespace murasaki */ | |
21 | + | |
22 | +#endif /* ABSTRACTSPIMASTERDECORATOR_HPP_ */ |
@@ -50,6 +50,7 @@ Uart::~Uart() | ||
50 | 50 | |
51 | 51 | void Uart::SetHardwareFlowControl(UartHardwareFlowControl control) |
52 | 52 | { |
53 | + //TODO need to rewrite. | |
53 | 54 | // stop UART activity. This is required by UART HAL specification. |
54 | 55 | __HAL_UART_DISABLE(uart_); |
55 | 56 |