diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2015-12-23 10:59:07 -0800 |
---|---|---|
committer | Ashish Chaudhari <ashish@ettus.com> | 2016-01-05 17:35:14 -0800 |
commit | e92913f81a8a44def64dfcb7c0001d9ca7d2d2c4 (patch) | |
tree | 12d441822342db2e9e11b5cbe7c0fd156f0cba13 /firmware/usrp3/lib/flash/spi_flash.c | |
parent | f45b4eb386a4c4cf5e7a463936fb4591d1bf8854 (diff) | |
download | uhd-e92913f81a8a44def64dfcb7c0001d9ca7d2d2c4.tar.gz uhd-e92913f81a8a44def64dfcb7c0001d9ca7d2d2c4.tar.bz2 uhd-e92913f81a8a44def64dfcb7c0001d9ca7d2d2c4.zip |
n230: Initial checkin of firmware files
Diffstat (limited to 'firmware/usrp3/lib/flash/spi_flash.c')
-rw-r--r-- | firmware/usrp3/lib/flash/spi_flash.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/firmware/usrp3/lib/flash/spi_flash.c b/firmware/usrp3/lib/flash/spi_flash.c new file mode 100644 index 000000000..b4257c96f --- /dev/null +++ b/firmware/usrp3/lib/flash/spi_flash.c @@ -0,0 +1,50 @@ +/* + * Copyright 2014 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <flash/spi_flash.h> + +void spif_init(spi_flash_session_t* flash, const spi_flash_dev_t* device, const spi_flash_ops_t* ops) +{ + flash->device = device; + flash->ops = ops; + flash->state = IDLE; + flash->last_offset = 0; + flash->id = ops->read_id(device); +} + +void spif_read_sync(const spi_flash_session_t* flash, uint32_t offset, void *buf, uint32_t num_bytes) +{ + flash->ops->read(flash->device, offset, buf, num_bytes); +} + +bool spif_erase_sector_sync(const spi_flash_session_t* flash, uint32_t offset) +{ + if (flash->ops->erase_sector_dispatch(flash->device, offset)) { + return flash->ops->erase_sector_commit(flash->device, offset); + } else { + return false; + } +} + +bool spif_write_page_sync(const spi_flash_session_t* flash, uint32_t offset, const void *buf, uint32_t num_bytes) +{ + if (flash->ops->write_page_dispatch(flash->device, offset, buf, num_bytes)) { + return flash->ops->write_page_commit(flash->device, offset, buf, num_bytes); + } else { + return false; + } +} |