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: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of COM_MNG_TMTC_SIMPLE by
Revision 132:d4a4461214ad, committed 2016-02-29
- Comitter:
- ee12b079
- Date:
- Mon Feb 29 13:21:40 2016 +0000
- Parent:
- 130:d5b53088270b
- Child:
- 136:8074893cd24e
- Commit message:
- i2c integration in progress
Changed in this revision
--- a/COM_MNG_TMTC.h Sat Feb 27 07:12:04 2016 +0000
+++ b/COM_MNG_TMTC.h Mon Feb 29 13:21:40 2016 +0000
@@ -991,55 +991,44 @@
{
- uint8_t PL_TM_SIZE;
+
#if DEBUG
printf("Telecommand is for PL\r\n");
#endif
- // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae
+
+
+ if(GETservice_subtype(tc_ptr) == 0xD0 || GETservice_subtype(tc_ptr) == 0xD2 || GETservice_subtype(tc_ptr) == 0xD3)
+ {
+ PL_TM_SIZE = TM_LONG_SIZE;
+ }
+ else
+ {
+ PL_TM_SIZE = TM_SHORT_SIZE;
+ }
+
if(GETshort_or_long_tc(tc_ptr) == LONG_TC_CODE)
FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_LONG_SIZE);
else
+ {
FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_SHORT_SIZE);
-
+ }
while(1)
{
gLEDG = !gLEDG;
t_pl.start();
- if(PYLD_I2C_Int == 1)
+ if(rcv_isr == 1)
{
+ gPC.printf("read_ack = %d",read_ack);
t_pl.stop();
- gPC.printf("i2c_t = %d",t_pl.read_ms());
- if(GETservice_subtype(tc_ptr) == 0xD0 || GETservice_subtype(tc_ptr) == 0xD2 || GETservice_subtype(tc_ptr) == 0xD3) //check which all require short TM
- {
- FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_LONG_SIZE);
- break;
- }
- else
- {
- FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_SHORT_SIZE);
+ //gPC.printf("i2c_t = %d",t_pl.read_ms());
+ for(int i = 0;i< PL_TM_SIZE;i++)
+ tm_pointer->TM_string[i] = PL_I2C_DATA[i];
+ rcv_isr = 0;
break;
- }
- }
-
-
}
-
-
- // for(int i;i<2000;i++){if(PYLD_I2C_Int=1)i=2001;}//timeout to be defined
-
-
- //PL should reset the i2c pin
-
- // received = 1;
- // }
- // if(received == 1 )
- // {
- // printf("Telemetry is received from BAE\r\n");
- // printf("%s", tm_ptr->TM_string);
- // received = 0;
- // } // similar to BAE functions
+ }
tm_pointer->next_TM = NULL; return tm_ptr;
break;
}
--- a/adf.h Sat Feb 27 07:12:04 2016 +0000
+++ b/adf.h Mon Feb 29 13:21:40 2016 +0000
@@ -314,13 +314,12 @@
gCS_ADF=1;\
SPI_mutex.unlock();\
loop_on = false;\
- gLEDR = 1;\
}\
else{\
ADF_off = true;\
}\
}else{\
- gLEDR = !gLEDR;\
+ gLEDG = !gLEDG;\
write_data;\
if(sent_tmfrom_SDcard)\
send_tm_from_SD_card_fun();\
--- a/cdms_sd.h Sat Feb 27 07:12:04 2016 +0000 +++ b/cdms_sd.h Mon Feb 29 13:21:40 2016 +0000 @@ -1,6 +1,3 @@ - - - //SPI spi(PTE1, PTE3, PTE2); // MOSI,MISO, CLOCK microcontroller(in order) //DigitalOut cs_sd(PTE22);
--- a/i2c.h Sat Feb 27 07:12:04 2016 +0000
+++ b/i2c.h Mon Feb 29 13:21:40 2016 +0000
@@ -7,29 +7,24 @@
//I2C master(PTC9,PTC8);
const int addr = 0x20; //slave address
const int addr_pl = 0x20<<1; //PL slave address
-//char telecommand[tc_len];
-//char telemetry[tm_len];
-//Timer test;
-//Timer t_read;
+
bool write_ack = true;
bool read_ack = true;
-int count = 0;
+
+char PL_I2C_DATA[134];//Payload i2c array
+uint8_t PL_TM_SIZE;//size of data to bev read from i2c
void FCTN_I2C_WRITE_PL(char *data2,uint8_t tc_len2)
{
write_ack = master.write(addr_pl|0x00,data2,tc_len2);//address to be defined in payload
- if(write_ack == 0)
+ if(write_ack == 1)
{
- #if DEBUG
- gPC.printf("\n\r data not sent \n");
- #endif
+ printf("\n\rdata not sent\n");
}
else
{
- #if DEBUG
- gPC.printf("\n\r data sent \n");
- #endif
+
}
}
void FCTN_I2C_READ_PL(char *data,int length)
@@ -37,15 +32,19 @@
//t_read.start();
read_ack = master.read(addr_pl|1,data,length);
//t_read.stop();
+ uint8_t len = 0;
- //if(read_ack == 0)
- // printf("\n\rData received from BAE %s \n",data);
- //if (read_ack == 1)
-// {
+ printf("\n\r i2c data : \n\n\r\r");
+ while(len != length) printf("%c",data[len]);
+ printf(" \n\n\r\r");
+ if(read_ack == 0)
+ printf("\n\rData received from PL %s \n",data);
+ if (read_ack == 1)
+ {
// gLEDR = 1;
-// printf("\n \r data not received \n");
+ printf("\n \r data not received from PL\n");
// gLEDR = 0;
-// }
+ }
//if(read_ack == 1)
//pc.printf("\n \r data not received \n");
//printf("\n\r %d \n",t.read_us());
@@ -63,9 +62,7 @@
// printf("\n\rData received from BAE %s \n",data);
if (read_ack == 1)
{
- gLEDR = 1;
printf("\n \r data not received \n");
- gLEDR = 0;
}
//if(read_ack == 1)
//pc.printf("\n \r data not received \n");
@@ -93,4 +90,21 @@
irpt_2_slv = 0;
//gPC.printf("\n\r %d \n",t.read_us());
//t.reset();
+}
+
+
+
+
+
+
+
+
+
+
+void isr_pyldtm()
+{
+
+ read_ack = master.read(addr_pl|1,PL_I2C_DATA,134);
+ gLEDR=!gLEDR;
+ rcv_isr = 1;
}
\ No newline at end of file
--- a/main.cpp Sat Feb 27 07:12:04 2016 +0000
+++ b/main.cpp Mon Feb 29 13:21:40 2016 +0000
@@ -2,7 +2,10 @@
#include "mbed.h"
+uint8_t rcv_isr = 0; // flag for interrupt
+
#define DEBUG 1
+#define SDCARD 0
#include "SimpleDMA.h"
#include "dmaSPIslave.h"
@@ -28,6 +31,8 @@
#include "ThreadsAndFunctions.h"
//void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
+
+
int main()
{
//gLEDR = 1;
@@ -43,7 +48,7 @@
RX1M.attach(&rx_read, Serial::RxIrq);
//I2C to Payload (depends on pl interrupt design)
- //PYLD_I2C_Int.rise(&isr_pyldtm);
+ PYLD_I2C_Int.rise(&isr_pyldtm);
// DEBUG
@@ -60,7 +65,9 @@
gCS_ADF = 1;
//FCTN_CDMS_INIT_RTC();/* rtc initialization*/
+ #if SDCARD
FCTN_CDMS_SD_INIT();/* sd card initialization*/
+ #endif
#if DEBUG
gPC.puts("welcome to mng_tmtc\r\n");
@@ -72,15 +79,16 @@
#if DEBUG
gPC.puts("allocating threads\r\n");
#endif
+ #if SDCARD
gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
// gPC.puts("step one complete\r\n");
gSCIENCE_THREAD->set_priority(osPriorityBelowNormal);
+ #endif
#if DEBUG
gPC.puts("competed allocating threads\r\n");
#endif
-
-
+
// *******************INITIALISATIONS END********************
//RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
@@ -100,9 +108,27 @@
{delete gSCIENCE_THREAD;
break;}
}*/
-
-
-
+ int i =0 ;
+ char test[1] ;
+ test[0] = 7;
+ while(1)
+ {
+
+ wait(5);
+ printf("Wriring to I2C\n");
+ master.write(addr_pl|0x00,test,1);
+
+ if(rcv_isr == 1)
+ {
+ for(i = 0; i < 134 ; i++)
+ {
+ printf("%d\r\n",PL_I2C_DATA[i]);
+ }
+ rcv_isr = 0;
+ }
+
+ }
+
while(true){
Thread::wait(osWaitForever);
//state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
