nRF5 SDK v17.1.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions

This module implements unified block device API. It could used as a middle layer between filesystems and memories. More...

Modules

 Empty implementation
 
 QSPI implementation
 
 Serial flash memory parameters
 
 RAM implementation
 This module implements block device API. It should be used as a reference block device.
 
 SDC implementation
 

Data Structures

struct  nrf_block_req_t
 Block device request descriptor item. More...
 
struct  nrf_block_dev_event_t
 Block device event. More...
 
struct  nrf_block_dev_geometry_t
 Block device geometry. More...
 
struct  nrf_block_dev_info_strings_t
 Block device information strings. More...
 
struct  nrf_block_dev_s
 Block device API. More...
 

Macros

#define NRF_BLOCK_DEV_REQUEST(name, block_start, block_count, buff)
 Helper macro to create block device read/write request item. More...
 
#define NFR_BLOCK_DEV_INFO_CONFIG(vendor, product, revision)
 Block device information config. More...
 
#define NFR_BLOCK_DEV_INFO_CONFIG_EMPTY   NFR_BLOCK_DEV_INFO_CONFIG(NULL, NULL, NULL)
 Empty info string initializer.
 
#define NRF_BLOCKDEV_BASE_ADDR(instance, member)   &(instance).member
 Helper macro to get block device address from specific instance. More...
 

Typedefs

typedef void(* nrf_block_dev_ev_handler )(struct nrf_block_dev_s const *p_blk_dev, nrf_block_dev_event_t const *p_event)
 Block device event handler. More...
 
typedef struct nrf_block_dev_s nrf_block_dev_t
 Block device API.
 
typedef struct nrf_block_dev_ops_s nrf_block_dev_ops_t
 Internals of nrf_block_dev_t.
 

Enumerations

enum  nrf_block_dev_event_type_t {
  NRF_BLOCK_DEV_EVT_INIT,
  NRF_BLOCK_DEV_EVT_UNINIT,
  NRF_BLOCK_DEV_EVT_BLK_READ_DONE,
  NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE
}
 Block device events. More...
 
enum  nrf_block_dev_result_t {
  NRF_BLOCK_DEV_RESULT_SUCCESS = 0,
  NRF_BLOCK_DEV_RESULT_IO_ERROR,
  NRF_BLOCK_DEV_RESULT_TIMEOUT
}
 
enum  nrf_block_dev_ioctl_req_t {
  NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH = 0,
  NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS
}
 Block device IOCTL requests. More...
 

Functions

static ret_code_t nrf_blk_dev_init (nrf_block_dev_t const *p_blk_dev, nrf_block_dev_ev_handler ev_handler, void const *p_context)
 Initializes a block device. More...
 
static ret_code_t nrf_blk_dev_uninit (nrf_block_dev_t const *p_blk_dev)
 Un-initializes a block device. More...
 
static ret_code_t nrf_blk_dev_read_req (nrf_block_dev_t const *p_blk_dev, nrf_block_req_t const *p_blk)
 Block read request. More...
 
static ret_code_t nrf_blk_dev_write_req (nrf_block_dev_t const *p_blk_dev, nrf_block_req_t const *p_blk)
 Block write request. More...
 
static ret_code_t nrf_blk_dev_ioctl (nrf_block_dev_t const *p_blk_dev, nrf_block_dev_ioctl_req_t req, void *p_data)
 IO control function. More...
 
static
nrf_block_dev_geometry_t const * 
nrf_blk_dev_geometry (nrf_block_dev_t const *p_blk_dev)
 Return a geometry of a block device. More...
 

Detailed Description

This module implements unified block device API. It could used as a middle layer between filesystems and memories.

Macro Definition Documentation

#define NFR_BLOCK_DEV_INFO_CONFIG (   vendor,
  product,
  revision 
)
Value:
( { \
.p_vendor = vendor, \
.p_product = product, \
.p_revision = revision, \
})

Block device information config.

Parameters
vendorVendor string
productProduct string
revisionRevision string
#define NRF_BLOCK_DEV_REQUEST (   name,
  block_start,
  block_count,
  buff 
)
Value:
nrf_block_req_t name = { \
.blk_id = block_start, \
.blk_count = block_count, \
.p_buff = buff, \
}

