dseq_bs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dseq_bs [2006/10/15 09:35] – (old revision restored) 127.0.0.1 | dseq_bs [2006/12/12 12:10] (current) – mess | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | bankstick | + | ====== Bankstick Routines ====== |
+ | |||
+ | This routines will load/save patterns from a bankstick | ||
+ | |||
+ | |||
+ | We're using the writepage MIOS function because a write to the bankstick takes a long time | ||
+ | this way we can write 64bytes at once so only 4 eeprom accesses are necessary | ||
+ | |||
+ | First versions of the firmware had a pattern size of 128bytes | ||
+ | so a pattern could be saved with two calls to the writepage function | ||
+ | |||
+ | Saving a pattern with 256bytes takes four page writes, this makes it impossible | ||
+ | to save the four pages after each other without affecting the sequencer timing. \\ | ||
+ | To avoid this the pattern is written over four ticks. Each time the program cycles through | ||
+ | the main loop a block is written until the whole pattern is saved. | ||
+ | |||
+ | Reading from a eeprom is a lot quicker so we can just call readpage for each block... | ||
+ | |||
+ | |||
+ | |||
+ | Code from bankstick.c: | ||
< | < | ||
///////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////// | ||
- | // These functions load/ | + | // This function initialises |
- | // using 2 page reads/ | + | |
///////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////// | ||
void BS_SavePat (unsigned char pat_nr){ | void BS_SavePat (unsigned char pat_nr){ | ||
- | unsigned char error = 0; | + | //only init block save if no other save is in progress |
- | unsigned int writeaddr; | + | if (save_block_cnt < NR_BLOCK) |
+ | return; | ||
- | //each pattern contains | + | //each pattern contains |
- | //so address = pat_nr*128 | + | //so address = pat_nr*256 |
- | writeaddr = ((unsigned int)pat_nr) << | + | writeaddr = ((unsigned int)pat_nr) << |
- | + | save_block_cnt | |
- | //write all values to bankstick | + | |
- | error | + | |
- | + | ||
- | error |= MIOS_BANKSTICK_WritePage(writeaddr + 64, buffer+64); | + | |
- | + | ||
- | //need to do some error handling | + | |
- | + | ||
} | } | ||
- | void BS_LoadPat | + | ///////////////////////////////////////////////////////////////////////////// |
+ | // This function saves a pattern block to a bankstick | ||
+ | ///////////////////////////////////////////////////////////////////////////// | ||
+ | void BS_SaveBlock | ||
unsigned char error = 0; | unsigned char error = 0; | ||
- | unsigned int readaddr; | + | //check if something has to be saved |
+ | if (save_block_cnt < NR_BLOCK) { | ||
+ | //write block | ||
+ | error |= MIOS_BANKSTICK_WritePage(writeaddr, | ||
+ | // | ||
+ | writeaddr += 0x40; | ||
+ | save_block_cnt++; | ||
- | // | + | if (error) { |
- | //so address = pat_nr*128 | + | MIOS_LCD_CursorSet(0xC0 + 0); |
- | readaddr | + | MIOS_LCD_PrintCString(" |
+ | MIOS_LCD_MessageStart(128); | ||
+ | //stop saving pattern | ||
+ | save_block_cnt | ||
+ | } | ||
+ | } | ||
- | //write all values to bankstick | + | } |
- | MIOS_BANKSTICK_ReadPage(readaddr, | + | |
- | MIOS_BANKSTICK_ReadPage(readaddr+64, buffer+64); | + | ///////////////////////////////////////////////////////////////////////////// |
- | + | // This function loads a pattern from a bankstick | |
- | // | + | ///////////////////////////////////////////////////////////////////////////// |
+ | void BS_LoadPat (unsigned char pat_nr){ | ||
+ | unsigned int readaddr; | ||
+ | unsigned char i; | ||
+ | //each pattern contains 256 bytes | ||
+ | //so address = pat_nr*256 | ||
+ | readaddr = ((unsigned int)pat_nr) << 8; | ||
+ | |||
+ | //load all values to bankstick | ||
+ | //(will be optimised in the future) | ||
+ | MIOS_BANKSTICK_ReadPage(readaddr + 0x00, buffer + 0x00); | ||
+ | MIOS_BANKSTICK_ReadPage(readaddr + 0x40, buffer + 0x40); | ||
+ | MIOS_BANKSTICK_ReadPage(readaddr + 0x80, buffer + 0x80); | ||
+ | MIOS_BANKSTICK_ReadPage(readaddr + 0xC0, buffer + 0xC0); | ||
+ | MIOS_LCD_CursorSet(0xC0 + 0); | ||
+ | if (MIOS_BOX_STAT.BS_AVAILABLE) { | ||
+ | MIOS_LCD_PrintCString(" | ||
+ | } else { | ||
+ | MIOS_LCD_PrintCString(" | ||
+ | } | ||
+ | MIOS_LCD_MessageStart(128); | ||
} | } | ||
dseq_bs.1160904901.txt.gz · Last modified: 2006/10/25 18:48 (external edit)