def mount_fram(): i2c = pyb.I2C(1, pyb.I2C.MASTER) f = FRAM(i2c) try: pyb.mount(None, '/fram') except: pass pyb.mount(f, '/fram')
def mount(): global card_instance if card_instance: raise SDCardError("Already mounted") rtb.pwr.SDCARD.request() if pyb.Pin.board.SD_CARD_INSERTED.value(): raise NoCardError("No card detected") card_instance = sdcardlib.SDCard(pyb.SPI(1), pyb.Pin.board.MICROSD_CS) pyb.mount(card_instance, '/spisd')
def umountflash(self): # Unmount flash and power it down if self.flash is None: return if self.mounted: self.flash.sync() try: pyb.mount(None, self.flash.mountpoint) except OSError: pass # Don't care if it wasn't mounted self.flash.end() # Shut down, turn off power if under control self.mounted = False # flag unmounted to prevent spurious syncs
def umountflash(self): # Unmount flash if self.flash is None: return if self.mounted: self.flash.sync() try: pyb.mount(None, self.flash.mountpoint) except OSError: pass # Don't care if it wasn't mounted self.flash.end() # Shut down self.mounted = False # flag unmounted to prevent spurious syncs
def sdtest(): sd = sdcard.SDCard(pyb.SPI(1), pyb.Pin.board.X21) # Compatible with PCB pyb.mount(sd, '/fc') print('Filesystem check') print(os.listdir('/fc')) line = 'abcdefghijklmnopqrstuvwxyz\n' lines = line * 200 # 5400 chars short = '1234567890\n' fn = '/fc/rats.txt' print() print('Multiple block read/write') with open(fn, 'w') as f: n = f.write(lines) print(n, 'bytes written') n = f.write(short) print(n, 'bytes written') n = f.write(lines) print(n, 'bytes written') with open(fn, 'r') as f: result1 = f.read() print(len(result1), 'bytes read') fn = '/fc/rats1.txt' print() print('Single block read/write') with open(fn, 'w') as f: n = f.write(short) # one block print(n, 'bytes written') with open(fn, 'r') as f: result2 = f.read() print(len(result2), 'bytes read') pyb.mount(None, '/fc') print() print('Verifying data read back') success = True if result1 == ''.join((lines, short, lines)): print('Large file Pass') else: print('Large file Fail') success = False if result2 == short: print('Small file Pass') else: print('Small file Fail') success = False print() print('Tests', 'passed' if success else 'failed')
def sdtest(): sd = sdcard.SDCard(pyb.SPI(1), pyb.Pin.board.X21) # Compatible with PCB pyb.mount(sd, '/fc') print('Filesystem check') print(os.listdir('/fc')) line = 'abcdefghijklmnopqrstuvwxyz\n' lines = line * 200 # 5400 chars short = '1234567890\n' fn = '/fc/rats.txt' print() print('Multiple block read/write') with open(fn,'w') as f: n = f.write(lines) print(n, 'bytes written') n = f.write(short) print(n, 'bytes written') n = f.write(lines) print(n, 'bytes written') with open(fn,'r') as f: result1 = f.read() print(len(result1), 'bytes read') fn = '/fc/rats1.txt' print() print('Single block read/write') with open(fn,'w') as f: n = f.write(short) # one block print(n, 'bytes written') with open(fn,'r') as f: result2 = f.read() print(len(result2), 'bytes read') pyb.mount(None, '/fc') print() print('Verifying data read back') success = True if result1 == ''.join((lines, short, lines)): print('Large file Pass') else: print('Large file Fail') success = False if result2 == short: print('Small file Pass') else: print('Small file Fail') success = False print() print('Tests', 'passed' if success else 'failed')
def unmount(): global card_instance pyb.mount(None, '/spisd') card_instance = None rtb.pwr.SDCARD.release()
def mountflash(self): if self.flash is None: # Not being used return self.flash.begin() # Turn on power if under control. Initialise. pyb.mount(self.flash, self.flash.mountpoint) self.mounted = True
def mountflash(self): if self.flash is None: # Not being used return self.flash.begin() # Initialise. pyb.mount(self.flash, self.flash.mountpoint) self.mounted = True