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.
Dependents: Chromatograph_Mobile Chromatograph_Mobile
Diff: PerifConfig.cpp
- Revision:
- 0:f9ba28ab9f4c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PerifConfig.cpp Mon Jun 08 05:48:24 2020 +0000 @@ -0,0 +1,85 @@ +#include "PerifConfig.h" +#include <stdio.h> + +/*Переопределение имени пинов*/ +DigitalOut Cs(D10); +DigitalOut En1(D15); + +DigitalOut Adr0(D5); +DigitalOut Adr1(D6); +DigitalOut Adr2(D7); + +DigitalOut Reset(D8); +DigitalIn CrdyA(D9); +/*Конец*/ + +//MOSI,MISO,SCK +SPI TED2(D11, D12, D13); + +Serial UART(SERIAL_TX,SERIAL_RX,NULL,115200); + + +void UART_gets(char maxcount) +/*Функция получения строки и записи её в глобальную переменную str[]*/ +{ + int i=0; + do + { + while (UART.readable()); //перед точкой с запятой цикл + str[i++]=UART.getc(); + } + while ((str[i-2]!=0x0D)&&(str[i-1]!=0x0A)); + for (i=i;i<maxcount;i++) + { + str[i]='\0'; + } +} + + + +void DebugString (unsigned char *sData,unsigned char sz) +{ + /* + int i; + for (i=0;i<sz;i++) + { + if (sData[i]==0x00) //если пришёл символ конца строки то не отправляем что-либо + { + i=sz; + } + else UART1_Transmit(sData[i]); + } + */ +} + +void SPI1_MasterInitMode(char mode) +{ + TED2.format(8,mode); + TED2.frequency(1000000); +} +void SPI1_SlaveInit() +{ + +} + + +void SPI1MasterTransmitString(unsigned char *sData,unsigned int sz) //передать строку размером sz +{ + /* + int i=0; + for (i=0;i<sz;i++) + { + SPI1MasterTransferByte(sData[i]); + } + */ +} + +unsigned char SPI1MasterTransferByte(unsigned char cData)//отправить и считать байт +{ + return TED2.write(cData); +} + +unsigned char SPI1MasterReadByte() +{ + return TED2.write(0xFF); +} \ No newline at end of file