our_c32 Module

Files:

Interface

Function: SetDDR
Arguments: port: constant of port to set
pin: pin numberto set (typically 0-7), or -1 to set all (doesn't work for AD).
direction: DDR constant, or the hex of all DDRs.
Returns: A success code.
Sets the data direction of the specified port and pin. To set the data direction of an entire port at once, pass in -1 as the pin, and the hex char value as direction (instead of READ or WRITE). This does not work for the AD pins.

Function: ReadPort
Arguments: port: constant of port to read
pin: pin number to read, -1 to read all (does not work for AD)
Returns: HI, LO, AD value, hex of values of entire port, or ERROR.
Reads the value of the specified port and pin. A quirk: can't read in from analog pins set to 'I'.

Function: WritePort
Arguments: port: constant of port to write to
pin: pin number to write to, -1 to write to all
value: value to write, or hex of all values
Returns: Success constant.
Writes passed value to the specified port and pin.

Pseudo-Code

SetDDR(Takes the port, pin, and data direction. Returns a success code.)
  check to make sure input values are valid
  if the port is the AD port:
    set the proper char on the data direction string to the passed in data direction
    set the AD port with the new data direction string
    return success or error
  endif

  store the proper mask based on the pin and data direction values
  if the passed in pin variable is -1:
    set the entire data direction for the appropriate port with the passed in
      direction char
  else:
    set the data direction only for the pin and port indicated
  endif
  return success or failure
ReadPort(Takes the port and pin. Returns the pin value.)
  check to make sure input values are valid
  if the port is the AD port:
    return the short from ADS12_ReadADPin
  endif

  store the proper mask based on the pin value
  if the passed in pin variable is -1:
    return the char for the entire port
  else:
    store the result of the port data & mask
  endif
  return if the result does not equal 0
WritePort(Takes the port, pin, and value to write. Returns a success code.)
  check to make sure input values are valid

  store the proper mask based on the pin and value
  if the passed in pin variable is -1:
    set the entire port with the passed in value
  else:
    set the value only for the pin and port indicated
  endif
  return success or failure