/* DEVICE
- mn103ser - mn103002 I/O ports 0-3.
+ mn103iop - mn103002 I/O ports 0-3.
DESCRIPTION
io_port->port[i].control = 0;
io_port->port[i].pin = 0;
}
+ io_port->port[2].output_mode = 0xff;
io_port->p2ss = 0;
- io_port->p4ss = 0;
+ io_port->p4ss = 0x0f;
}
const void *source,
unsigned nr_bytes)
{
+ unsigned8 buf = *(unsigned8 *)source;
if ( nr_bytes == 1 )
{
- io_port->port[io_port_reg].output = *(unsigned16 *)source;
+ if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+ {
+ hw_abort(me, "Cannot write to read-only bits of P3OUT.");
+ }
+ else
+ {
+ io_port->port[io_port_reg].output = buf;
+ }
}
else
{
const void *source,
unsigned nr_bytes)
{
+ unsigned8 buf = *(unsigned8 *)source;
if ( nr_bytes == 1 )
{
/* check if there are fields which can't be written and
take appropriate action depending what bits are set */
- io_port->port[io_port_reg].output_mode = *(unsigned8 *)source;
+ if ( ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+ || ( (io_port_reg == 0 || io_port_reg == 1) && (buf & 0xfe) != 0 ) )
+ {
+ hw_abort(me, "Cannot write to read-only bits of output mode register.");
+ }
+ else
+ {
+ io_port->port[io_port_reg].output_mode = buf;
+ }
}
else
{
const void *source,
unsigned nr_bytes)
{
+ unsigned8 buf = *(unsigned8 *)source;
if ( nr_bytes == 1 )
{
- io_port->port[io_port_reg].control = *(unsigned8 *)source;
+ if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+ {
+ hw_abort(me, "Cannot write to read-only bits of P3DIR.");
+ }
+ else
+ {
+ io_port->port[io_port_reg].control = buf;
+ }
}
else
{
const void *source,
unsigned nr_bytes)
{
+ unsigned8 buf = *(unsigned8 *)source;
if ( nr_bytes == 1 )
{
/* select on io_port_reg: */
if ( io_port_reg == P2SS )
{
- io_port->p2ss = *(unsigned8 *)source;
+ if ( (buf && 0xfc) != 0 )
+ {
+ hw_abort(me, "Cannot write to read-only bits in p2ss.");
+ }
+ else
+ {
+ io_port->p2ss = buf;
+ }
}
else
{
- io_port->p4ss = *(unsigned8 *)source;
+ if ( (buf && 0xf0) != 0 )
+ {
+ hw_abort(me, "Cannot write to read-only bits in p4ss.");
+ }
+ else
+ {
+ io_port->p4ss = buf;
+ }
}
}
else