Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed nRF24L01P SDFileSystem
Diff: L432KC-log_read.cpp
- Revision:
- 7:61d9e4606908
- Parent:
- 6:c7e81ea42e5a
- Child:
- 8:63d28d6b728a
--- a/L432KC-log_read.cpp Mon Jan 25 09:31:35 2021 +0000
+++ b/L432KC-log_read.cpp Tue Jan 26 04:43:57 2021 +0000
@@ -1,8 +1,9 @@
#include "mbed.h"
+#include "string.h"
#include "nRF24L01P.h"
#include "SDFileSystem.h"
-//dummyって名前だけど、マイコンボードL432KC用のログ読み取り治具の最終プログラムです。
+//マイコンボードL432KC用のログ読み取り治具の最終プログラムです。
//DigitalOut nRF_csn(D3 /*PB_6*/ ); //これは、もしかしてこのコードでも定義しとかないとかな?と思って定義した通信モジュのピン定義だけど、
//DigitalOut nRF_ce(D6); //ライブラリに定義があり、そことかぶるから不要と言われたので不要!
@@ -13,7 +14,7 @@
Ticker interrput;
SDFileSystem sd1(PB_5_ALT0, PB_4_ALT0, PB_3_ALT0, A0, "sd1"); // mosi, miso, sclk, cs__このコードの場所はメインの上にしよう_SDFileSystemを新しくしたら、ヘッダ側(SDFileSystem.cppの122行辺り)で周波数を定義してたので,(10MHzぐらいに設定)周波数は削除した書き方に
-//D11, D12, D13
+
#define TRANSFER_SIZE 32
int out_flg = 0;
@@ -40,10 +41,7 @@
//A6, A5, A4
-//nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); // mosi, miso, sck, csn, ce, irq
-
void timer(){
- uint16_t ain;
if(rcv_flg == 1) {
@@ -61,12 +59,7 @@
}
- /*
- if(i>5){
- i = 0;
- close_flg = 1;
- }
- */
+
}
@@ -75,7 +68,7 @@
// ...read the data into the receive buffer
txData1[txDataIdx] = UDGS01.getc(); //getcharだと、PCからのキーボード入力という標準コンソール?のやつだからだめらしい
-// pc.printf("tx[%d] = %s", txDataIdx, &txData[txDataIdx]);
+
txDataIdx++;
if (txDataIdx == TRANSFER_SIZE) {//最初の32回
@@ -107,13 +100,17 @@
printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() );
printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
-// pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
+
printf( "Type keys to test transfers:\r\n (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE );
my_nrf24l01p.setTransferSize( TRANSFER_SIZE );//mAX 32
my_nrf24l01p.setReceiveMode();
my_nrf24l01p.enable();
-
+
+ memset(txData1, '\0', sizeof(txData1));
+ memset(txData2, '\0', sizeof(txData2));
+ memset(rxData1, '\0', sizeof(rxData1));
+ memset(rxData2, '\0', sizeof(rxData2));
printf("Hellooooo\r\n");
wait_ms(10);
@@ -128,7 +125,7 @@
// while(1);
}
else{
-// fwrite(rxData3, sizeof(char), TRANSFER_SIZE, fp);
+
printf("SD opened\r\n");
fprintf(fp, "opened!!\r\n");
fclose(fp);
@@ -142,7 +139,7 @@
UDGS01.attach(recieve,Serial::RxIrq);//牛からのデータ受信したら割り込み発生してrecieveを呼び出す
- // my_nrf24l01p.flush_rx_fifo();
+
while(1){
if ( my_nrf24l01p.readable(NRF24L01P_PIPE_P0) ) { //受信可能であれば
@@ -154,7 +151,7 @@
wait_ms(1);
}
-// memcpy(rxData3, rxData1, TRANSFER_SIZE);
+
if(open_flg == 1){
fp = fopen("/sd1/recieve_log.txt", "a");
@@ -169,14 +166,14 @@
}
if(write_flg == 1){
-// fprintf(fp, "check\r\n");
+
fwrite(rxData2, sizeof(char), TRANSFER_SIZE, fp);
wait_ms(1);
fclose(fp);
wait_ms(1);
-// close_flg = 0;
+
write_flg = 0;
open_flg = 1;
}
@@ -200,13 +197,12 @@
}
if(write_flg == 2){
-// fprintf(fp, "check\r\n");
fwrite(txData2, sizeof(char), TRANSFER_SIZE, fp);
wait_ms(1);
fclose(fp);
wait_ms(1);
-// close_flg = 0;
+
write_flg = 0;
open_flg = 1;
}