umouse

umouse.git
git clone git://git.lenczewski.org/umouse.git
Log | Files | Refs | Submodules | README

MinSerSTM32p.fth (1464B)


      1 \ MinSerSTM32p.fth - STM32 polled RX, polled TX, serial communication drivers
      2 
      3 ((
      4 Copyright (c) 2010, 2014
      5 MicroProcessor Engineering
      6 133 Hill Lane
      7 Southampton SO15 5AF
      8 England
      9 
     10 tel: +44 (0)23 8063 1441
     11 fax: +44 (0)23 8033 9691
     12 net: mpe@mpeforth.com
     13      tech-support@mpeforth.com
     14 web: www.mpeforth.com
     15 
     16 From North America, our telephone and fax numbers are:
     17   011 44 23 8063 1441
     18   011 44 23 8033 9691
     19 
     20 
     21 To do
     22 =====
     23 
     24 Change history
     25 ==============
     26 20100131 SFP001 STM32 conversion.
     27 ))
     28 
     29 only forth definitions
     30 
     31 
     32 \ *****************
     33 \ Serial primitives
     34 \ *****************
     35 
     36 align L: ^UART
     37   _USART1 ,
     38 
     39 IsLeaf : init-ser	\ --
     40 \ *G The host has already set up the UART. Force the UART into
     41 \ ** polled operation.
     42   CLD_UART @				\ if non-zero
     43   if  CLD_UART @ ^UART !  endif		\ use different UART
     44   ^UART @
     45 \  $0000 swap usCR3 + !			\ no interrupts, no DMA, no LIN, no smartcard
     46   $000C over usCR1 + !			\ 8 bit, no parity, TE, RE, no TX/RX ints
     47   $000D swap usCR1 + !			\ 8 bit, no parity, TE, RE, UE
     48 ;
     49 
     50 IsLeaf : emit	\ char --
     51   ^UART @
     52   begin
     53     dup usISR + @ bit7 and
     54   until
     55   usTDR + !
     56 ;
     57 
     58 IsLeaf : key?	\ -- t/f
     59   ^UART @ usISR + @ bit5 and  ;
     60 
     61 IsLeaf : key	\ -- char
     62   ^UART @
     63   begin
     64     dup usISR + @ bit5 and
     65   until
     66   usRDR + @ $FF and
     67   [asm  nop nop nop nop  nop nop nop nop  asm]
     68 ;
     69 
     70 : type		\ c-addr len --
     71   bounds ?do  i c@ emit  loop  ;
     72 
     73 : CR		\ --
     74   $0D emit  $0A emit  ;
     75