NAND. Added reset function.

This commit is contained in:
barthess 2017-01-06 11:06:40 +03:00
parent 71a77db50f
commit 779ea88be7
4 changed files with 23 additions and 8 deletions

View File

@ -82,6 +82,7 @@ typedef enum {
NAND_READ = 6, /**< Reading from NAND. */
NAND_DMA_TX = 7, /**< DMA transmitting. */
NAND_DMA_RX = 8, /**< DMA receiving. */
NAND_RESET = 9, /**< Software reset in progress. */
} nandstate_t;
/**

View File

@ -157,14 +157,9 @@ static void nand_isr_handler (NANDDriver *nandp) {
/* thread will be waked up from DMA ISR */
break;
case NAND_ERASE:
/* NAND reports about erase finish */
nandp->state = NAND_READY;
wakeup_isr(nandp);
break;
case NAND_PROGRAM:
/* NAND reports about page programming finish */
case NAND_ERASE: /* NAND reports about erase finish */
case NAND_PROGRAM: /* NAND reports about page programming finish */
case NAND_RESET: /* NAND reports about finished reset recover */
nandp->state = NAND_READY;
wakeup_isr(nandp);
break;
@ -410,6 +405,23 @@ uint8_t nand_lld_write_data(NANDDriver *nandp, const uint8_t *data,
return nand_lld_read_status(nandp);
}
/**
* @brief Soft reset NAND device.
*
* @param[in] nandp pointer to the @p NANDDriver object
*
* @notapi
*/
void nand_lld_reset(NANDDriver *nandp) {
nandp->state = NAND_RESET;
nand_lld_write_cmd (nandp, NAND_CMD_RESET);
osalSysLock();
nand_lld_suspend_thread(nandp);
osalSysUnlock();
}
/**
* @brief Erase block.
*

View File

@ -283,6 +283,7 @@ extern "C" {
uint8_t nand_lld_write_data(NANDDriver *nandp, const uint8_t *data,
size_t datalen, uint8_t *addr, size_t addrlen, uint32_t *ecc);
uint8_t nand_lld_read_status(NANDDriver *nandp);
void nand_lld_reset(NANDDriver *nandp);
#ifdef __cplusplus
}
#endif

View File

@ -229,6 +229,7 @@ void nandStart(NANDDriver *nandp, const NANDConfig *config, bitmap_t *bb_map) {
pagesize_check(nandp->config->page_data_size);
nand_lld_start(nandp);
nandp->state = NAND_READY;
nand_lld_reset(nandp);
if (NULL != bb_map) {
nandp->bb_map = bb_map;