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: ad5422_arduino mbed LT1446 LM35 PGA280_ADS1259
PerifConfig.cpp
00001 #include "PerifConfig.h" 00002 #include <stdio.h> 00003 00004 /*Переопределение имени пинов для платы ТЭД2*/ 00005 DigitalOut Cs(D10); 00006 DigitalOut En1(D15); 00007 00008 DigitalOut Adr0(D5); 00009 DigitalOut Adr1(D6); 00010 DigitalOut Adr2(D7); 00011 00012 DigitalOut Reset(D8); 00013 DigitalIn CrdyA(D9); 00014 00015 /*DigitalOut MOSI(D11); 00016 DigitalIn MISO(D12); 00017 DigitalOut SCK(D13);*/ 00018 /*Конец*/ 00019 00020 //MOSI,MISO,SCK 00021 SPI TED2(D11, D12, D13); 00022 00023 Serial UART(SERIAL_TX,SERIAL_RX,115200); 00024 00025 00026 void UART_gets(char maxcount) 00027 /*Функция получения строки и записи её в глобальную переменную str[]*/ 00028 { 00029 int i=0; 00030 do 00031 { 00032 while (UART.readable()); //перед точкой с запятой цикл 00033 str[i++]=UART.getc(); 00034 } 00035 while ((str[i-2]!=0x0D)&&(str[i-1]!=0x0A)); 00036 for (i=i;i<maxcount;i++) 00037 { 00038 str[i]='\0'; 00039 } 00040 } 00041 00042 00043 00044 void DebugString (unsigned char *sData,unsigned char sz) 00045 { 00046 /* 00047 int i; 00048 for (i=0;i<sz;i++) 00049 { 00050 if (sData[i]==0x00) //если пришёл символ конца строки то не отправляем что-либо 00051 { 00052 i=sz; 00053 } 00054 else UART1_Transmit(sData[i]); 00055 } 00056 */ 00057 } 00058 00059 void SPI1_MasterInitMode(char mode) 00060 { 00061 TED2.format(8,mode); 00062 TED2.frequency(2500000); 00063 } 00064 void SPI1_SlaveInit() 00065 { 00066 00067 } 00068 00069 00070 void SPI1MasterTransmitString(unsigned char *sData,unsigned int sz) //передать строку размером sz 00071 { 00072 /* 00073 int i=0; 00074 for (i=0;i<sz;i++) 00075 { 00076 SPI1MasterTransferByte(sData[i]); 00077 } 00078 */ 00079 } 00080 00081 unsigned char SPI1MasterTransferByte(unsigned char cData)//отправить и считать байт 00082 { 00083 return (unsigned char)TED2.write(cData); 00084 } 00085 00086 unsigned char SPI1MasterReadByte() 00087 { 00088 return (unsigned char)TED2.write(0xFF); 00089 }
Generated on Sat Jul 30 2022 07:47:02 by
1.7.2