dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 """
nexpaq 1:55a6170b404f 2 mbed SDK
nexpaq 1:55a6170b404f 3 Copyright (c) 2011-2013 ARM Limited
nexpaq 1:55a6170b404f 4
nexpaq 1:55a6170b404f 5 Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 1:55a6170b404f 6 you may not use this file except in compliance with the License.
nexpaq 1:55a6170b404f 7 You may obtain a copy of the License at
nexpaq 1:55a6170b404f 8
nexpaq 1:55a6170b404f 9 http://www.apache.org/licenses/LICENSE-2.0
nexpaq 1:55a6170b404f 10
nexpaq 1:55a6170b404f 11 Unless required by applicable law or agreed to in writing, software
nexpaq 1:55a6170b404f 12 distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 1:55a6170b404f 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 1:55a6170b404f 14 See the License for the specific language governing permissions and
nexpaq 1:55a6170b404f 15 limitations under the License.
nexpaq 1:55a6170b404f 16 """
nexpaq 1:55a6170b404f 17 from host_test import Test
nexpaq 1:55a6170b404f 18 from mbedrpc import SerialRPC, DigitalOut, DigitalIn, pin
nexpaq 1:55a6170b404f 19
nexpaq 1:55a6170b404f 20
nexpaq 1:55a6170b404f 21 class RpcTest(Test):
nexpaq 1:55a6170b404f 22 def test(self):
nexpaq 1:55a6170b404f 23 self.notify("RPC Test")
nexpaq 1:55a6170b404f 24 s = SerialRPC(self.mbed.port, debug=True)
nexpaq 1:55a6170b404f 25
nexpaq 1:55a6170b404f 26 self.notify("Init remote objects")
nexpaq 1:55a6170b404f 27
nexpaq 1:55a6170b404f 28 p_out = pin("p10")
nexpaq 1:55a6170b404f 29 p_in = pin("p11")
nexpaq 1:55a6170b404f 30
nexpaq 1:55a6170b404f 31 if hasattr(self.mbed.options, 'micro'):
nexpaq 1:55a6170b404f 32 if self.mbed.options.micro == 'M0+':
nexpaq 1:55a6170b404f 33 print "Freedom Board: PTA12 <-> PTC4"
nexpaq 1:55a6170b404f 34 p_out = pin("PTA12")
nexpaq 1:55a6170b404f 35 p_in = pin("PTC4")
nexpaq 1:55a6170b404f 36
nexpaq 1:55a6170b404f 37 self.output = DigitalOut(s, p_out);
nexpaq 1:55a6170b404f 38 self.input = DigitalIn(s, p_in);
nexpaq 1:55a6170b404f 39
nexpaq 1:55a6170b404f 40 self.check = True
nexpaq 1:55a6170b404f 41 self.write_read_test(1)
nexpaq 1:55a6170b404f 42 self.write_read_test(0)
nexpaq 1:55a6170b404f 43 return self.check
nexpaq 1:55a6170b404f 44
nexpaq 1:55a6170b404f 45 def write_read_test(self, v):
nexpaq 1:55a6170b404f 46 self.notify("Check %d" % v)
nexpaq 1:55a6170b404f 47 self.output.write(v)
nexpaq 1:55a6170b404f 48 if self.input.read() != v:
nexpaq 1:55a6170b404f 49 self.notify("ERROR")
nexpaq 1:55a6170b404f 50 self.check = False
nexpaq 1:55a6170b404f 51 else:
nexpaq 1:55a6170b404f 52 self.notify("OK")
nexpaq 1:55a6170b404f 53
nexpaq 1:55a6170b404f 54
nexpaq 1:55a6170b404f 55 if __name__ == '__main__':
nexpaq 1:55a6170b404f 56 RpcTest().run()