keniti akiba
/
serial_test_010_2
stm32l010 serial 9600bps pa2 1
Revision 0:f89fcbc67075, committed 2021-05-06
- Comitter:
- caa45040
- Date:
- Thu May 06 00:57:21 2021 +0000
- Commit message:
- stm32l010 serial 9600bps 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 06 00:57:21 2021 +0000 @@ -0,0 +1,68 @@ +#include "mbed.h" + +//Serial pc(USBTX, USBRX); // tx, rx +//Serial pc(SERIAL_TX, SERIAL_RX); //767 +//Serial pc(PA_2, PA_3); //010 +//Serial pc(PA_9, PA_10); //010 + +//アナログ入力の設定 +//AnalogIn adc_vbat(A3); //PA_4 + +#define UART_DELAY 96 // 1/9600 + +//仮想シリアルの出力ポート +//DigitalOut TX(PA_9); +DigitalOut TX(PA_2); + +//仮想シリアルへの一文字出力 9600bps +int pc_putc(char ch) { + + TX=1; + TX=0;//START + wait_us(UART_DELAY); + + for(int ii=0;ii<8;ii++){ + TX=(ch>>ii)&1; + wait_us(UART_DELAY); + }; //for + + TX=1;//Stop + wait_us(UART_DELAY); + + return(0); + +} //pc_putc + + +int main() { + + //ポートをhiにする 初期化 + TX=1; + + //adcの読み込み 0から4096 + //int s = (adc_vbat.read_u16()>>4); + + char *ss1; //文字のポインター + int ii; //ループカウンター + + //無限ループ + while(1) { + + ss1="Hello World !\r\n"; + ii=0; //ループカウンター + while(ss1[ii]!=0){ + + //一文字出力 + pc_putc(ss1[ii]);ii++; + + } //while + + //1秒の待ち + wait_ms(1000); + + } //while + +} //main + +//容量削減 +void error(const char* format, ...){}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 06 00:57:21 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/2e9cc70d1897 \ No newline at end of file