• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shared_fooの不要ディレクトリ削除前のもの


Commit MetaInfo

Revisiondb9b1d0276a7eea930d4121f1ab5bd97b96d1856 (tree)
Zeit2018-03-11 16:45:04
Autortakemasa <suikan@user...>
Commitertakemasa

Log Message

Debugger:printf is renamed as Printf, to follow the google map.
Implement the cache coherency.

Ändern Zusammenfassung

Diff

--- a/stm32_development/murasaki/Src/my_test.cpp
+++ b/stm32_development/murasaki/Src/my_test.cpp
@@ -84,7 +84,7 @@ void InitTestUart(UART_HandleTypeDef * uart_handle, SPI_HandleTypeDef * spi_hand
8484 unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG1), sizeof(MSG1));
8585 test_fifo->NotifyData();
8686
87- murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
87+ murasaki::debugger->Printf("FIFO.Put(), %d data taransfered\n\r", copied);
8888 #endif
8989
9090 }
@@ -97,7 +97,7 @@ void DoTestUart(void)
9797 #if 0
9898 unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG1), sizeof(MSG1));
9999 test_fifo->NotifyData();
100- murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
100+ murasaki::debugger->Printf("FIFO.Put(), %d data taransfered\n\r", copied);
101101 #endif
102102
103103 #if 0
@@ -109,24 +109,24 @@ void DoTestUart(void)
109109 unsigned int copied = test_fifo->Get(reinterpret_cast<uint8_t *>(data), sizeof(data));
110110 if (copied == 0)
111111 {
112- murasaki::debugger->printf("FIFO.Get(), %d data taransfered \n\r", copied);
112+ murasaki::debugger->Printf("FIFO.Get(), %d data taransfered \n\r", copied);
113113 // test_fifo->ReWind();
114114 test_fifo->NotifyData();
115115 }
116116 else {
117- murasaki::debugger->printf("FIFO.Get(), %d data taransfered : '%10s'\n\r", copied, data);
117+ murasaki::debugger->Printf("FIFO.Get(), %d data taransfered : '%10s'\n\r", copied, data);
118118 }
119119 #endif
120120 // by murasaki debugging output. You can use this in both task and interrupt context.
121121 // non blocking
122- murasaki::debugger->printf(MSG, counter);
122+ murasaki::debugger->Printf(MSG, counter);
123123
124124 }
125125
126126 // Hook for the assert_failure() in main.c
127127 void CustomAssertFailed(uint8_t* file, uint32_t line)
128128 {
129- murasaki::debugger->printf("Wrong parameters value: file %s on line %d\r\n", file, line);
129+ murasaki::debugger->Printf("Wrong parameters value: file %s on line %d\r\n", file, line);
130130 }
131131
132132
@@ -168,9 +168,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_P)
168168 unsigned int copied = test_fifo->Put(reinterpret_cast<const uint8_t *>(MSG2), sizeof(MSG2));
169169 test_fifo->NotifyData();
170170
171- murasaki::debugger->printf("FIFO.Put(), %d data taransfered\n\r", copied);
171+ murasaki::debugger->Printf("FIFO.Put(), %d data taransfered\n\r", copied);
172172 #else
173- murasaki::debugger->printf("Interrupt occurs %d \n\r", counter);
173+ murasaki::debugger->Printf("Interrupt occurs %d \n\r", counter);
174174 #endif
175175 }
176176 }
--- a/stm32_development/murasaki/murasaki/debugger.cpp
+++ b/stm32_development/murasaki/murasaki/debugger.cpp
@@ -58,7 +58,7 @@ Debugger::~Debugger()
5858 delete helpers_.fifo;
5959 }
6060
61-void Debugger::printf(const char * fmt, ...)
61+void Debugger::Printf(const char * fmt, ...)
6262 {
6363 // obtain variable parameter list
6464 va_list argp;
--- a/stm32_development/murasaki/murasaki/debugger.hpp
+++ b/stm32_development/murasaki/murasaki/debugger.hpp
@@ -74,7 +74,7 @@ class Debugger
7474 *
7575 * At 2018/Jan/14 measurement, task stack was consumed 49bytes.
7676 */
77- void printf(const char * fmt, ...);
77+ void Printf(const char * fmt, ...);
7878 /**
7979 * \brief Receive one character from serial port.
8080 * \return Received character.
@@ -84,7 +84,7 @@ class Debugger
8484 *
8585 * This is thread safe and task context dedicated function. Never call from ISR.
8686 *
87- * Becareful, this is blocking while the Debug::printf() non-blocking.
87+ * Becareful, this is blocking while the Debug::Printf() non-blocking.
8888 */
8989 char GetchFromTask();
9090 /**
--- a/stm32_development/murasaki/murasaki/murasaki_assert.hpp
+++ b/stm32_development/murasaki/murasaki/murasaki_assert.hpp
@@ -36,9 +36,9 @@
3636 #define MURASAKI_ASSERT( COND )\
3737 if ( ! (COND) )\
3838 {\
39- murasaki::debugger->printf("--------------------\n\r");\
40- murasaki::debugger->printf(MURASAKI_ASSERT_MSG, __func__, __LINE__,__FILE__ );\
41- murasaki::debugger->printf("Fail expression : %s\r\n", #COND);\
39+ murasaki::debugger->Printf("--------------------\n\r");\
40+ murasaki::debugger->Printf(MURASAKI_ASSERT_MSG, __func__, __LINE__,__FILE__ );\
41+ murasaki::debugger->Printf("Fail expression : %s\r\n", #COND);\
4242 if ( murasaki::IsTaskContext() )\
4343 vTaskSuspend(nullptr);\
4444 }
@@ -84,7 +84,7 @@
8484 #define MURASAKI_PRINT_ERROR( ERR )\
8585 if ( (ERR) )\
8686 {\
87- murasaki::debugger->printf(MURASAKI_ERROR_MSG, __func__, __LINE__,__FILE__, #ERR );\
87+ murasaki::debugger->Printf(MURASAKI_ERROR_MSG, __func__, __LINE__,__FILE__, #ERR );\
8888 }
8989 #endif
9090
--- a/stm32_development/murasaki/murasaki/murasaki_defs.hpp
+++ b/stm32_development/murasaki/murasaki/murasaki_defs.hpp
@@ -86,7 +86,7 @@ enum SpiClockPhase
8686 * \brief determine task or ISR context
8787 * \returns true if task context, false if ISR context.
8888 */
89-inline bool IsTaskContext()
89+static inline bool IsTaskContext()
9090 {
9191 // portNVIC_INT_CTRL_REG is mapped to the address 0xe000ed04 by portmacro.h. This register is
9292 // officially called as NVIC ICSR by ARM
@@ -104,6 +104,18 @@ inline bool IsTaskContext()
104104 }
105105
106106
107+static inline void InvalidateDataCacheByAddress(void * address, size_t size)
108+{
109+ unsigned int aligned_address = reinterpret_cast<unsigned int>(address);
110+
111+ // extract modulo 32. The address have to be aligned to 32byte.
112+ unsigned int adjustment = aligned_address & 0x1F;
113+ // Adjust the address and size.
114+ aligned_address -= adjustment; // aligne to 32byte boarder
115+ size += adjustment; // Because the start address is lower, the size is bigger.
116+
117+ ::SCB_InvalidateDCache_by_Addr(reinterpret_cast<long unsigned int *>(aligned_address), size);
118+}
107119
108120 /**
109121 * \}
--- a/stm32_development/murasaki/murasaki/murasaki_ug.hpp
+++ b/stm32_development/murasaki/murasaki/murasaki_ug.hpp
@@ -108,10 +108,10 @@
108108 * \section sec6 Versatile printf() logger
109109 * Logging or "printf debug" is a strong tool in the embedded system development.
110110 *
111- * Murasaki has two levels of the printf debugging mechanism. One is the \ref murasaki::debugger->printf(),
111+ * Murasaki has two levels of the printf debugging mechanism. One is the \ref murasaki::debugger->Printf(),
112112 * the other is \ref MURASAKI_ASSERT macro.
113113 *
114- * The murasaki::debugger->printf() is flexible output mechanism which has several good
114+ * The murasaki::debugger->Printf() is flexible output mechanism which has several good
115115 * features :
116116 * \li printf() compatible parameters.
117117 * \li Task/interrupt bi-context operation
@@ -122,8 +122,8 @@
122122 * but also in the interrupt context.
123123 *
124124 * \section sec7 Guard by assertion
125- * In addition to the murasaki::debugger->printf(), programmer can use \ref MURASAKI_ASSERT macro.
126- * This allows easy assertion and logging. This macro uses the murasaki::debugger->printf()
125+ * In addition to the murasaki::debugger->Printf(), programmer can use \ref MURASAKI_ASSERT macro.
126+ * This allows easy assertion and logging. This macro uses the murasaki::debugger->Printf()
127127 * internally.
128128 *
129129 * This assertion is used inside murasaki class library. Then, the wrong context,
@@ -222,7 +222,7 @@
222222 *
223223 * First, class instances are created inside heap region by new operator often.
224224 * Second, Task stack is also created inside heap.
225- * And third, murasaki::Debugger allocates a huge size of FIFO buffer betwen its murasaki::Debugger::printf()
225+ * And third, murasaki::Debugger allocates a huge size of FIFO buffer betwen its murasaki::Debugger::Printf()
226226 * function and logger task.
227227 *
228228 * The size of this FIFO buffer is defined by @ref PLATFORM_CONFIG_DEBUG_BUFFER_SIZE and default is 4KB.
@@ -484,7 +484,7 @@
484484 * // Hook for the assert_failure() in main.c
485485 * void CustomAssertFailed(uint8_t* file, uint32_t line)
486486 * {
487- * murasaki::debugger->printf("Wrong parameters value: file %s on line %d\r\n", file, line);
487+ * murasaki::debugger->Printf("Wrong parameters value: file %s on line %d\r\n", file, line);
488488 * }
489489 *
490490 * \endcode
--- a/stm32_development/murasaki/murasaki/spimaster.cpp
+++ b/stm32_development/murasaki/murasaki/spimaster.cpp
@@ -70,6 +70,9 @@ bool SpiMaster::TransmitAndReceive(murasaki::AbstractSpiSlaveSpecifier* spi_spec
7070 // Assert the chip select for slave
7171 spi_spec->AssertCs();
7272 {
73+ // Keep coherency between the L2 and cache before DMA
74+ murasaki::InvalidateDataCacheByAddress(tx_data, size);
75+ murasaki::InvalidateDataCacheByAddress(rx_data, size);
7376
7477 // Transmit over SPI
7578 HAL_StatusTypeDef status = HAL_SPI_TransmitReceive_DMA(peripheral_, tx_data, rx_data, size);
--- a/stm32_development/murasaki/murasaki/uart.cpp
+++ b/stm32_development/murasaki/murasaki/uart.cpp
@@ -90,6 +90,9 @@ bool Uart::Transmit(uint8_t * data, unsigned int size, WaitMilliSeconds timeout_
9090 // make this methold re-entrant in task context.
9191 tx_critical_section_->Enter();
9292 {
93+ // Keep coherency between the L2 and cache before DMA
94+ murasaki::InvalidateDataCacheByAddress(data, size);
95+
9396 HAL_StatusTypeDef status = HAL_UART_Transmit_DMA(peripheral_, data, size);
9497 MURASAKI_ASSERT(HAL_OK == status);
9598
@@ -123,6 +126,9 @@ bool Uart::Receive(uint8_t * data, unsigned int size, WaitMilliSeconds timeout_m
123126 // make this methold re-entrant in task context.
124127 rx_critical_section_->Enter();
125128 {
129+ // Keep coherency between the L2 and cache before DMA
130+ murasaki::InvalidateDataCacheByAddress(data, size);
131+
126132 HAL_StatusTypeDef status = HAL_UART_Receive_DMA(peripheral_, data, size);
127133 MURASAKI_ASSERT(HAL_OK == status);
128134