CEBF746 Module.. PC <--> This Module (SPI Master) <-->
Dependencies: cube_CEBF746 cube_crc_16 mbed
main.cpp@7:efe7a78d7724, 2016-10-20 (annotated)
- Committer:
- gandol2
- Date:
- Thu Oct 20 13:13:19 2016 +0000
- Revision:
- 7:efe7a78d7724
- Parent:
- 6:a98f9d63f8a2
161020_commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gandol2 | 0:9a61123385e9 | 1 | // firmware for NUCLEO-F746ZG |
gandol2 | 0:9a61123385e9 | 2 | // ======== SPI Master Pin |
gandol2 | 0:9a61123385e9 | 3 | // PA5 - SCK |
gandol2 | 0:9a61123385e9 | 4 | // PA6 - MISO |
gandol2 | 0:9a61123385e9 | 5 | // PA7 - MOSI |
gandol2 | 0:9a61123385e9 | 6 | // PA14 - SEL |
gandol2 | 0:9a61123385e9 | 7 | |
gandol2 | 0:9a61123385e9 | 8 | #include "mbed.h" |
gandol2 | 6:a98f9d63f8a2 | 9 | #include "lib_CEBF746.h" |
gandol2 | 6:a98f9d63f8a2 | 10 | #include "lib_crc.h" |
gandol2 | 0:9a61123385e9 | 11 | |
gandol2 | 0:9a61123385e9 | 12 | #define DEBUG_SPI |
gandol2 | 0:9a61123385e9 | 13 | #ifdef DEBUG_SPI |
gandol2 | 0:9a61123385e9 | 14 | #define PRINTD(arg1,arg2...) printf(arg1,##arg2) |
gandol2 | 0:9a61123385e9 | 15 | #endif |
gandol2 | 0:9a61123385e9 | 16 | |
gandol2 | 5:589ab465ed00 | 17 | // ======== SPI Func define |
gandol2 | 0:9a61123385e9 | 18 | #define EEPROM_WREN 0x06 // Write Enable |
gandol2 | 0:9a61123385e9 | 19 | #define EEPROM_WRDI 0x04 // Write Disable |
gandol2 | 0:9a61123385e9 | 20 | #define EEPROM_RDSR 0x05 // Read Status Register |
gandol2 | 0:9a61123385e9 | 21 | #define EEPROM_WRSR 0x01 // Write Status Register |
gandol2 | 0:9a61123385e9 | 22 | #define EEPROM_READ 0x03 // Read EEPROM Memory |
gandol2 | 0:9a61123385e9 | 23 | #define EEPROM_WRITE 0x02 // Write EEPROM Memory |
gandol2 | 0:9a61123385e9 | 24 | #define EEPROM_MULTIREAD 0x07 // Write EEPROM Memory |
gandol2 | 0:9a61123385e9 | 25 | |
gandol2 | 5:589ab465ed00 | 26 | #define SPI_CONFIG_BIT 8 |
gandol2 | 5:589ab465ed00 | 27 | #define SPI_CONFIG_FREQUENCY 1000000 // 1Mhz |
gandol2 | 5:589ab465ed00 | 28 | //#define SPI_CONFIG_FREQUENCY 50000000 // 50Mhz |
gandol2 | 0:9a61123385e9 | 29 | |
gandol2 | 6:a98f9d63f8a2 | 30 | |
gandol2 | 5:589ab465ed00 | 31 | |
gandol2 | 6:a98f9d63f8a2 | 32 | Serial pc_serial(USBTX, USBRX); |
gandol2 | 0:9a61123385e9 | 33 | |
gandol2 | 6:a98f9d63f8a2 | 34 | typedef enum |
gandol2 | 5:589ab465ed00 | 35 | { |
gandol2 | 6:a98f9d63f8a2 | 36 | MENU_READ_STATUS_REG = 1, |
gandol2 | 6:a98f9d63f8a2 | 37 | MENU_SPI_SELF_TEST_WRITE = 2, |
gandol2 | 6:a98f9d63f8a2 | 38 | MENU_SPI_SELF_TEST_READ = 3, |
gandol2 | 6:a98f9d63f8a2 | 39 | MENU_SPI_WRITE_ENC_DATA = 4, |
gandol2 | 6:a98f9d63f8a2 | 40 | MENU_SPI_READ_ENC_DATA = 5, |
gandol2 | 6:a98f9d63f8a2 | 41 | |
gandol2 | 5:589ab465ed00 | 42 | MENU_EXIT_Program = 9 |
gandol2 | 6:a98f9d63f8a2 | 43 | }cebf746_command; |
gandol2 | 5:589ab465ed00 | 44 | |
gandol2 | 5:589ab465ed00 | 45 | /** @brief print menu |
gandol2 | 5:589ab465ed00 | 46 | * |
gandol2 | 5:589ab465ed00 | 47 | */ |
gandol2 | 0:9a61123385e9 | 48 | void print_menu(void) |
gandol2 | 0:9a61123385e9 | 49 | { |
gandol2 | 5:589ab465ed00 | 50 | pc_serial.printf("\n\n\n"); |
gandol2 | 6:a98f9d63f8a2 | 51 | pc_serial.printf("-----------[CEBF746 Test MENU]----------\n"); |
gandol2 | 6:a98f9d63f8a2 | 52 | // CEBF746 func ### |
gandol2 | 6:a98f9d63f8a2 | 53 | |
gandol2 | 6:a98f9d63f8a2 | 54 | |
gandol2 | 6:a98f9d63f8a2 | 55 | pc_serial.printf("%d) Read Status Reg\n", MENU_READ_STATUS_REG); |
gandol2 | 6:a98f9d63f8a2 | 56 | pc_serial.printf("%d) Self Test(Write)\n", MENU_SPI_SELF_TEST_WRITE); |
gandol2 | 6:a98f9d63f8a2 | 57 | pc_serial.printf("%d) Self Test(Read)\n", MENU_SPI_SELF_TEST_READ); |
gandol2 | 6:a98f9d63f8a2 | 58 | pc_serial.printf("%d) Encrypt Data Write(16Byte)\n", MENU_SPI_WRITE_ENC_DATA); |
gandol2 | 6:a98f9d63f8a2 | 59 | pc_serial.printf("%d) Encrypted Data Read(16Byte)\n", MENU_SPI_READ_ENC_DATA); |
gandol2 | 5:589ab465ed00 | 60 | // cubebite test func ### |
gandol2 | 6:a98f9d63f8a2 | 61 | |
gandol2 | 5:589ab465ed00 | 62 | |
gandol2 | 5:589ab465ed00 | 63 | // exit func ### |
gandol2 | 5:589ab465ed00 | 64 | pc_serial.printf("%d) Exit program\n", MENU_EXIT_Program); |
gandol2 | 6:a98f9d63f8a2 | 65 | pc_serial.printf("----------------------------------------\n"); |
gandol2 | 5:589ab465ed00 | 66 | pc_serial.printf("input menu : "); |
gandol2 | 0:9a61123385e9 | 67 | } |
gandol2 | 0:9a61123385e9 | 68 | |
gandol2 | 5:589ab465ed00 | 69 | |
gandol2 | 5:589ab465ed00 | 70 | /** @brief convert ASCII to hex |
gandol2 | 5:589ab465ed00 | 71 | * |
gandol2 | 5:589ab465ed00 | 72 | * @param convertedData converted Data |
gandol2 | 5:589ab465ed00 | 73 | * @param sourceBuf ASCII data array |
gandol2 | 5:589ab465ed00 | 74 | * @param lenght sourceBuf length |
gandol2 | 5:589ab465ed00 | 75 | * @return 0 is valid hex format, other is error |
gandol2 | 5:589ab465ed00 | 76 | */ |
gandol2 | 0:9a61123385e9 | 77 | int converHex(char * convertedData, char * sourceBuf, int length) |
gandol2 | 0:9a61123385e9 | 78 | { |
gandol2 | 0:9a61123385e9 | 79 | int ret = 0; |
gandol2 | 0:9a61123385e9 | 80 | char tempBuf[length]; |
gandol2 | 0:9a61123385e9 | 81 | *convertedData = 0; |
gandol2 | 5:589ab465ed00 | 82 | |
gandol2 | 5:589ab465ed00 | 83 | for (int iCnt = 0; iCnt < length; iCnt++) |
gandol2 | 0:9a61123385e9 | 84 | { |
gandol2 | 5:589ab465ed00 | 85 | if (('0' <= *(sourceBuf + iCnt)) && ('9' >= *(sourceBuf + iCnt))) |
gandol2 | 0:9a61123385e9 | 86 | { |
gandol2 | 5:589ab465ed00 | 87 | tempBuf[iCnt] = (*(sourceBuf + iCnt) - 48); |
gandol2 | 0:9a61123385e9 | 88 | } |
gandol2 | 5:589ab465ed00 | 89 | else if (('A' <= *(sourceBuf + iCnt)) && ('F' >= *(sourceBuf + iCnt))) |
gandol2 | 0:9a61123385e9 | 90 | { |
gandol2 | 5:589ab465ed00 | 91 | tempBuf[iCnt] = (*(sourceBuf + iCnt) - 55); |
gandol2 | 0:9a61123385e9 | 92 | } |
gandol2 | 5:589ab465ed00 | 93 | else if (('a' <= *(sourceBuf + iCnt)) && ('f' >= *(sourceBuf + iCnt))) |
gandol2 | 5:589ab465ed00 | 94 | { |
gandol2 | 5:589ab465ed00 | 95 | tempBuf[iCnt] = (*(sourceBuf + iCnt) - 87); |
gandol2 | 0:9a61123385e9 | 96 | } |
gandol2 | 0:9a61123385e9 | 97 | else // error |
gandol2 | 0:9a61123385e9 | 98 | { |
gandol2 | 0:9a61123385e9 | 99 | ret = -1; |
gandol2 | 5:589ab465ed00 | 100 | return ret; |
gandol2 | 5:589ab465ed00 | 101 | } |
gandol2 | 0:9a61123385e9 | 102 | } |
gandol2 | 5:589ab465ed00 | 103 | |
gandol2 | 0:9a61123385e9 | 104 | //pc_serial.printf("[TEST] tempBuf[0] = 0x%02X\n", tempBuf[0]); |
gandol2 | 0:9a61123385e9 | 105 | //pc_serial.printf("[TEST] tempBuf[1] = 0x%02X\n", tempBuf[1]); |
gandol2 | 0:9a61123385e9 | 106 | *convertedData = ((tempBuf[0] & 0x0F) << 4) | (tempBuf[1] & 0x0F); |
gandol2 | 0:9a61123385e9 | 107 | //pc_serial.printf("[TEST] convertedData = 0x%02X\n", *convertedData); |
gandol2 | 0:9a61123385e9 | 108 | return ret; |
gandol2 | 0:9a61123385e9 | 109 | } |
gandol2 | 0:9a61123385e9 | 110 | |
gandol2 | 6:a98f9d63f8a2 | 111 | |
gandol2 | 6:a98f9d63f8a2 | 112 | |
gandol2 | 6:a98f9d63f8a2 | 113 | |
gandol2 | 6:a98f9d63f8a2 | 114 | |
gandol2 | 6:a98f9d63f8a2 | 115 | |
gandol2 | 6:a98f9d63f8a2 | 116 | |
gandol2 | 5:589ab465ed00 | 117 | /** @brief main function ################################################################### |
gandol2 | 5:589ab465ed00 | 118 | * |
gandol2 | 5:589ab465ed00 | 119 | */ |
gandol2 | 0:9a61123385e9 | 120 | int main() |
gandol2 | 0:9a61123385e9 | 121 | { |
gandol2 | 6:a98f9d63f8a2 | 122 | uint16_t tempCrc; |
gandol2 | 6:a98f9d63f8a2 | 123 | char ret = 0; |
gandol2 | 6:a98f9d63f8a2 | 124 | char retCode; |
gandol2 | 5:589ab465ed00 | 125 | char inputMenuNum = 0; |
gandol2 | 6:a98f9d63f8a2 | 126 | spiDataStr sendData; |
gandol2 | 6:a98f9d63f8a2 | 127 | spiDataStr reciveData; |
gandol2 | 6:a98f9d63f8a2 | 128 | |
gandol2 | 7:efe7a78d7724 | 129 | uint8_t encTempBuf[CEB_BUF_SIZE] = {0, }; |
gandol2 | 7:efe7a78d7724 | 130 | |
gandol2 | 6:a98f9d63f8a2 | 131 | uint8_t spiMOSIBuf[255]; |
gandol2 | 6:a98f9d63f8a2 | 132 | uint8_t spiMISOBuf[255]; |
gandol2 | 6:a98f9d63f8a2 | 133 | |
gandol2 | 5:589ab465ed00 | 134 | |
gandol2 | 6:a98f9d63f8a2 | 135 | |
gandol2 | 6:a98f9d63f8a2 | 136 | cebf746_use_init(); |
gandol2 | 5:589ab465ed00 | 137 | |
gandol2 | 6:a98f9d63f8a2 | 138 | pc_serial.printf("\n\n========== SPI Master for CEBF746 [Start] ==========\n"); |
gandol2 | 5:589ab465ed00 | 139 | |
gandol2 | 5:589ab465ed00 | 140 | while (1) |
gandol2 | 5:589ab465ed00 | 141 | { |
gandol2 | 5:589ab465ed00 | 142 | print_menu(); |
gandol2 | 5:589ab465ed00 | 143 | inputMenuNum = pc_serial.getc(); |
gandol2 | 5:589ab465ed00 | 144 | |
gandol2 | 5:589ab465ed00 | 145 | pc_serial.printf("[DEBUG] input menu number = %c\n", inputMenuNum); |
gandol2 | 5:589ab465ed00 | 146 | |
gandol2 | 5:589ab465ed00 | 147 | if (('0' < inputMenuNum) && ('9' >= inputMenuNum)) |
gandol2 | 5:589ab465ed00 | 148 | { |
gandol2 | 0:9a61123385e9 | 149 | inputMenuNum = inputMenuNum - 48; |
gandol2 | 5:589ab465ed00 | 150 | } |
gandol2 | 5:589ab465ed00 | 151 | else |
gandol2 | 5:589ab465ed00 | 152 | { |
gandol2 | 5:589ab465ed00 | 153 | pc_serial.printf("[INFO] correct input menu number.. please retry..\n"); |
gandol2 | 5:589ab465ed00 | 154 | wait(1); |
gandol2 | 5:589ab465ed00 | 155 | continue; |
gandol2 | 5:589ab465ed00 | 156 | } |
gandol2 | 5:589ab465ed00 | 157 | |
gandol2 | 6:a98f9d63f8a2 | 158 | |
gandol2 | 6:a98f9d63f8a2 | 159 | |
gandol2 | 6:a98f9d63f8a2 | 160 | |
gandol2 | 6:a98f9d63f8a2 | 161 | |
gandol2 | 6:a98f9d63f8a2 | 162 | memset(spiMISOBuf, 0, 255); |
gandol2 | 6:a98f9d63f8a2 | 163 | memset(spiMOSIBuf, 0, 255); |
gandol2 | 6:a98f9d63f8a2 | 164 | retCode = 0xFF; |
gandol2 | 5:589ab465ed00 | 165 | switch (inputMenuNum) |
gandol2 | 5:589ab465ed00 | 166 | { |
gandol2 | 6:a98f9d63f8a2 | 167 | |
gandol2 | 6:a98f9d63f8a2 | 168 | case MENU_READ_STATUS_REG: // Write Enable =================================[OK] |
gandol2 | 6:a98f9d63f8a2 | 169 | pc_serial.printf("[DEBUG] Read Status Reg..\n"); |
gandol2 | 6:a98f9d63f8a2 | 170 | ret = 0; |
gandol2 | 6:a98f9d63f8a2 | 171 | ret = cebf746_packet_read(FUNC_READ_STATUS, 0); |
gandol2 | 6:a98f9d63f8a2 | 172 | printf("[INFO] status reg [%02X]\n", ret); |
gandol2 | 5:589ab465ed00 | 173 | break; |
gandol2 | 6:a98f9d63f8a2 | 174 | |
gandol2 | 6:a98f9d63f8a2 | 175 | |
gandol2 | 6:a98f9d63f8a2 | 176 | case MENU_SPI_SELF_TEST_WRITE: // 161017_KSS_Test OK |
gandol2 | 6:a98f9d63f8a2 | 177 | char spiSelfTestBuf[CEB_BUF_SIZE] = WRITE_SELF_TEST_DATA; |
gandol2 | 6:a98f9d63f8a2 | 178 | |
gandol2 | 6:a98f9d63f8a2 | 179 | sendData.size = sizeof(spiSelfTestBuf); |
gandol2 | 6:a98f9d63f8a2 | 180 | sendData.buf = (uint8_t*)spiSelfTestBuf; |
gandol2 | 6:a98f9d63f8a2 | 181 | sendData.crc16 = 0; |
gandol2 | 5:589ab465ed00 | 182 | |
gandol2 | 6:a98f9d63f8a2 | 183 | ret = cebf746_packet_write(FUNC_WRITE_SELF_TEST, &sendData); |
gandol2 | 6:a98f9d63f8a2 | 184 | /* |
gandol2 | 6:a98f9d63f8a2 | 185 | cebf746_print_packet(&sendData); |
gandol2 | 6:a98f9d63f8a2 | 186 | |
gandol2 | 6:a98f9d63f8a2 | 187 | pc_serial.printf("FUNC_WRITE_SELF_TEST.."); |
gandol2 | 6:a98f9d63f8a2 | 188 | if(0 == ret) |
gandol2 | 6:a98f9d63f8a2 | 189 | { |
gandol2 | 6:a98f9d63f8a2 | 190 | pc_serial.printf("[SUCESS] ret = %02X\n", ret); |
gandol2 | 6:a98f9d63f8a2 | 191 | } |
gandol2 | 6:a98f9d63f8a2 | 192 | else |
gandol2 | 6:a98f9d63f8a2 | 193 | { |
gandol2 | 6:a98f9d63f8a2 | 194 | pc_serial.printf("[FAIL] ******** ret = %02X ******** \n", ret); |
gandol2 | 6:a98f9d63f8a2 | 195 | } |
gandol2 | 6:a98f9d63f8a2 | 196 | */ |
gandol2 | 5:589ab465ed00 | 197 | break; |
gandol2 | 6:a98f9d63f8a2 | 198 | |
gandol2 | 6:a98f9d63f8a2 | 199 | case MENU_SPI_SELF_TEST_READ: // 161017_KSS_Test OK |
gandol2 | 6:a98f9d63f8a2 | 200 | char selfTempRxBuf[CEB_BUF_SIZE]={0,}; |
gandol2 | 6:a98f9d63f8a2 | 201 | |
gandol2 | 6:a98f9d63f8a2 | 202 | reciveData.size = CEB_BUF_SIZE; |
gandol2 | 6:a98f9d63f8a2 | 203 | reciveData.buf = (uint8_t*)selfTempRxBuf; |
gandol2 | 7:efe7a78d7724 | 204 | reciveData.crc16 = 0; |
gandol2 | 6:a98f9d63f8a2 | 205 | |
gandol2 | 6:a98f9d63f8a2 | 206 | ret = cebf746_packet_read(FUNC_READ_SELF_TEST, &reciveData); |
gandol2 | 6:a98f9d63f8a2 | 207 | |
gandol2 | 6:a98f9d63f8a2 | 208 | break; |
gandol2 | 6:a98f9d63f8a2 | 209 | |
gandol2 | 6:a98f9d63f8a2 | 210 | |
gandol2 | 7:efe7a78d7724 | 211 | case MENU_SPI_WRITE_ENC_DATA: // Master >>>>>(encrypt data)>>>>> Slave |
gandol2 | 7:efe7a78d7724 | 212 | |
gandol2 | 6:a98f9d63f8a2 | 213 | |
gandol2 | 6:a98f9d63f8a2 | 214 | pc_serial.printf("input Encrypt String (16 character) : "); |
gandol2 | 6:a98f9d63f8a2 | 215 | for(int iCnt = 0 ; iCnt < 16 ; ++iCnt) |
gandol2 | 6:a98f9d63f8a2 | 216 | { |
gandol2 | 6:a98f9d63f8a2 | 217 | encTempBuf[iCnt] = pc_serial.getc(); |
gandol2 | 6:a98f9d63f8a2 | 218 | pc_serial.printf("%c", encTempBuf[iCnt]); |
gandol2 | 6:a98f9d63f8a2 | 219 | } |
gandol2 | 6:a98f9d63f8a2 | 220 | |
gandol2 | 6:a98f9d63f8a2 | 221 | sendData.size = sizeof(encTempBuf); |
gandol2 | 6:a98f9d63f8a2 | 222 | sendData.buf = (uint8_t*)encTempBuf; |
gandol2 | 6:a98f9d63f8a2 | 223 | sendData.crc16 = 0; |
gandol2 | 6:a98f9d63f8a2 | 224 | |
gandol2 | 6:a98f9d63f8a2 | 225 | ret = cebf746_packet_write(FUNC_WRITE_ENC_DATA, &sendData); |
gandol2 | 6:a98f9d63f8a2 | 226 | |
gandol2 | 6:a98f9d63f8a2 | 227 | break; |
gandol2 | 6:a98f9d63f8a2 | 228 | |
gandol2 | 6:a98f9d63f8a2 | 229 | |
gandol2 | 7:efe7a78d7724 | 230 | case MENU_SPI_READ_ENC_DATA: // Master <<<<<(encrypted data)<<<<< Slave |
gandol2 | 6:a98f9d63f8a2 | 231 | int encryptWaitCnt = 10; |
gandol2 | 7:efe7a78d7724 | 232 | |
gandol2 | 7:efe7a78d7724 | 233 | // ★★★★ status reg 읽어오는 부분이 문제가 있는듯함 여기를 먼저 고쳐야함 |
gandol2 | 6:a98f9d63f8a2 | 234 | while(1) |
gandol2 | 5:589ab465ed00 | 235 | { |
gandol2 | 6:a98f9d63f8a2 | 236 | ret = cebf746_packet_read(FUNC_READ_STATUS, 0); |
gandol2 | 7:efe7a78d7724 | 237 | if(ret == 0x02) // Encrypting.. |
gandol2 | 5:589ab465ed00 | 238 | { |
gandol2 | 7:efe7a78d7724 | 239 | --encryptWaitCnt; |
gandol2 | 7:efe7a78d7724 | 240 | if(0 >= encryptWaitCnt) |
gandol2 | 7:efe7a78d7724 | 241 | break; |
gandol2 | 5:589ab465ed00 | 242 | } |
gandol2 | 6:a98f9d63f8a2 | 243 | else |
gandol2 | 5:589ab465ed00 | 244 | { |
gandol2 | 5:589ab465ed00 | 245 | break; |
gandol2 | 5:589ab465ed00 | 246 | } |
gandol2 | 5:589ab465ed00 | 247 | } |
gandol2 | 6:a98f9d63f8a2 | 248 | |
gandol2 | 7:efe7a78d7724 | 249 | |
gandol2 | 6:a98f9d63f8a2 | 250 | if(0 == encryptWaitCnt) |
gandol2 | 7:efe7a78d7724 | 251 | { |
gandol2 | 7:efe7a78d7724 | 252 | printf("[INFO] The CEBF746 is running, STATUS[%02X]\n", ret); |
gandol2 | 6:a98f9d63f8a2 | 253 | continue; |
gandol2 | 6:a98f9d63f8a2 | 254 | } |
gandol2 | 6:a98f9d63f8a2 | 255 | else |
gandol2 | 5:589ab465ed00 | 256 | { |
gandol2 | 6:a98f9d63f8a2 | 257 | /* 161019_암호화된 데이터 읽어와야함. 슬레이브도 구현 해야함 */ |
gandol2 | 7:efe7a78d7724 | 258 | reciveData.size = sizeof(encTempBuf)+2; |
gandol2 | 7:efe7a78d7724 | 259 | reciveData.buf = (uint8_t*)encTempBuf; |
gandol2 | 7:efe7a78d7724 | 260 | reciveData.crc16 = 0; |
gandol2 | 7:efe7a78d7724 | 261 | |
gandol2 | 7:efe7a78d7724 | 262 | ret = cebf746_packet_read(FUNC_READ_ENC_DATA, &reciveData); |
gandol2 | 7:efe7a78d7724 | 263 | |
gandol2 | 7:efe7a78d7724 | 264 | printf("[DEBUF]MENU_SPI_READ_ENC_DATA return [%02X]\n", ret); |
gandol2 | 5:589ab465ed00 | 265 | } |
gandol2 | 6:a98f9d63f8a2 | 266 | |
gandol2 | 6:a98f9d63f8a2 | 267 | |
gandol2 | 6:a98f9d63f8a2 | 268 | |
gandol2 | 6:a98f9d63f8a2 | 269 | /* |
gandol2 | 6:a98f9d63f8a2 | 270 | uint8_t encTempBuf[CEB_BUF_SIZE] = {0, }; |
gandol2 | 6:a98f9d63f8a2 | 271 | |
gandol2 | 6:a98f9d63f8a2 | 272 | pc_serial.printf("input Encrypt String (16 character) : "); |
gandol2 | 6:a98f9d63f8a2 | 273 | for(int iCnt = 0 ; iCnt < 16 ; ++iCnt) |
gandol2 | 6:a98f9d63f8a2 | 274 | { |
gandol2 | 6:a98f9d63f8a2 | 275 | encTempBuf[iCnt] = pc_serial.getc(); |
gandol2 | 6:a98f9d63f8a2 | 276 | pc_serial.printf("%c", encTempBuf[iCnt]); |
gandol2 | 6:a98f9d63f8a2 | 277 | } |
gandol2 | 6:a98f9d63f8a2 | 278 | |
gandol2 | 6:a98f9d63f8a2 | 279 | sendData.size = sizeof(encTempBuf); |
gandol2 | 6:a98f9d63f8a2 | 280 | sendData.buf = (uint8_t*)encTempBuf; |
gandol2 | 6:a98f9d63f8a2 | 281 | sendData.crc16 = 0; |
gandol2 | 6:a98f9d63f8a2 | 282 | |
gandol2 | 6:a98f9d63f8a2 | 283 | ret = cebf746_packet_write(FUNC_WRITE_ENC_DATA, &sendData); |
gandol2 | 6:a98f9d63f8a2 | 284 | */ |
gandol2 | 5:589ab465ed00 | 285 | break; |
gandol2 | 5:589ab465ed00 | 286 | |
gandol2 | 5:589ab465ed00 | 287 | |
gandol2 | 5:589ab465ed00 | 288 | case MENU_EXIT_Program: |
gandol2 | 6:a98f9d63f8a2 | 289 | |
gandol2 | 5:589ab465ed00 | 290 | pc_serial.printf("exit program... thank you\n"); |
gandol2 | 5:589ab465ed00 | 291 | //return 0; |
gandol2 | 5:589ab465ed00 | 292 | |
gandol2 | 0:9a61123385e9 | 293 | } |
gandol2 | 6:a98f9d63f8a2 | 294 | |
gandol2 | 5:589ab465ed00 | 295 | |
gandol2 | 0:9a61123385e9 | 296 | } |
gandol2 | 5:589ab465ed00 | 297 | |
gandol2 | 0:9a61123385e9 | 298 | return 0; |
gandol2 | 0:9a61123385e9 | 299 | } |