Fork

Dependencies:   mbed libscpi

Committer:
bavovanachte
Date:
Thu Jun 10 13:29:48 2021 +0000
Revision:
31:0475756cede6
Parent:
30:b463e1f3cae3
Implemented; - Word write; - SPEED aliases

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wuliqunyy 16:a0bfe33f8a4a 1 #include "uart_mbed.h"
wuliqunyy 16:a0bfe33f8a4a 2 #include "mbed.h"
bavovanachte 26:beaf802e2456 3 #include "scpi/scpi.h"
bavovanachte 26:beaf802e2456 4
wuliqunyy 16:a0bfe33f8a4a 5
wuliqunyy 16:a0bfe33f8a4a 6 Serial pc(USBTX, USBRX); // tx, rx
wuliqunyy 16:a0bfe33f8a4a 7
wuliqunyy 16:a0bfe33f8a4a 8 void uart_print(char *buffer){
wuliqunyy 16:a0bfe33f8a4a 9 pc.printf("RAM_ADDR:%02X MByte:%02X LByte:%02X'\n", *buffer, *(buffer+1),*(buffer+2));
wuliqunyy 16:a0bfe33f8a4a 10 }
wuliqunyy 16:a0bfe33f8a4a 11
wuliqunyy 16:a0bfe33f8a4a 12 void uart_read(char *buffer){
wuliqunyy 16:a0bfe33f8a4a 13 pc.gets(buffer, 20);
wuliqunyy 16:a0bfe33f8a4a 14 }
bavovanachte 25:8367b3fe2891 15
bavovanachte 25:8367b3fe2891 16 void uart_write(char *buffer){
bavovanachte 25:8367b3fe2891 17 pc.printf(buffer);
bavovanachte 25:8367b3fe2891 18 }
wuliqunyy 16:a0bfe33f8a4a 19
wuliqunyy 16:a0bfe33f8a4a 20 void uart_start(){
wuliqunyy 16:a0bfe33f8a4a 21 pc.printf("data_start\n");
wuliqunyy 16:a0bfe33f8a4a 22 }
wuliqunyy 16:a0bfe33f8a4a 23
wuliqunyy 16:a0bfe33f8a4a 24 void uart_I2C_test_pass(){
wuliqunyy 16:a0bfe33f8a4a 25 pc.printf("i2c_test_pass, ready!\n");
wuliqunyy 16:a0bfe33f8a4a 26 }
wuliqunyy 16:a0bfe33f8a4a 27
wuliqunyy 16:a0bfe33f8a4a 28 void uart_I2C_test_fail(){
wuliqunyy 16:a0bfe33f8a4a 29 pc.printf("i2c_test_fail\n");
wuliqunyy 16:a0bfe33f8a4a 30 }
wuliqunyy 16:a0bfe33f8a4a 31
wuliqunyy 16:a0bfe33f8a4a 32 void uart_ram_dump_finish(){
wuliqunyy 16:a0bfe33f8a4a 33 pc.printf("dump_finish\n");
wuliqunyy 16:a0bfe33f8a4a 34 }
bavovanachte 26:beaf802e2456 35
bavovanachte 26:beaf802e2456 36 int SCPI_Error(scpi_t * context, int_fast16_t err) {
bavovanachte 26:beaf802e2456 37 (void) context;
bavovanachte 26:beaf802e2456 38
bavovanachte 26:beaf802e2456 39 printf("**ERROR: %d, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err));
bavovanachte 26:beaf802e2456 40 return 0;
bavovanachte 26:beaf802e2456 41 }
bavovanachte 26:beaf802e2456 42
bavovanachte 26:beaf802e2456 43 size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
bavovanachte 26:beaf802e2456 44 (void) context;
bavovanachte 26:beaf802e2456 45 return fwrite(data, 1, len, stdout);
bavovanachte 26:beaf802e2456 46 }
bavovanachte 26:beaf802e2456 47
bavovanachte 26:beaf802e2456 48 scpi_result_t SCPI_Flush(scpi_t * context) {
bavovanachte 26:beaf802e2456 49 fflush(stdout);
bavovanachte 26:beaf802e2456 50 return SCPI_RES_OK;
bavovanachte 26:beaf802e2456 51 }
bavovanachte 26:beaf802e2456 52
bavovanachte 26:beaf802e2456 53 /**
bavovanachte 26:beaf802e2456 54 * Return 0 as OK and other number as error
bavovanachte 26:beaf802e2456 55 */
bavovanachte 26:beaf802e2456 56 scpi_result_t SCPI_Test(scpi_t * context) {
bavovanachte 26:beaf802e2456 57 printf("**Test\r\n");
bavovanachte 26:beaf802e2456 58 return (scpi_result_t)0;
bavovanachte 26:beaf802e2456 59 }
bavovanachte 26:beaf802e2456 60
bavovanachte 26:beaf802e2456 61 scpi_result_t SCPI_Reset(scpi_t * context)
bavovanachte 26:beaf802e2456 62 {
bavovanachte 26:beaf802e2456 63 printf("**Reset\r\n");
bavovanachte 26:beaf802e2456 64 return SCPI_RES_OK;
bavovanachte 26:beaf802e2456 65 }
bavovanachte 26:beaf802e2456 66
bavovanachte 26:beaf802e2456 67 scpi_result_t SCPI_Control(scpi_t * context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) {
bavovanachte 26:beaf802e2456 68 if (SCPI_CTRL_SRQ == ctrl) {
bavovanachte 26:beaf802e2456 69 printf("**SRQ: 0x%X (%d)\r\n", val, val);
bavovanachte 26:beaf802e2456 70 } else {
bavovanachte 26:beaf802e2456 71 printf("**CTRL %02x: 0x%X (%d)\r\n", ctrl, val, val);
bavovanachte 26:beaf802e2456 72 }
bavovanachte 26:beaf802e2456 73 return SCPI_RES_OK;
bavovanachte 26:beaf802e2456 74 }
bavovanachte 26:beaf802e2456 75
bavovanachte 26:beaf802e2456 76