class::hal::PeriphObject

class hal::PeriphObject
  : public hal::Device

This class handles general peripheral IO. It re-implments open(), close(), read(), write(), ioctl() in order to manage the file descriptors for MCU peripherals.

Summary

virtual int close()

int fileno() const

virtual int ioctl(

const arg::IoRequest request,
const arg::IoArgument arg
) const

int open(

const fs::OpenFlags & flags
)

virtual int read(

const arg::DestinationBuffer buf,
const arg::Size size
) const

virtual int read(

fs::Aio & aio
) const

int seek(

const arg::Location & location,
PeriphObject::whence whence
) const

virtual int write(

const arg::SourceBuffer buf,
const arg::Size size
) const

virtual int write(

fs::Aio & aio
) const

protected u16 m_periph_port

protected int lookup_fileno() const

protected virtual int open(

const arg::SourceFilePath & name,
const fs::OpenFlags & flags
)

protected void update_fileno() const

typedef unsigned int port_t

Members

virtual int close()

Closes the file or device.


int fileno() const

virtual int ioctl(

const arg::IoRequest request,
const arg::IoArgument arg
) const

Executes an IO control request.

This method is typically only implemented for devices and other special file systems.


int open(

const fs::OpenFlags & flags
)

This method opens the peripheral. For each instance, the peripheral only needs to be opened one time. The port is typically opened with open() and configured with set_attr(). After that, other instances of the peripheral can read and write without opening again.


virtual int read(

const arg::DestinationBuffer buf,
const arg::Size size
) const

Reads the file.

Parameters

  • buf A pointer to the destination buffer

  • nbyte The number of bytes to read

Returns

The number of bytes read or less than zero on an error


virtual int read(

fs::Aio & aio
) const

Reads the device asynchronously.

Parameters

  • aio A reference to the fs::Aio object to use for reading

See also: fs::Aio


int seek(

const arg::Location & location,
PeriphObject::whence whence
) const


virtual int write(

const arg::SourceBuffer buf,
const arg::Size size
) const

Write the file.

Parameters

  • buf A pointer to the source buffer

  • nbyte The number of bytes to read

Returns

The number of bytes written or less than zero on an error


virtual int write(

fs::Aio & aio
) const

Writes the device asynchronously.

Parameters

  • aio A reference to the fs::Aio object to use for writing

See also: fs::Aio


protected u16 m_periph_port

protected int lookup_fileno() const

protected virtual int open(

const arg::SourceFilePath & name,
const fs::OpenFlags & flags
)

Opens a file.

Parameters

  • name The path to the file

  • flags The flags used to open the flag (e.g. File::READONLY)

Returns

Zero on success


protected void update_fileno() const

typedef unsigned int port_t

Defines the type to use when specifying a peripheral port.


X

Thanks for Coming!

Subscribe to news and updates