#include "stdio.h" #include "simpletools.h" #include #include #include #include #include struct __using("jm_fullduplexserial.spin2") jm; enum { _xtlfreq = 20_000_000, _clkfreq = 256_000_000, DOWNLOAD_BAUD = 230_400, DEBUG_BAUD = DOWNLOAD_BAUD, PINS = 20|7<<6, GROUP = 2, CLK_PIN = 6, TX_REGD = 1, CLK_REGD = 0, CPOL = 1, CPHA = 0, //CLK_DIV = 2, CLK_DIV = 8, M_NCO = 0x8000_0000UL / CLK_DIV + (0x8000_0000UL % CLK_DIV > 0UL ? 1UL : 0UL), // round up //M_LEADIN = X_IMM_32X1_1DAC1 | 7 + CLK_DIV + CLK_REGD - TX_REGD - (1 ^ CPHA) * (CLK_DIV>>1), M_LEADIN = X_IMM_32X1_1DAC1 | 5 + CLK_DIV + CLK_REGD - TX_REGD - (1 ^ CPHA) * (CLK_DIV>>1), }; #define buff_size 32768 static long stack1[32800]; static long stack2[32800]; char arr[buff_size] = {0}; int cogid1; int cogid2; int temp = 0; unsigned int data_count = 0; int chunk_cnt = 0; int i = 0; FILE * fp; void print_data(){ printf("Started new cog print_data()\n"); mount("/sd", _vfs_open_sdcard()); FILE *fp = fopen("/sd/data.txt", "a"); FILE *fh ; if (fp == NULL) { printf("File failed to open in printdata..\n"); } // checking file is present or not else { printf("The file is now opened in printdata.\n"); } while (true){ while(_pollatn()==0); printf("Received attenuation from UART : Datasize = %d\n",sizeof(arr)); int data_cnt = fwrite(arr, sizeof(char), sizeof(arr), fp); while(data_cnt<0) { data_cnt = fwrite(arr, sizeof(char), sizeof(arr), fh); } printf("DATA_CNT write= %d\n", data_cnt); printf("Chunk written\n"); printf("Sending attenuation to PRINT second time: \n"); _cogatn((1<