Helper macro to create block device read/write request item.

Parameters
nameInstance name
block_startBlock number start
block_countNumber of blocks
buffBuffer to read/write
#define NRF_BLOCKDEV_BASE_ADDR (   instance,
  member 
)    &(instance).member

Helper macro to get block device address from specific instance.

Parameters
instanceBlock device instance
memberBlock device member name

Typedef Documentation

typedef void(* nrf_block_dev_ev_handler)(struct nrf_block_dev_s const *p_blk_dev, nrf_block_dev_event_t const *p_event)

Block device event handler.

Parameters
[in]p_blk_devBlock device handle
[in]p_eventBlock device event

Enumeration Type Documentation

Block device events.

Events are propagated when event handler is defined (nrf_blk_dev_init)

Enumerator
NRF_BLOCK_DEV_EVT_INIT 

Passed to event handler when init is done

NRF_BLOCK_DEV_EVT_UNINIT 

Passed to event handler when uninit is done

NRF_BLOCK_DEV_EVT_BLK_READ_DONE 

Passed to event handler block read operation is done

NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE 

Passed to event handler block write operation is done

Block device IOCTL requests.

Enumerator
NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH 

Cache flush IOCTL request

NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS 

Get info strings IOCTL request

Enumerator
NRF_BLOCK_DEV_RESULT_SUCCESS 

Operation completed succsefully

NRF_BLOCK_DEV_RESULT_IO_ERROR 

I/O error

NRF_BLOCK_DEV_RESULT_TIMEOUT 

Device timeout

Function Documentation

static nrf_block_dev_geometry_t const* nrf_blk_dev_geometry ( nrf_block_dev_t const *  p_blk_dev)
inlinestatic

Return a geometry of a block device.

Parameters
[in]p_blk_devBlock device handle
Returns
Block size and count nrf_block_dev_geometry_t
static ret_code_t nrf_blk_dev_init ( nrf_block_dev_t const *  p_blk_dev,
nrf_block_dev_ev_handler  ev_handler,
void const *  p_context 
)
inlinestatic

Initializes a block device.

Parameters
[in]p_blk_devBlock device handle
[in]ev_handlerEvent handler (pass NULL to work in synchronous mode)
[in]p_contextContext passed to event handler
Returns
Standard error code
static ret_code_t nrf_blk_dev_ioctl ( nrf_block_dev_t const *  p_blk_dev,
nrf_block_dev_ioctl_req_t  req,
void *  p_data 
)
inlinestatic

IO control function.

Parameters
[in]p_blk_devBlock device handle
[in]reqBlock device ioctl request
[in]p_dataBlock device ioctl data
Returns
Standard error code
static ret_code_t nrf_blk_dev_read_req ( nrf_block_dev_t const *  p_blk_dev,
nrf_block_req_t const *  p_blk 
)
inlinestatic

Block read request.

In synchronous mode this function will execute the read operation and wait for its completion. In asynchronous mode the function will only request the operation and return immediately. Then, the NRF_BLOCK_DEV_EVT_BLK_READ_DONE event will signal that operation has been completed and the specified buffer contains valid data.

Parameters
[in]p_blk_devBlock device handle
[in]p_blkBlock device request
Returns
Standard error code
static ret_code_t nrf_blk_dev_uninit ( nrf_block_dev_t const *  p_blk_dev)
inlinestatic

Un-initializes a block device.

Parameters
[in]p_blk_devBlock device handle
Returns
Standard error code
static ret_code_t nrf_blk_dev_write_req ( nrf_block_dev_t const *  p_blk_dev,
nrf_block_req_t const *  p_blk 
)
inlinestatic

Block write request.

In synchronous mode this function will execute the write operation and wait for its completion. In asynchronous mode the function will only request the operation and return immediately. Then, the NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE event will signal that operation has been completed and the specified buffer can be freed.

Parameters
[in]p_blk_devBlock device handle
[in]p_blkBlock device request
Returns
Standard error code

Documentation feedback | Developer Zone | Subscribe | Updated