CDMS_CODE_samp_23SEP_DMA_flag
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA by
adf.h@241:410c9cdd4f6e, 2016-07-08 (annotated)
- Committer:
- ee12b079
- Date:
- Fri Jul 08 06:50:21 2016 +0000
- Revision:
- 241:410c9cdd4f6e
- Parent:
- 237:12061b714e47
- Child:
- 242:4a78c173060b
Integrating adf, errors in tes_pl.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 1:a0055b3280c8 | 1 | //without reset feature , with state checks. |
ee12b079 | 172:c508bbf7e89a | 2 | InterruptIn IRQ(ADF_IRQ); |
aniruddhv | 52:0bd68655c651 | 3 | //Ticker ticker; |
ee12b079 | 176:a5bfe3ca60b1 | 4 | |
shreeshas95 | 1:a0055b3280c8 | 5 | bool loop_on; |
shreeshas95 | 1:a0055b3280c8 | 6 | bool ADF_off; |
shreeshas95 | 1:a0055b3280c8 | 7 | bool buffer_state; |
ee12b079 | 9:e9eaada136c6 | 8 | bool finish_write_data; |
shreeshas95 | 1:a0055b3280c8 | 9 | uint8_t signal = 0x00; |
ee12b079 | 237:12061b714e47 | 10 | unsigned char bbram_buffer[66]={0x19,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0xF4,0xC2,0x10,0xC0,0x00,0x30,0x31,0x07,0x00,0x01,0x00,0x7F,0x00,0x0B,0x37,0x00,0x00,0x40,0x0C,0x00,0x05,0x00,0x00,0x18,0x12,0x34,0x56,0x20,0x10,0xC4,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xE0,0x00,0x10,0x04,0x00,0x00,0x00,0x00,0x00}; |
ee12b079 | 241:410c9cdd4f6e | 11 | bool data_irq_err=0; |
ee12b079 | 241:410c9cdd4f6e | 12 | bool data_err= false; |
ee12b079 | 241:410c9cdd4f6e | 13 | unsigned char temp_byte=0x00; |
ee12b079 | 241:410c9cdd4f6e | 14 | unsigned char data_err1[112]; |
ee12b079 | 241:410c9cdd4f6e | 15 | unsigned char data_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 16 | unsigned int byte_count =0; |
ee12b079 | 241:410c9cdd4f6e | 17 | #define DATA_ERR_THRS 20 |
ee12b079 | 241:410c9cdd4f6e | 18 | bool rolling_buffer_settings_error=true; |
ee12b079 | 241:410c9cdd4f6e | 19 | bool bbram_write_success=true; |
ee12b079 | 241:410c9cdd4f6e | 20 | int bbram_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 21 | int rbp_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 22 | bool reset_flag=false; |
ee12b079 | 241:410c9cdd4f6e | 23 | #define RBP_THRS 4 |
ee12b079 | 241:410c9cdd4f6e | 24 | bool quit_configuration=false; |
ee12b079 | 241:410c9cdd4f6e | 25 | bool power_reset_flag=false; |
ee12b079 | 241:410c9cdd4f6e | 26 | unsigned int power_reset_count=0; |
ee12b079 | 241:410c9cdd4f6e | 27 | bool Configuration_done=false; |
ee12b079 | 241:410c9cdd4f6e | 28 | #define HW_THRS 2 |
ee12b079 | 9:e9eaada136c6 | 29 | |
shreeshas95 | 2:2caf2a9a13aa | 30 | //int initialise_card(); |
shreeshas95 | 2:2caf2a9a13aa | 31 | //int disk_initialize(); |
shreeshas95 | 1:a0055b3280c8 | 32 | //------------------------------------------------------------------------ |
shreeshas95 | 1:a0055b3280c8 | 33 | // state checking functions |
shreeshas95 | 1:a0055b3280c8 | 34 | //bool assrt_phy_off( int, int, int); |
shreeshas95 | 1:a0055b3280c8 | 35 | //bool assrt_phy_on( int,int,int); |
shreeshas95 | 1:a0055b3280c8 | 36 | //bool assrt_phy_tx(int,int,int); |
ee12b079 | 241:410c9cdd4f6e | 37 | |
ee12b079 | 241:410c9cdd4f6e | 38 | #define TRANSMIT_LEN_1 0xFF |
ee12b079 | 241:410c9cdd4f6e | 39 | #define TRANSMIT_LEN_2 0xFF |
ee12b079 | 241:410c9cdd4f6e | 40 | /***/ |
ee12b079 | 241:410c9cdd4f6e | 41 | Timer T; |
ee12b079 | 9:e9eaada136c6 | 42 | |
shreeshas95 | 1:a0055b3280c8 | 43 | #define START_ADDRESS 0x020; |
shreeshas95 | 1:a0055b3280c8 | 44 | #define MISO_PIN PTE3 |
shreeshas95 | 1:a0055b3280c8 | 45 | /**************Defining Counter Limits**************/ |
shreeshas95 | 1:a0055b3280c8 | 46 | #define THRS 20 |
shreeshas95 | 1:a0055b3280c8 | 47 | #define STATE_ERR_THRS 20 |
shreeshas95 | 1:a0055b3280c8 | 48 | #define PHY_OFF_EXEC_TIME 300 |
shreeshas95 | 1:a0055b3280c8 | 49 | #define PHY_ON_EXEC_TIME 300 |
shreeshas95 | 1:a0055b3280c8 | 50 | #define PHY_TX_EXEC_TIME 600 |
shreeshas95 | 1:a0055b3280c8 | 51 | /******DEFINING COMMANDS*********/ |
shreeshas95 | 1:a0055b3280c8 | 52 | #define CMD_HW_RESET 0xC8 |
shreeshas95 | 1:a0055b3280c8 | 53 | #define CMD_PHY_ON 0xB1 |
shreeshas95 | 1:a0055b3280c8 | 54 | #define CMD_PHY_OFF 0xB0 |
shreeshas95 | 1:a0055b3280c8 | 55 | #define CMD_PHY_TX 0xB5 |
shreeshas95 | 1:a0055b3280c8 | 56 | #define CMD_CONFIG_DEV 0xBB |
ee12b079 | 241:410c9cdd4f6e | 57 | /**STATES**/ |
ee12b079 | 241:410c9cdd4f6e | 58 | //======================= |
ee12b079 | 241:410c9cdd4f6e | 59 | #define PHY_OFF 0xB1 |
ee12b079 | 241:410c9cdd4f6e | 60 | #define PHY_ON 0xB2 |
ee12b079 | 241:410c9cdd4f6e | 61 | #define PHY_TX 0xB4 |
ee12b079 | 241:410c9cdd4f6e | 62 | #define BUSY 0x00 |
ee12b079 | 241:410c9cdd4f6e | 63 | //=================================================== |
ee12b079 | 241:410c9cdd4f6e | 64 | |
ee12b079 | 241:410c9cdd4f6e | 65 | unsigned int Adf_data_counter=0; |
ee12b079 | 241:410c9cdd4f6e | 66 | unsigned char status =0; |
ee12b079 | 241:410c9cdd4f6e | 67 | unsigned int cmd_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 68 | unsigned int data_length; |
ee12b079 | 241:410c9cdd4f6e | 69 | unsigned int state_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 70 | unsigned int miso_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 71 | unsigned int hw_reset_err_cnt=0; |
ee12b079 | 241:410c9cdd4f6e | 72 | unsigned int counter =0; |
ee12b079 | 241:410c9cdd4f6e | 73 | bool temp_return = 0; |
ee12b079 | 241:410c9cdd4f6e | 74 | bool bcn_flag=0; |
ee12b079 | 241:410c9cdd4f6e | 75 | bool bbram_flag=0; |
ee12b079 | 241:410c9cdd4f6e | 76 | |
ee12b079 | 241:410c9cdd4f6e | 77 | bool stop_transmission=false; |
ee12b079 | 241:410c9cdd4f6e | 78 | |
ee12b079 | 241:410c9cdd4f6e | 79 | #define reset_flags {\ |
ee12b079 | 241:410c9cdd4f6e | 80 | finish_write_data = false;\ |
ee12b079 | 241:410c9cdd4f6e | 81 | buffer_state = true;\ |
ee12b079 | 241:410c9cdd4f6e | 82 | last_buffer = false;\ |
ee12b079 | 241:410c9cdd4f6e | 83 | loop_on = true;\ |
ee12b079 | 241:410c9cdd4f6e | 84 | ADF_off = false;\ |
ee12b079 | 241:410c9cdd4f6e | 85 | buffer_state = true;\ |
ee12b079 | 241:410c9cdd4f6e | 86 | loop_on = true;\ |
ee12b079 | 241:410c9cdd4f6e | 87 | ADF_off = false;\ |
ee12b079 | 241:410c9cdd4f6e | 88 | sent_tmfrom_SDcard = false;\ |
ee12b079 | 241:410c9cdd4f6e | 89 | Adf_data_counter=0;\ |
ee12b079 | 241:410c9cdd4f6e | 90 | status =0;\ |
ee12b079 | 241:410c9cdd4f6e | 91 | cmd_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 92 | data_length;\ |
ee12b079 | 241:410c9cdd4f6e | 93 | state_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 94 | miso_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 95 | hw_reset_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 96 | counter =0;\ |
ee12b079 | 241:410c9cdd4f6e | 97 | bcn_flag=0;\ |
ee12b079 | 241:410c9cdd4f6e | 98 | bbram_flag=0;\ |
ee12b079 | 241:410c9cdd4f6e | 99 | stop_transmission=false;\ |
ee12b079 | 241:410c9cdd4f6e | 100 | } |
ee12b079 | 241:410c9cdd4f6e | 101 | |
ee12b079 | 241:410c9cdd4f6e | 102 | |
ee12b079 | 241:410c9cdd4f6e | 103 | int err_arr[64]; |
ee12b079 | 241:410c9cdd4f6e | 104 | bool bbram_err=false; |
ee12b079 | 241:410c9cdd4f6e | 105 | int err_idx=-1; |
ee12b079 | 241:410c9cdd4f6e | 106 | int err[64]; |
ee12b079 | 241:410c9cdd4f6e | 107 | #define bbram_check gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 108 | for(int i=0;i<64;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 109 | err_arr[i]=0;\ |
ee12b079 | 241:410c9cdd4f6e | 110 | }\ |
ee12b079 | 241:410c9cdd4f6e | 111 | for(int i=0;i<64;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 112 | err[i]=0;\ |
ee12b079 | 241:410c9cdd4f6e | 113 | }\ |
ee12b079 | 241:410c9cdd4f6e | 114 | bbram_err=false;\ |
ee12b079 | 241:410c9cdd4f6e | 115 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 116 | spi.write(0x39);\ |
ee12b079 | 241:410c9cdd4f6e | 117 | spi.write(0x00);\ |
ee12b079 | 241:410c9cdd4f6e | 118 | spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 119 | for(int i=0;i<64;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 120 | err_arr[i]=spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 121 | if(err_arr[i]!=bbram_buffer[i+2]){\ |
ee12b079 | 241:410c9cdd4f6e | 122 | err[i]=1;\ |
ee12b079 | 241:410c9cdd4f6e | 123 | bbram_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 124 | }\ |
ee12b079 | 241:410c9cdd4f6e | 125 | }\ |
ee12b079 | 241:410c9cdd4f6e | 126 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 127 | if(!bbram_err)\ |
ee12b079 | 241:410c9cdd4f6e | 128 | gPC.printf("BBRAM verified \r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 129 | else\ |
ee12b079 | 241:410c9cdd4f6e | 130 | gPC.printf("BBRAM error \r\n");\ |
ee12b079 | 176:a5bfe3ca60b1 | 131 | |
ee12b079 | 241:410c9cdd4f6e | 132 | |
ee12b079 | 241:410c9cdd4f6e | 133 | bool tx_loop=1; |
ee12b079 | 241:410c9cdd4f6e | 134 | |
ee12b079 | 241:410c9cdd4f6e | 135 | #define PRNT_ONCE {\ |
ee12b079 | 241:410c9cdd4f6e | 136 | gPC.printf("%d %d lol_ what?\r\n",segment_len,EOS_len);\ |
ee12b079 | 241:410c9cdd4f6e | 137 | } |
ee12b079 | 241:410c9cdd4f6e | 138 | |
ee12b079 | 241:410c9cdd4f6e | 139 | #define bbram_write {\ |
ee12b079 | 241:410c9cdd4f6e | 140 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 141 | spi.write(0xB0);\ |
ee12b079 | 241:410c9cdd4f6e | 142 | wait_us(300);\ |
ee12b079 | 241:410c9cdd4f6e | 143 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 144 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 145 | for(int i=0;i<66;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 146 | spi.write(bbram_buffer[i]);\ |
ee12b079 | 241:410c9cdd4f6e | 147 | }\ |
ee12b079 | 241:410c9cdd4f6e | 148 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 149 | } |
ee12b079 | 241:410c9cdd4f6e | 150 | //------------------------------------------------------------------------ |
ee12b079 | 241:410c9cdd4f6e | 151 | // state checking functions |
ee12b079 | 241:410c9cdd4f6e | 152 | //bool assrt_phy_off( int, int, int); |
ee12b079 | 241:410c9cdd4f6e | 153 | //bool assrt_phy_on( int,int,int); |
ee12b079 | 241:410c9cdd4f6e | 154 | //bool assrt_phy_tx(int,int,int); |
ee12b079 | 241:410c9cdd4f6e | 155 | |
shreeshas95 | 1:a0055b3280c8 | 156 | #define check_status {\ |
shreeshas95 | 1:a0055b3280c8 | 157 | unsigned char stat=0;\ |
shreeshas95 | 1:a0055b3280c8 | 158 | gCS_ADF=0;\ |
ee12b079 | 176:a5bfe3ca60b1 | 159 | spi.write(0xFF);\ |
ee12b079 | 176:a5bfe3ca60b1 | 160 | stat = spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 161 | gCS_ADF=1;\ |
ee12b079 | 176:a5bfe3ca60b1 | 162 | status = stat;\ |
shreeshas95 | 1:a0055b3280c8 | 163 | } |
ee12b079 | 241:410c9cdd4f6e | 164 | |
ee12b079 | 241:410c9cdd4f6e | 165 | /*CMD_VAR*/ |
ee12b079 | 241:410c9cdd4f6e | 166 | bool cmd_bit=true; |
ee12b079 | 241:410c9cdd4f6e | 167 | bool cmd_err_flag=false; |
ee12b079 | 241:410c9cdd4f6e | 168 | unsigned char command = 0x00; |
ee12b079 | 241:410c9cdd4f6e | 169 | #define CMD(command) {\ |
ee12b079 | 241:410c9cdd4f6e | 170 | cmd_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 171 | cmd_err_flag=false;\ |
ee12b079 | 241:410c9cdd4f6e | 172 | while(cmd_err_cnt<3) {\ |
shreeshas95 | 1:a0055b3280c8 | 173 | check_status;\ |
ee12b079 | 241:410c9cdd4f6e | 174 | cmd_bit=status&0x20;\ |
ee12b079 | 241:410c9cdd4f6e | 175 | if(cmd_bit) {\ |
ee12b079 | 241:410c9cdd4f6e | 176 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 177 | spi.write(command);\ |
ee12b079 | 241:410c9cdd4f6e | 178 | gCS_ADF=1;\ |
shreeshas95 | 1:a0055b3280c8 | 179 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 180 | } else {\ |
ee12b079 | 241:410c9cdd4f6e | 181 | wait_us(5);\ |
ee12b079 | 241:410c9cdd4f6e | 182 | cmd_err_cnt++;\ |
shreeshas95 | 1:a0055b3280c8 | 183 | }\ |
ee12b079 | 241:410c9cdd4f6e | 184 | }\ |
ee12b079 | 241:410c9cdd4f6e | 185 | if(cmd_err_cnt==3) {\ |
ee12b079 | 241:410c9cdd4f6e | 186 | cmd_err_flag=true;\ |
ee12b079 | 241:410c9cdd4f6e | 187 | }\ |
ee12b079 | 241:410c9cdd4f6e | 188 | }\ |
ee12b079 | 241:410c9cdd4f6e | 189 | // all three arguments are int\ |
ee12b079 | 241:410c9cdd4f6e | 190 | #define assrt_phy_off {\ |
ee12b079 | 241:410c9cdd4f6e | 191 | int state_err_cnt = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 192 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 193 | if(cmd_err_flag){\ |
ee12b079 | 241:410c9cdd4f6e | 194 | temp_return=1;\ |
shreeshas95 | 1:a0055b3280c8 | 195 | }\ |
ee12b079 | 241:410c9cdd4f6e | 196 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 197 | for(int i = 0 ; i < 40 ;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 198 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 199 | check_status;\ |
ee12b079 | 241:410c9cdd4f6e | 200 | if(status == PHY_OFF){\ |
ee12b079 | 241:410c9cdd4f6e | 201 | temp_return = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 202 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 203 | }\ |
ee12b079 | 241:410c9cdd4f6e | 204 | else if(state_err_cnt>THRS){\ |
ee12b079 | 241:410c9cdd4f6e | 205 | temp_return = 1;\ |
ee12b079 | 241:410c9cdd4f6e | 206 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 207 | }\ |
ee12b079 | 241:410c9cdd4f6e | 208 | else {\ |
ee12b079 | 241:410c9cdd4f6e | 209 | wait_ms(1);\ |
ee12b079 | 241:410c9cdd4f6e | 210 | }\ |
shreeshas95 | 1:a0055b3280c8 | 211 | }\ |
shreeshas95 | 1:a0055b3280c8 | 212 | }\ |
shreeshas95 | 1:a0055b3280c8 | 213 | } |
ee12b079 | 241:410c9cdd4f6e | 214 | |
ee12b079 | 241:410c9cdd4f6e | 215 | |
ee12b079 | 241:410c9cdd4f6e | 216 | bool hardware_reset(int bcn_call) |
ee12b079 | 241:410c9cdd4f6e | 217 | { |
ee12b079 | 241:410c9cdd4f6e | 218 | for(int i= 0; i < 2 ; i++) { |
shreeshas95 | 1:a0055b3280c8 | 219 | gCS_ADF=0; |
shreeshas95 | 1:a0055b3280c8 | 220 | spi.write(CMD_HW_RESET); |
shreeshas95 | 1:a0055b3280c8 | 221 | gCS_ADF=1; |
shreeshas95 | 1:a0055b3280c8 | 222 | wait_ms(2);// Typically 1 ms |
shreeshas95 | 1:a0055b3280c8 | 223 | int count=0; |
ee12b079 | 241:410c9cdd4f6e | 224 | temp_return = 0; |
ee12b079 | 241:410c9cdd4f6e | 225 | while(count<10 && miso_err_cnt<10) { |
ee12b079 | 241:410c9cdd4f6e | 226 | if(MISO_PIN) { |
ee12b079 | 241:410c9cdd4f6e | 227 | // assrt_phy_off; |
ee12b079 | 241:410c9cdd4f6e | 228 | /*asseert_phyoff Starts**/ |
ee12b079 | 241:410c9cdd4f6e | 229 | {\ |
ee12b079 | 241:410c9cdd4f6e | 230 | int state_err_cnt = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 231 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 232 | if(cmd_err_flag){\ |
ee12b079 | 241:410c9cdd4f6e | 233 | temp_return=1;\ |
ee12b079 | 241:410c9cdd4f6e | 234 | }\ |
ee12b079 | 241:410c9cdd4f6e | 235 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 236 | for(int i = 0 ; i < 40 ;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 237 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 238 | check_status;\ |
ee12b079 | 241:410c9cdd4f6e | 239 | if(status == PHY_OFF){\ |
ee12b079 | 241:410c9cdd4f6e | 240 | temp_return = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 241 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 242 | }\ |
ee12b079 | 241:410c9cdd4f6e | 243 | else if(state_err_cnt>THRS){\ |
ee12b079 | 241:410c9cdd4f6e | 244 | temp_return = 1;\ |
ee12b079 | 241:410c9cdd4f6e | 245 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 246 | }\ |
ee12b079 | 241:410c9cdd4f6e | 247 | else {\ |
ee12b079 | 241:410c9cdd4f6e | 248 | wait_ms(1);\ |
ee12b079 | 241:410c9cdd4f6e | 249 | }\ |
ee12b079 | 241:410c9cdd4f6e | 250 | }\ |
ee12b079 | 241:410c9cdd4f6e | 251 | }\ |
ee12b079 | 241:410c9cdd4f6e | 252 | }\ |
ee12b079 | 241:410c9cdd4f6e | 253 | /*Assert_phy_off_ends*/ |
ee12b079 | 241:410c9cdd4f6e | 254 | |
ee12b079 | 241:410c9cdd4f6e | 255 | |
ee12b079 | 241:410c9cdd4f6e | 256 | |
ee12b079 | 241:410c9cdd4f6e | 257 | |
ee12b079 | 241:410c9cdd4f6e | 258 | |
shreeshas95 | 1:a0055b3280c8 | 259 | if(!temp_return){ |
shreeshas95 | 1:a0055b3280c8 | 260 | return 0; |
shreeshas95 | 1:a0055b3280c8 | 261 | } |
shreeshas95 | 1:a0055b3280c8 | 262 | count++; |
ee12b079 | 241:410c9cdd4f6e | 263 | } else { |
shreeshas95 | 1:a0055b3280c8 | 264 | wait_us(50); |
shreeshas95 | 1:a0055b3280c8 | 265 | miso_err_cnt++; |
shreeshas95 | 1:a0055b3280c8 | 266 | } |
shreeshas95 | 1:a0055b3280c8 | 267 | } |
shreeshas95 | 1:a0055b3280c8 | 268 | } |
shreeshas95 | 1:a0055b3280c8 | 269 | return 1; |
shreeshas95 | 1:a0055b3280c8 | 270 | } |
ee12b079 | 241:410c9cdd4f6e | 271 | //for reseting the transmission call assert function after b5 and b1. after b1 assert_phi_on and after b5 assert_phi_tx. |
shreeshas95 | 1:a0055b3280c8 | 272 | //---------------------------------------------------------------------------- |
ee12b079 | 241:410c9cdd4f6e | 273 | unsigned char temp; |
ee12b079 | 241:410c9cdd4f6e | 274 | bool reg_err; |
ee12b079 | 241:410c9cdd4f6e | 275 | int reg_err_cnt; |
ee12b079 | 241:410c9cdd4f6e | 276 | #define REG_ERR_THRS 5 |
ee12b079 | 241:410c9cdd4f6e | 277 | #define reg_check(addr1,addr2,reg_val){\ |
ee12b079 | 241:410c9cdd4f6e | 278 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 279 | reg_err=false;\ |
ee12b079 | 241:410c9cdd4f6e | 280 | spi.write(addr1);\ |
ee12b079 | 241:410c9cdd4f6e | 281 | spi.write(addr2);\ |
ee12b079 | 241:410c9cdd4f6e | 282 | spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 283 | temp = spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 284 | if(temp==reg_val)\ |
ee12b079 | 241:410c9cdd4f6e | 285 | reg_err = false;\ |
ee12b079 | 241:410c9cdd4f6e | 286 | else\ |
ee12b079 | 241:410c9cdd4f6e | 287 | reg_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 288 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 289 | } |
ee12b079 | 241:410c9cdd4f6e | 290 | |
ee12b079 | 241:410c9cdd4f6e | 291 | #define initiate {\ |
shreeshas95 | 1:a0055b3280c8 | 292 | gCS_ADF=0;\ |
shreeshas95 | 1:a0055b3280c8 | 293 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 294 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 295 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 296 | reg_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 297 | for(reg_err_cnt=0;reg_err_cnt<REG_ERR_THRS && reg_err;reg_err_cnt++){\ |
ee12b079 | 241:410c9cdd4f6e | 298 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 299 | spi.write(0x08);\ |
ee12b079 | 241:410c9cdd4f6e | 300 | spi.write(0x14);\ |
ee12b079 | 241:410c9cdd4f6e | 301 | spi.write(TRANSMIT_LEN_1);\ |
ee12b079 | 241:410c9cdd4f6e | 302 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 303 | reg_check(0x28,0x14,TRANSMIT_LEN_1);\ |
ee12b079 | 241:410c9cdd4f6e | 304 | }\ |
ee12b079 | 241:410c9cdd4f6e | 305 | if(reg_err)\ |
ee12b079 | 241:410c9cdd4f6e | 306 | gPC.printf("Reg_err_ignored %x \r\n",(int)temp);\ |
ee12b079 | 241:410c9cdd4f6e | 307 | else\ |
ee12b079 | 241:410c9cdd4f6e | 308 | gPC.printf("reg written successful %x \r\n",(int)temp);\ |
ee12b079 | 241:410c9cdd4f6e | 309 | reg_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 310 | for(reg_err_cnt=0;reg_err_cnt<REG_ERR_THRS && reg_err;reg_err_cnt++){\ |
ee12b079 | 241:410c9cdd4f6e | 311 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 312 | spi.write(0x08);\ |
ee12b079 | 241:410c9cdd4f6e | 313 | spi.write(0x15);\ |
ee12b079 | 241:410c9cdd4f6e | 314 | spi.write(TRANSMIT_LEN_2);\ |
ee12b079 | 241:410c9cdd4f6e | 315 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 316 | reg_check(0x28,0x15,TRANSMIT_LEN_2);\ |
ee12b079 | 241:410c9cdd4f6e | 317 | }\ |
ee12b079 | 241:410c9cdd4f6e | 318 | if(reg_err)\ |
ee12b079 | 241:410c9cdd4f6e | 319 | gPC.printf("Reg_err_ignored %x \r\n",(int)temp);\ |
ee12b079 | 241:410c9cdd4f6e | 320 | else\ |
ee12b079 | 241:410c9cdd4f6e | 321 | gPC.printf("reg written successful %x \r\n",(int)temp);\ |
ee12b079 | 241:410c9cdd4f6e | 322 | }\ |
ee12b079 | 241:410c9cdd4f6e | 323 | #define write_data {\ |
ee12b079 | 241:410c9cdd4f6e | 324 | counter++;\ |
shreeshas95 | 1:a0055b3280c8 | 325 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 326 | spi.write(0x0B);\ |
ee12b079 | 241:410c9cdd4f6e | 327 | spi.write(0x36);\ |
ee12b079 | 241:410c9cdd4f6e | 328 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 329 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 330 | data_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 331 | data_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 332 | while(data_err && (data_err_cnt<DATA_ERR_THRS)){\ |
ee12b079 | 241:410c9cdd4f6e | 333 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 334 | if(buffer_state){\ |
ee12b079 | 241:410c9cdd4f6e | 335 | spi.write(0x18);\ |
ee12b079 | 241:410c9cdd4f6e | 336 | spi.write(0x20);\ |
ee12b079 | 241:410c9cdd4f6e | 337 | for(unsigned char i=0; i<112;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 338 | if(bypass_adf)\ |
ee12b079 | 241:410c9cdd4f6e | 339 | gPC.putc(buffer_112[i]);\ |
ee12b079 | 241:410c9cdd4f6e | 340 | else\ |
ee12b079 | 241:410c9cdd4f6e | 341 | spi.write(buffer_112[i]);\ |
ee12b079 | 241:410c9cdd4f6e | 342 | /*gPC.printf("0x%X,",spi.write(buffer_112[i]));*/\ |
ee12b079 | 241:410c9cdd4f6e | 343 | }\ |
ee12b079 | 241:410c9cdd4f6e | 344 | }\ |
ee12b079 | 241:410c9cdd4f6e | 345 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 346 | spi.write(0x18);\ |
ee12b079 | 241:410c9cdd4f6e | 347 | spi.write(0x90);\ |
ee12b079 | 241:410c9cdd4f6e | 348 | for(unsigned char i=0; i<112;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 349 | if(bypass_adf)\ |
ee12b079 | 241:410c9cdd4f6e | 350 | gPC.putc(buffer_112[i]);\ |
ee12b079 | 241:410c9cdd4f6e | 351 | else\ |
ee12b079 | 241:410c9cdd4f6e | 352 | spi.write(buffer_112[i]);\ |
ee12b079 | 241:410c9cdd4f6e | 353 | /*gPC.printf("0x%X,",spi.write(buffer_112[i]));*/\ |
ee12b079 | 241:410c9cdd4f6e | 354 | }\ |
ee12b079 | 241:410c9cdd4f6e | 355 | }\ |
ee12b079 | 241:410c9cdd4f6e | 356 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 357 | wait_us(5);\ |
ee12b079 | 241:410c9cdd4f6e | 358 | data_err=false;\ |
ee12b079 | 241:410c9cdd4f6e | 359 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 360 | spi.write(0x38);\ |
ee12b079 | 241:410c9cdd4f6e | 361 | if(buffer_state){\ |
ee12b079 | 241:410c9cdd4f6e | 362 | spi.write(0x20);\ |
ee12b079 | 241:410c9cdd4f6e | 363 | }\ |
ee12b079 | 241:410c9cdd4f6e | 364 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 365 | spi.write(0x90);\ |
ee12b079 | 241:410c9cdd4f6e | 366 | }\ |
ee12b079 | 241:410c9cdd4f6e | 367 | spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 368 | for(unsigned char i=0; i<112;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 369 | temp_byte=spi.write(0xFF);\ |
ee12b079 | 241:410c9cdd4f6e | 370 | if(buffer_112[i]!=temp_byte){\ |
ee12b079 | 241:410c9cdd4f6e | 371 | data_err1[i]=1;\ |
ee12b079 | 241:410c9cdd4f6e | 372 | data_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 373 | }\ |
ee12b079 | 241:410c9cdd4f6e | 374 | }\ |
shreeshas95 | 1:a0055b3280c8 | 375 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 376 | /*SPI_mutex.unlock();*/\ |
ee12b079 | 241:410c9cdd4f6e | 377 | if(data_err==false){\ |
ee12b079 | 241:410c9cdd4f6e | 378 | buffer_state = !buffer_state;\ |
ee12b079 | 241:410c9cdd4f6e | 379 | }\ |
ee12b079 | 241:410c9cdd4f6e | 380 | data_err_cnt++;\ |
ee12b079 | 241:410c9cdd4f6e | 381 | if(last_buffer){\ |
ee12b079 | 241:410c9cdd4f6e | 382 | finish_write_data = true;\ |
ee12b079 | 241:410c9cdd4f6e | 383 | /*gPC.puts("adf_off\r\n");*/\ |
ee12b079 | 241:410c9cdd4f6e | 384 | }\ |
ee12b079 | 241:410c9cdd4f6e | 385 | }\ |
ee12b079 | 241:410c9cdd4f6e | 386 | } |
ee12b079 | 241:410c9cdd4f6e | 387 | |
ee12b079 | 241:410c9cdd4f6e | 388 | #define check {\ |
ee12b079 | 241:410c9cdd4f6e | 389 | check_status; //remove me\ |
ee12b079 | 241:410c9cdd4f6e | 390 | gPC.printf("I 0x%X\r\n",(int)status);//Remove me\ |
ee12b079 | 241:410c9cdd4f6e | 391 | if(IRQ || bypass_adf){\ |
ee12b079 | 241:410c9cdd4f6e | 392 | gPC.printf("det\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 393 | // if(1){\ |
ee12b079 | 241:410c9cdd4f6e | 394 | if(!ADF_off) {\ |
ee12b079 | 241:410c9cdd4f6e | 395 | // gCOM_MNG_TMTC_THREAD->signal_set(signal);\ |
ee12b079 | 241:410c9cdd4f6e | 396 | if(finish_write_data) {\ |
ee12b079 | 241:410c9cdd4f6e | 397 | write_data;\ |
ee12b079 | 241:410c9cdd4f6e | 398 | ADF_off=true;\ |
ee12b079 | 241:410c9cdd4f6e | 399 | } else {\ |
ee12b079 | 241:410c9cdd4f6e | 400 | write_data;\ |
ee12b079 | 241:410c9cdd4f6e | 401 | if(sent_tmfrom_SDcard)\ |
ee12b079 | 241:410c9cdd4f6e | 402 | send_tm_from_SD_card_fun();\ |
ee12b079 | 241:410c9cdd4f6e | 403 | else snd_tm.transmit_data(buffer_112,&last_buffer);\ |
ee12b079 | 241:410c9cdd4f6e | 404 | }\ |
ee12b079 | 241:410c9cdd4f6e | 405 | } else {\ |
ee12b079 | 241:410c9cdd4f6e | 406 | wait_ms(20);\ |
ee12b079 | 241:410c9cdd4f6e | 407 | // ticker.detach();\ |
ee12b079 | 241:410c9cdd4f6e | 408 | gCS_ADF=0;\ |
ee12b079 | 241:410c9cdd4f6e | 409 | spi.write(0xB1);\ |
ee12b079 | 241:410c9cdd4f6e | 410 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 411 | gPC.puts("transmission done\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 412 | // cout<<counter<<endl;\ |
ee12b079 | 241:410c9cdd4f6e | 413 | loop_on=false;\ |
ee12b079 | 241:410c9cdd4f6e | 414 | }\ |
ee12b079 | 241:410c9cdd4f6e | 415 | }\ |
ee12b079 | 241:410c9cdd4f6e | 416 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 417 | if(T.read_us()>98000){\ |
ee12b079 | 241:410c9cdd4f6e | 418 | data_irq_err=true;\ |
ee12b079 | 241:410c9cdd4f6e | 419 | CMD(CMD_PHY_ON);\ |
ee12b079 | 241:410c9cdd4f6e | 420 | gPC.printf("Data_error_detected");\ |
ee12b079 | 241:410c9cdd4f6e | 421 | }\ |
ee12b079 | 241:410c9cdd4f6e | 422 | }\ |
ee12b079 | 241:410c9cdd4f6e | 423 | } |
ee12b079 | 241:410c9cdd4f6e | 424 | |
ee12b079 | 241:410c9cdd4f6e | 425 | #define send_data {\ |
ee12b079 | 9:e9eaada136c6 | 426 | gCS_ADF=0;\ |
ee12b079 | 9:e9eaada136c6 | 427 | spi.write(0xBB);\ |
ee12b079 | 9:e9eaada136c6 | 428 | gCS_ADF=1;\ |
ee12b079 | 9:e9eaada136c6 | 429 | gCS_ADF=0;\ |
ee12b079 | 9:e9eaada136c6 | 430 | spi.write(0xFF);\ |
ee12b079 | 9:e9eaada136c6 | 431 | spi.write(0xFF);\ |
ee12b079 | 9:e9eaada136c6 | 432 | gCS_ADF=1;\ |
ee12b079 | 241:410c9cdd4f6e | 433 | if(sent_tmfrom_SDcard){\ |
ee12b079 | 95:42d6747900cb | 434 | send_tm_from_SD_card_fun();\ |
shreeshas95 | 1:a0055b3280c8 | 435 | }else{\ |
shreeshas95 | 1:a0055b3280c8 | 436 | snd_tm.transmit_data(buffer_112,&last_buffer);\ |
shreeshas95 | 1:a0055b3280c8 | 437 | }\ |
shreeshas95 | 1:a0055b3280c8 | 438 | write_data;\ |
shreeshas95 | 1:a0055b3280c8 | 439 | if(sent_tmfrom_SDcard){\ |
krishanprajapat | 148:46763854fa83 | 440 | send_tm_from_SD_card_fun();\ |
krishanprajapat | 148:46763854fa83 | 441 | }else{\ |
krishanprajapat | 148:46763854fa83 | 442 | snd_tm.transmit_data(buffer_112,&last_buffer);\ |
krishanprajapat | 148:46763854fa83 | 443 | }\ |
krishanprajapat | 148:46763854fa83 | 444 | write_data;\ |
krishanprajapat | 148:46763854fa83 | 445 | if(sent_tmfrom_SDcard){\ |
ee12b079 | 95:42d6747900cb | 446 | send_tm_from_SD_card_fun();\ |
shreeshas95 | 1:a0055b3280c8 | 447 | }else{\ |
shreeshas95 | 1:a0055b3280c8 | 448 | snd_tm.transmit_data(buffer_112,&last_buffer);\ |
shreeshas95 | 1:a0055b3280c8 | 449 | }\ |
shreeshas95 | 1:a0055b3280c8 | 450 | gCS_ADF=0;\ |
shreeshas95 | 1:a0055b3280c8 | 451 | spi.write(0xB1);\ |
shreeshas95 | 1:a0055b3280c8 | 452 | gCS_ADF=1;\ |
shreeshas95 | 1:a0055b3280c8 | 453 | wait_us(300);\ |
shreeshas95 | 1:a0055b3280c8 | 454 | gCS_ADF=0;\ |
shreeshas95 | 1:a0055b3280c8 | 455 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 456 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 457 | gCS_ADF=1;\ |
shreeshas95 | 1:a0055b3280c8 | 458 | gCS_ADF=0;\ |
shreeshas95 | 1:a0055b3280c8 | 459 | spi.write(0xB5);\ |
shreeshas95 | 1:a0055b3280c8 | 460 | gCS_ADF=1;\ |
shreeshas95 | 1:a0055b3280c8 | 461 | wait_us(300);\ |
shreeshas95 | 1:a0055b3280c8 | 462 | gCS_ADF=0;\ |
shreeshas95 | 1:a0055b3280c8 | 463 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 464 | spi.write(0xFF);\ |
shreeshas95 | 1:a0055b3280c8 | 465 | gCS_ADF=1;\ |
shreeshas95 | 1:a0055b3280c8 | 466 | } |
ee12b079 | 241:410c9cdd4f6e | 467 | |
ee12b079 | 241:410c9cdd4f6e | 468 | #define initial_adf_check {\ |
ee12b079 | 241:410c9cdd4f6e | 469 | bool Configuration_Done=false;\ |
ee12b079 | 241:410c9cdd4f6e | 470 | quit_configuration=false;\ |
ee12b079 | 241:410c9cdd4f6e | 471 | bool reset_flag1 = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 472 | bool flag = false;\ |
ee12b079 | 241:410c9cdd4f6e | 473 | while((hw_reset_err_cnt<HW_THRS)&&(quit_configuration==false)){\ |
ee12b079 | 241:410c9cdd4f6e | 474 | while((bbram_err_cnt<2)&&(quit_configuration==false)){\ |
ee12b079 | 241:410c9cdd4f6e | 475 | /*assrt_phy_off;*/\ |
ee12b079 | 241:410c9cdd4f6e | 476 | /*Assrt_phy_off Begin*/\ |
ee12b079 | 241:410c9cdd4f6e | 477 | {\ |
ee12b079 | 241:410c9cdd4f6e | 478 | int state_err_cnt = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 479 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 480 | if(cmd_err_flag){\ |
ee12b079 | 241:410c9cdd4f6e | 481 | temp_return=1;\ |
ee12b079 | 241:410c9cdd4f6e | 482 | }\ |
ee12b079 | 241:410c9cdd4f6e | 483 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 484 | for(int i = 0 ; i < 40 ;i++){\ |
ee12b079 | 241:410c9cdd4f6e | 485 | CMD(CMD_PHY_OFF);\ |
ee12b079 | 241:410c9cdd4f6e | 486 | check_status;\ |
ee12b079 | 241:410c9cdd4f6e | 487 | if(status == PHY_OFF){\ |
ee12b079 | 241:410c9cdd4f6e | 488 | temp_return = 0;\ |
ee12b079 | 241:410c9cdd4f6e | 489 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 490 | }\ |
ee12b079 | 241:410c9cdd4f6e | 491 | else if(state_err_cnt>THRS){\ |
ee12b079 | 241:410c9cdd4f6e | 492 | temp_return = 1;\ |
ee12b079 | 241:410c9cdd4f6e | 493 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 494 | }\ |
ee12b079 | 241:410c9cdd4f6e | 495 | else {\ |
ee12b079 | 241:410c9cdd4f6e | 496 | wait_ms(1);\ |
ee12b079 | 241:410c9cdd4f6e | 497 | }\ |
ee12b079 | 241:410c9cdd4f6e | 498 | }\ |
ee12b079 | 241:410c9cdd4f6e | 499 | }\ |
ee12b079 | 241:410c9cdd4f6e | 500 | }\ |
ee12b079 | 241:410c9cdd4f6e | 501 | /*Assrt_phy_off end*/\ |
ee12b079 | 241:410c9cdd4f6e | 502 | reset_flag1=temp_return;\ |
ee12b079 | 241:410c9cdd4f6e | 503 | if(!reset_flag1){\ |
ee12b079 | 241:410c9cdd4f6e | 504 | bbram_write;\ |
ee12b079 | 241:410c9cdd4f6e | 505 | while((rbp_err_cnt<RBP_THRS)&&(quit_configuration==false)){\ |
ee12b079 | 241:410c9cdd4f6e | 506 | bbram_check;\ |
ee12b079 | 241:410c9cdd4f6e | 507 | if(bbram_err==0){\ |
ee12b079 | 241:410c9cdd4f6e | 508 | bbram_write_success=true;\ |
ee12b079 | 241:410c9cdd4f6e | 509 | bbram_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 510 | initiate;\ |
ee12b079 | 241:410c9cdd4f6e | 511 | if(reg_err){\ |
ee12b079 | 241:410c9cdd4f6e | 512 | rbp_err_cnt++;\ |
ee12b079 | 241:410c9cdd4f6e | 513 | }\ |
ee12b079 | 241:410c9cdd4f6e | 514 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 515 | rbp_err_cnt=0;\ |
ee12b079 | 241:410c9cdd4f6e | 516 | gPC.printf("NO Reg err\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 517 | CMD(CMD_CONFIG_DEV);\ |
ee12b079 | 241:410c9cdd4f6e | 518 | if(cmd_err_flag){\ |
ee12b079 | 241:410c9cdd4f6e | 519 | reset_flag=1;\ |
ee12b079 | 241:410c9cdd4f6e | 520 | gPC.printf("CMD ERR\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 521 | }\ |
ee12b079 | 241:410c9cdd4f6e | 522 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 523 | reset_flag=0;\ |
ee12b079 | 241:410c9cdd4f6e | 524 | gPC.printf("NO CMD ERR CONFIG_DONE\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 525 | quit_configuration=true;\ |
ee12b079 | 241:410c9cdd4f6e | 526 | }\ |
ee12b079 | 241:410c9cdd4f6e | 527 | }\ |
ee12b079 | 241:410c9cdd4f6e | 528 | }\ |
ee12b079 | 241:410c9cdd4f6e | 529 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 530 | bbram_write_success=false;\ |
ee12b079 | 241:410c9cdd4f6e | 531 | bbram_err_cnt++;\ |
ee12b079 | 241:410c9cdd4f6e | 532 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 533 | }\ |
ee12b079 | 241:410c9cdd4f6e | 534 | }\ |
ee12b079 | 241:410c9cdd4f6e | 535 | }\ |
ee12b079 | 241:410c9cdd4f6e | 536 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 537 | break;\ |
ee12b079 | 241:410c9cdd4f6e | 538 | }\ |
ee12b079 | 241:410c9cdd4f6e | 539 | }\ |
ee12b079 | 241:410c9cdd4f6e | 540 | if(reset_flag1){\ |
ee12b079 | 241:410c9cdd4f6e | 541 | hardware_reset(0);\ |
ee12b079 | 241:410c9cdd4f6e | 542 | hw_reset_err_cnt++;\ |
ee12b079 | 241:410c9cdd4f6e | 543 | gPC.puts("Resetting hardware\r\n");\ |
ee12b079 | 241:410c9cdd4f6e | 544 | }\ |
ee12b079 | 241:410c9cdd4f6e | 545 | }\ |
ee12b079 | 241:410c9cdd4f6e | 546 | if(hw_reset_err_cnt==HW_THRS){\ |
ee12b079 | 241:410c9cdd4f6e | 547 | power_reset_flag=1;\ |
ee12b079 | 241:410c9cdd4f6e | 548 | power_reset_count++;\ |
ee12b079 | 241:410c9cdd4f6e | 549 | }\ |
ee12b079 | 241:410c9cdd4f6e | 550 | else{\ |
ee12b079 | 241:410c9cdd4f6e | 551 | Configuration_Done=true;\ |
ee12b079 | 241:410c9cdd4f6e | 552 | gPC.printf("Configuration_Done\n");\ |
ee12b079 | 241:410c9cdd4f6e | 553 | }\ |
ee12b079 | 241:410c9cdd4f6e | 554 | } |
ee12b079 | 241:410c9cdd4f6e | 555 | |
aniruddhv | 52:0bd68655c651 | 556 | #define configure_adf {\ |
ee12b079 | 241:410c9cdd4f6e | 557 | reset_flags;\ |
aniruddhv | 52:0bd68655c651 | 558 | initial_adf_check;\ |
ee12b079 | 241:410c9cdd4f6e | 559 | gPC.puts("Config_part done\r\n");\ |
ee12b079 | 9:e9eaada136c6 | 560 | } |
ee12b079 | 9:e9eaada136c6 | 561 | |
ee12b079 | 95:42d6747900cb | 562 | #define transmit_adf {\ |
aniruddhv | 52:0bd68655c651 | 563 | configure_adf;\ |
aniruddhv | 52:0bd68655c651 | 564 | send_data;\ |
ee12b079 | 241:410c9cdd4f6e | 565 | CMD(CMD_PHY_TX);\ |
ee12b079 | 241:410c9cdd4f6e | 566 | wait_us(2000);\ |
aniruddhv | 52:0bd68655c651 | 567 | while(loop_on){\ |
ee12b079 | 241:410c9cdd4f6e | 568 | wait_us(20);\ |
ee12b079 | 241:410c9cdd4f6e | 569 | check;\ |
ee12b079 | 241:410c9cdd4f6e | 570 | if(data_irq_err){\ |
ee12b079 | 241:410c9cdd4f6e | 571 | break;\ |
aniruddhv | 52:0bd68655c651 | 572 | }\ |
aniruddhv | 52:0bd68655c651 | 573 | }\ |
aniruddhv | 69:20f09a0c3fd2 | 574 | /*gPC.puts("after while loop\r\n");*/\ |
ee12b079 | 88:b9beee1a7a3e | 575 | } |
ee12b079 | 88:b9beee1a7a3e | 576 |