-
Notifications
You must be signed in to change notification settings - Fork 3k
SPIFBlockDevice doesn't play nice on shared SPI bus #11732. #12681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ SingletonPtr<PlatformMutex> SPIFBlockDevice::_mutex; | |
//*********************** | ||
SPIFBlockDevice::SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinName csel, int freq) | ||
: | ||
_spi(mosi, miso, sclk), _cs(csel), _prog_instruction(0), _erase_instruction(0), | ||
_spi(mosi, miso, sclk, csel, use_gpio_ssel), _prog_instruction(0), _erase_instruction(0), | ||
_page_size_bytes(0), _init_ref_count(0), _is_initialized(false) | ||
{ | ||
_address_size = SPIF_ADDR_SIZE_3_BYTES; | ||
|
@@ -110,7 +110,7 @@ SPIFBlockDevice::SPIFBlockDevice(PinName mosi, PinName miso, PinName sclk, PinNa | |
tr_error("SPI Set Frequency Failed"); | ||
} | ||
|
||
_cs = 1; | ||
_spi.deselect(); | ||
} | ||
|
||
int SPIFBlockDevice::init() | ||
|
@@ -470,8 +470,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_read_command(int read_inst, uint8_t *bu | |
uint32_t dummy_bytes = _dummy_and_mode_cycles / 8; | ||
int dummy_byte = 0; | ||
|
||
// csel must go low for the entire command (Inst, Address and Data) | ||
_cs = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be replaced with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is write function: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True about select and deselect, but looking at the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i correct understand SPI is only interface between block device, so when we want write/ready to block device something we select cs and do operations on spi (one block device operation can take few spi actions). Function _ int DataFlashBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) _ make few that operation and i cannot see reason to all time hold down cs (in my opinion cs should be down only when write spi operation). |
||
_spi.select(); | ||
|
||
// Write 1 byte Instruction | ||
_spi.write(read_inst); | ||
|
@@ -491,8 +490,8 @@ spif_bd_error SPIFBlockDevice::_spi_send_read_command(int read_inst, uint8_t *bu | |
buffer[i] = _spi.write(0); | ||
} | ||
|
||
// csel back to high | ||
_cs = 1; | ||
_spi.deselect(); | ||
|
||
return SPIF_BD_ERROR_OK; | ||
} | ||
|
||
|
@@ -519,8 +518,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_program_command(int prog_inst, const vo | |
int dummy_byte = 0; | ||
uint8_t *data = (uint8_t *)buffer; | ||
|
||
// csel must go low for the entire command (Inst, Address and Data) | ||
_cs = 0; | ||
_spi.select(); | ||
|
||
// Write 1 byte Instruction | ||
_spi.write(prog_inst); | ||
|
@@ -540,8 +538,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_program_command(int prog_inst, const vo | |
_spi.write(data[i]); | ||
} | ||
|
||
// csel back to high | ||
_cs = 1; | ||
_spi.deselect(); | ||
|
||
return SPIF_BD_ERROR_OK; | ||
} | ||
|
@@ -561,8 +558,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_general_command(int instruction, bd_add | |
uint32_t dummy_bytes = _dummy_and_mode_cycles / 8; | ||
uint8_t dummy_byte = 0x00; | ||
|
||
// csel must go low for the entire command (Inst, Address and Data) | ||
_cs = 0; | ||
_spi.select(); | ||
|
||
// Write 1 byte Instruction | ||
_spi.write(instruction); | ||
|
@@ -583,8 +579,7 @@ spif_bd_error SPIFBlockDevice::_spi_send_general_command(int instruction, bd_add | |
// Read/Write Data | ||
_spi.write(tx_buffer, (int)tx_length, rx_buffer, (int)rx_length); | ||
|
||
// csel back to high | ||
_cs = 1; | ||
_spi.deselect(); | ||
|
||
return SPIF_BD_ERROR_OK; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.