Merge "abstract buses" changes with "fix SPI flash read"
This commit is contained in:
@ -268,7 +268,7 @@ void rf_path_set_direction(rf_path_t* const rf_path, const rf_path_direction_t d
|
|||||||
#ifdef HACKRF_ONE
|
#ifdef HACKRF_ONE
|
||||||
rf_path_set_antenna(rf_path, 0);
|
rf_path_set_antenna(rf_path, 0);
|
||||||
#endif
|
#endif
|
||||||
rf_path_set_lna(0);
|
rf_path_set_lna(rf_path, 0);
|
||||||
/* Set RF path to receive direction when "off" */
|
/* Set RF path to receive direction when "off" */
|
||||||
rf_path->switchctrl &= ~SWITCHCTRL_TX;
|
rf_path->switchctrl &= ~SWITCHCTRL_TX;
|
||||||
rffc5071_disable(&rffc5072);
|
rffc5071_disable(&rffc5072);
|
||||||
|
@ -201,24 +201,27 @@ void w25q80bv_program(w25q80bv_driver_t* const drv, uint32_t addr, uint32_t len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void w25q80bv_read(uint32_t addr, uint32_t len, uint8_t* const data)
|
/* write an arbitrary number of bytes */
|
||||||
|
void w25q80bv_read(w25q80bv_driver_t* const drv, uint32_t addr, uint32_t len, uint8_t* const data)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
/* do nothing if we would overflow the flash */
|
/* do nothing if we would overflow the flash */
|
||||||
if ((len > W25Q80BV_NUM_BYTES) || (addr > W25Q80BV_NUM_BYTES)
|
if ((len > drv->num_bytes) || (addr > drv->num_bytes)
|
||||||
|| ((addr + len) > W25Q80BV_NUM_BYTES))
|
|| ((addr + len) > drv->num_bytes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
w25q80bv_wait_while_busy();
|
w25q80bv_wait_while_busy(drv);
|
||||||
|
|
||||||
gpio_clear(PORT_SSP0_SSEL, PIN_SSP0_SSEL);
|
uint8_t header[] = {
|
||||||
ssp_transfer(SSP0_NUM, W25Q80BV_FAST_READ);
|
W25Q80BV_FAST_READ,
|
||||||
ssp_transfer(SSP0_NUM, (addr >> 16) & 0xFF);
|
(addr & 0xFF0000) >> 16,
|
||||||
ssp_transfer(SSP0_NUM, (addr >> 8) & 0xFF);
|
(addr & 0xFF00) >> 8,
|
||||||
ssp_transfer(SSP0_NUM, (addr >> 0) & 0xFF);
|
addr & 0xFF
|
||||||
ssp_transfer(SSP0_NUM, 0xFF);
|
};
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
data[i] = ssp_transfer(SSP0_NUM, 0xFF);
|
const spi_transfer_t transfers[] = {
|
||||||
gpio_set(PORT_SSP0_SSEL, PIN_SSP0_SSEL);
|
{ header, ARRAY_SIZE(header) },
|
||||||
|
{ data, len }
|
||||||
|
};
|
||||||
|
|
||||||
|
spi_bus_transfer_gather(drv->bus, transfers, ARRAY_SIZE(transfers));
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,6 @@ void w25q80bv_chip_erase(w25q80bv_driver_t* const drv);
|
|||||||
void w25q80bv_program(w25q80bv_driver_t* const drv, uint32_t addr, uint32_t len, uint8_t* data);
|
void w25q80bv_program(w25q80bv_driver_t* const drv, uint32_t addr, uint32_t len, uint8_t* data);
|
||||||
uint8_t w25q80bv_get_device_id(w25q80bv_driver_t* const drv);
|
uint8_t w25q80bv_get_device_id(w25q80bv_driver_t* const drv);
|
||||||
void w25q80bv_get_unique_id(w25q80bv_driver_t* const drv, w25q80bv_unique_id_t* unique_id);
|
void w25q80bv_get_unique_id(w25q80bv_driver_t* const drv, w25q80bv_unique_id_t* unique_id);
|
||||||
void w25q80bv_read(uint32_t addr, uint32_t len, uint8_t* const data);
|
void w25q80bv_read(w25q80bv_driver_t* const drv, uint32_t addr, uint32_t len, uint8_t* const data);
|
||||||
|
|
||||||
#endif//__W25Q80BV_H__
|
#endif//__W25Q80BV_H__
|
||||||
|
@ -221,9 +221,6 @@ int main(void) {
|
|||||||
#endif
|
#endif
|
||||||
cpu_clock_init();
|
cpu_clock_init();
|
||||||
|
|
||||||
/* Code is not running from SPI flash, initialize for flash read/write over USB */
|
|
||||||
w25q80bv_setup();
|
|
||||||
|
|
||||||
usb_set_descriptor_by_serial_number();
|
usb_set_descriptor_by_serial_number();
|
||||||
|
|
||||||
usb_set_configuration_changed_cb(usb_configuration_changed);
|
usb_set_configuration_changed_cb(usb_configuration_changed);
|
||||||
|
@ -96,7 +96,7 @@ usb_request_status_t usb_vendor_request_read_spiflash(
|
|||||||
|| ((addr + len) > spi_flash.num_bytes)) {
|
|| ((addr + len) > spi_flash.num_bytes)) {
|
||||||
return USB_REQUEST_STATUS_STALL;
|
return USB_REQUEST_STATUS_STALL;
|
||||||
} else {
|
} else {
|
||||||
w25q80bv_read(addr, len, &spiflash_buffer[0]);
|
w25q80bv_read(&spi_flash, addr, len, &spiflash_buffer[0]);
|
||||||
usb_transfer_schedule_block(endpoint->in, &spiflash_buffer[0], len,
|
usb_transfer_schedule_block(endpoint->in, &spiflash_buffer[0], len,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
return USB_REQUEST_STATUS_OK;
|
return USB_REQUEST_STATUS_OK;
|
||||||
|
Submodule firmware/libopencm3 updated: 10503c7cc1...50c51c7b5f
Reference in New Issue
Block a user