• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

テスト用のあれこれ共用フォルダ


Commit MetaInfo

Revisãob2ca88237ebbc6397c309a0f587b16c93b45f3ce (tree)
Hora2018-06-23 16:04:07
Autortakemasa <suikan@user...>
Commitertakemasa

Mensagem de Log

SPI master has been debugged. I2C is under debugging.

So far, transmission is OK. Need to check the EEProm behavior on the
secodn transmission.

Mudança Sumário

Diff

--- a/stm32_development/nucleo-l152re-fujitsubo-test/Inc/platform_defs.hpp
+++ b/stm32_development/nucleo-l152re-fujitsubo-test/Inc/platform_defs.hpp
@@ -83,6 +83,7 @@ struct Platform
8383 AbstractLogger * logger; ///< logging class object for debugger
8484 AbstractSpiMaster * spi; ///< SPIport controler
8585 AbstractSpiSlaveSpecifier * m95010; ///< 1kbit EEPROM
86+ AbstractI2CMaster * i2c1; ///< I2C controler
8687
8788 AbstractBitOut * led;
8889 };
--- a/stm32_development/nucleo-l152re-fujitsubo-test/Src/main.c
+++ b/stm32_development/nucleo-l152re-fujitsubo-test/Src/main.c
@@ -251,7 +251,7 @@ static void MX_SPI1_Init(void)
251251 hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
252252 hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
253253 hspi1.Init.NSS = SPI_NSS_SOFT;
254- hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
254+ hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
255255 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
256256 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
257257 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
--- a/stm32_development/nucleo-l152re-fujitsubo-test/Src/murasaki_platform.cpp
+++ b/stm32_development/nucleo-l152re-fujitsubo-test/Src/murasaki_platform.cpp
@@ -82,6 +82,8 @@ void InitPlatform()
8282 SPI_CS_GPIO_Port,
8383 SPI_CS_Pin);
8484
85+ murasaki::platform.i2c1 = new murasaki::I2cMaster(&hi2c1);
86+
8587 // Setting the debugger
8688 murasaki::debugger = new murasaki::Debugger(murasaki::platform.logger);
8789 // Set the debugger as AutoRePrint mode, for the easy operation.
@@ -89,6 +91,8 @@ void InitPlatform()
8991
9092 }
9193
94+#define M24128_ADDR 0x50
95+
9296 /**
9397 * @brief The body of the real application.
9498 * @ingroup MURASAKI_PLATFORM_GROUP
@@ -106,23 +110,49 @@ void ExecPlatform()
106110 // counter for the demonstration.
107111 static int count = 0;
108112
109- uint8_t txbuf[2];
110- uint8_t rxbuf[2];
113+ uint8_t txbuf[10];
114+ uint8_t rxbuf[10];
111115
112- txbuf[0] = 0x09; // RDSR instruction for m95010.
116+ txbuf[0] = 0x05; // RDSR instruction for m95010.
113117
114118 // Loop forever
115119 while (true) {
116120 // Toggle LED.
117121 murasaki::platform.led->Toggle();
118-
122+#if 0
123+ // SPI test
119124 murasaki::platform.spi->TransmitAndReceive(murasaki::platform.m95010,
120125 txbuf, rxbuf, 2);
121126
122127 // print a message with counter value to the console.
123- murasaki::debugger->Printf("Hello %d status register = 0x%02x\n\r",
128+ murasaki::debugger->Printf("Hello %d SPI status register = 0x%02x\n\r",
124129 count, rxbuf[1]);
130+#else
131+ //I2C test
132+ // Writting 0xdeadbeaf from address 0
133+ txbuf[0] = 0; // memory address upper byte
134+ txbuf[1] = 0; // memory address lower byte
135+ txbuf[2] = 0xde; // data of address 0
136+ txbuf[3] = 0xad; // data of address 0
137+ txbuf[4] = 0xbe; // data of address 0
138+ txbuf[5] = 0xef; // data of address 0
139+
140+ // Write data
141+ murasaki::platform.i2c1->Transmit(M24128_ADDR, txbuf, 6);
142+ murasaki::debugger->Printf("Hello %d I2C Transmit \n\r", count);
143+
144+ // Dummy write to set the address
145+ murasaki::platform.i2c1->Transmit(M24128_ADDR, txbuf, 2);
146+ murasaki::debugger->Printf("Hello %d I2C Transmit Dummy \n\r", count);
147+
148+ // Read from the address
149+ murasaki::platform.i2c1->Receive(M24128_ADDR, rxbuf, 4);
125150
151+
152+ // print a message with counter value to the console.
153+ murasaki::debugger->Printf("Hello %d I2C Received 0x%02x\n\r", count,
154+ rxbuf[0]);
155+#endif
126156 // update the counter value.
127157 count++;
128158
@@ -277,6 +307,8 @@ void HAL_SPI_ErrorCallback(SPI_HandleTypeDef * hspi) {
277307 */
278308 void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef * hi2c)
279309 {
310+ if (murasaki::platform.i2c1->TransmitCompleteCallback(hi2c))
311+ return;
280312
281313 }
282314
@@ -295,6 +327,8 @@ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef * hi2c)
295327 * murasaki::Uart::ReceiveCompleteCallback() function.
296328 */
297329 void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef * hi2c) {
330+ if (murasaki::platform.i2c1->ReceiveCompleteCallback(hi2c))
331+ return;
298332
299333 }
300334
@@ -314,6 +348,8 @@ void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef * hi2c) {
314348 * murasaki::I2c::HandleError() function.
315349 */
316350 void HAL_I2C_ErrorCallback(I2C_HandleTypeDef * hi2c) {
351+ if (murasaki::platform.i2c1->HandleError(hi2c))
352+ return;
317353
318354 }
319355
--- a/stm32_development/nucleo-l152re-fujitsubo-test/nucleo-l152re-fujitsubo-test.ioc
+++ b/stm32_development/nucleo-l152re-fujitsubo-test/nucleo-l152re-fujitsubo-test.ioc
@@ -222,9 +222,10 @@ RCC.USBOutput=48000000
222222 RCC.VCOOutputFreq_Value=96000000
223223 SH.GPXTI13.0=GPIO_EXTI13
224224 SH.GPXTI13.ConfNb=1
225-SPI1.CalculateBaudRate=16.0 MBits/s
225+SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256
226+SPI1.CalculateBaudRate=125.0 KBits/s
226227 SPI1.Direction=SPI_DIRECTION_2LINES
227-SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
228+SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
228229 SPI1.Mode=SPI_MODE_MASTER
229230 SPI1.VirtualType=VM_MASTER
230231 USART2.IPParameters=VirtualMode