Manually controlling the SerPortSel Pins

Eckhart K√∂ppen, author of the Blunt, the Newton bluetooth stack, has posted code on GitHub for manually controlling the SerPortSel3 signal.  His code manually controls the proper DIO pins using functions in the Newton ROM.

While this method works great for Serial3, I wanted to also control Serial0.  So I started looking at the ROM.  I found two functions in the ROM explicitly for controlling these signals:

0x0026d050 SerialPort0LineDriverConfig__16TVoyagerPlatformFUcT1
0x0026d094 SerialPort3LineDriverConfig__16TVoyagerPlatformFUcT1

I took a look at the assembly for these functions and found them to be pretty simple.  The first parameter seems to be a boolean and the second a bitfield.  I’m not exactly sure what the second parameter does, but it changes the behavior of the function when it finds the 0x20 bit set.

From what I can tell, for the Port3 function, you can leave the second parameter as 0x0 and the first parameter is a bool that controls the signal.  For the Port0 function, the first parameter the logical inverse of the signal you want, and the second parameter should be 0x20.

  • SerialPort0LineDriverConfig(0,0) // results in Port0Sel High 
  • SerialPort0LineDriverConfig(1,0) // results in Port0Sel High 
  • SerialPort0LineDriverConfig(0,0×20) // results Port0Sel High 
  • SerialPort0LineDriverConfig(1,0×20) // results Port0Sel Low 
  • SerialPort3LineDriverConfig(0,0) // results in  Port3Sel Low 
  • SerialPort3LineDriverConfig(1,0) // results in Port3Sel High 
  • SerialPort3LineDriverConfig(0,0×20) // results in Port3Sel Low 
  • SerialPort3LineDriverConfig(1,0×20) // results in Port3Sel Low

Eckhart’s code is an awesome blueprint for calling arbitrary memory locations, so it was easy to modify it to call these two functions.  Putting it all together, I whipped up this little Newton application:

Still a little more work to do, but good enough for development and testing.

Incidentally, when called with the correct parameters, the assembly behind SerialPort3LineDriverConfig is virtually identical to Eckhart’s code.  The SerialPort0LineDriverConfig is very similar but uses as GPIO instead of DIO.