Home
Raspberry Pi LPC1114 I/O Processor Expansion Board User Guide
Contents
1. 29 GPIO Type DEAN TON Hae See 29 GPIO SEM ere Tbe UR Rd 30 Spiagent gpto configire sv porn 30 spiagent gpio configure 31 spiagent gpio configure 2 22 2 2 2 2 2 21 spiddgent OPODO GEN 4 deat ue 31 Spidgent X R XR 31 AtialogcInplit See Jen 32 splagent analog config re 32 Sgiagent analog det as SE 32 Pulse Width Modulator Output 0 32 Spiagent set frequency iie ne pete eph RE o pP ERAI Ic 32 spiagent pwim confiquEre eps S Ue 32 spiagent 32 _ __ 33 apiddent servo NS 33 Spiagent 1Trbtor cODHQUl e s DES 34 spiagent mMotor DU o o GE 34 Timer Type Definitions oue RR ILS ieee ees 35 Timer re Ee 36 Spiagent imer sors eres es ee 36 spiagent timer configure
2. 36 spiagent timer configure 37 spiagent timer configure 37 spiagent timer configure match sss 38 spiddent veli 38 spiagent timer get capt re Lx 39 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 3 of 49 spiagent timer get _ _ 39 LEGO Power Functions Remote Control Type Definitions 40 LEGO Power Functions Remote Control 5 1 5 40 Sspiadent 1 PIN avse 40 Special Function Register 5 41 SfF GE varende 41 sSplagen SF PU N 41 s on ROGER C 42 Spiagent Joterrupt enable ice MAY ObRPEPIPTR TREE 42 spiagent Jnterr pt lt GISADIE cas oes eo seed ina os 42 spiagent 42 Raspberry PI GPIO Pin Assignments and Device 5 43 LPC1114 GPIO Pin ASS I
3. 6 3 16 MuntsOS DETS ES ENE 17 SPI Agent Firmware 18 Command Message verte ere neue oes a ees 18 RESPONSE MESSAGE Hasene eden 18 Commando 19 O SPIAGENT END NOP SSE 19 1 SPIAGENT CMDs LOOPBACK usanne 19 2 SPIAGENT CMD CONFIGURE ANALOG 19 SPIAGENT CMD CONFIGURE GPIO 19 4 SPIAGENT CMD CONFIGURE GPIO 20 5 SPIAGENT CMD CONFIGURE PWM 20 6 SPIAGENT CMD GET ANALOG Aura Sethe ee banken sinn 20 7 SPIAGENT CMD GET Leve 20 8 SPIAGENT CMD PUT GR A 21 9 SPIAGENT CMD PUT PWM nen 21 10 SPIAGENT CMD CONFIGURE GPIO 21 11 SPIAGENT CMD CONFIGURE GPIQ dtr ct o Iso RE rm Ida Eck mere 22 12 SPIAGENT CMD 3 tin toa E pn EE 22 13 SPIAGENT CMD GET SFR ES 23 T4 SPIAGENT CMD PUT ae 23 15 SPIAGENT CMD CONFIGURE TIMER 23 16 SPIAGENT CMD CONFIGURE TIMER 5 24 17 SPIAGENT CMD CONFIGURE TIMER
4. 24 18 SPIAGENT CMD CONFIGURE TIMER 24 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 2 of 49 19 SPIAGENT CMD CONFIGURE TIMER 24 20 SPIAGENT CMD CONFIGURE TIMER 2 24 21 SPIAGENT CMD CONFIGURE TIMER 24 22 SPIAGENT CMD CONFIGURE TIMER MATCHO 25 23 SPIAGENT CMD CONFIGURE TIMER MATCH1 25 24 SPIAGENT CMD CONFIGURE TIMER MATCH2 25 25 SPIAGENT CMD CONFIGURE TIMER MATCH3 25 26 SPIAGENT GET 25 27 SPIAGENT CMD GET TIMER CAPTURE sagene eee 26 28 SPIAGENT CMD GET TIMER CAPTURE 26 29 SPIAGENT CMD INM 26 C Language API 25 d bea o daa eoe eau iue XC ERE UE 27 SPI Agent Transport Type 7 7 4 27 SPI Agent Transport Service 2 2 2 2 2 2 2 2 28 Splagen OPEN qd ocu S RD 28 spiagent command dc us buds 29
5. PWM output pin The pin parameter indicates the pin to set Allowed values are LPC1114 PWM1 through LPC1114 PWM4 The dutycycle parameter sets the output pulse train duty cycle Allowed values 0 through 100 0 percent 0 indicating mostly off low output and 100 0 percent indicating mostly on high output Note The actual resolution of the duty cycle varies depending on the pulse frequency from a full 16 bits at low frequencies to as little as 6 bits at higher frequencies spiagent servo configure void spiagent servo configure uint32_t pin int error This service configures one of the PWM outputs for driving a servo The PWM frequency must be 50 400Hz The pin parameter indicates the to configure Allowed values are LPC1114 PWM1 through LPC1114 spiagent servo put void spiagent servo put unsigned pin float position int error This service sets the position of an RC servo motor connected to a PWM output pin The pin parameter indicates the pin to set Allowed values are LPC1114 PWM1 through LPC1114 PWM4 The position parameter sets the position of the RC servo motor Allowed values 1 0 through 1 0 relative deflection from the null position value of 0 0 selects the null position Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 33 of 49 spiagent motor configure void spiagent motor configure uint32 t pwmpin uint32 t dirpin int error
6. The ONC RPC server program spi_agent_oncrpc_server provides highly efficient RPC services to client programs running on either the Raspberry Pi itself or on remote computers connecting via the network Many commonly used compiled programming langages such as C C Java C etc can issue ONC RPC calls with the proper development libraries Most interpreted programming languages such as Python Ruby Lua etc cannot make ONC RPC calls without a great deal of effort The advantage of ONC RPC is that it is very efficient spi_agent_oncrpc_server can handle over 2200 commands per second from a client program running on the same Raspberry Pi XML RPC Server XML RPC server program spi agent xmlrpc server provides highly portable RPC services to client programs running on either the Raspberry Pi itself or on remote computers connecting via the network The advantage of XML RPC is that it is very widely implemented most current programming languages including Python have support for it available The disadvantage of XML RPC is that it is far less efficient than ONC RPC spi agent xmlrpc server can only handle about 220 commands per second from a compiled C client program running on the same Raspberry Pi For interpreted language clients the protocol inefficiency of XML RPC matters less Python 3 client running on the Raspberry Pi can only issue about 69 commands per second about a third of what the server can handle Raspbe
7. The response message error field will set to ENODEV if the register address passed in the command message is outside the ranges 0x40000000 through 0x4007FFFF 0x50000000 through 0x501FFFFF 15 SPIAGENT CMD CONFIGURE TIMER MODE The 1114 counter timer CT32BO CT32B1 indicated by the command message pin field will be configured to the mode and counting source indicated by the command message data field The following counter timer identifiers are available 0 SPIAGENT CT32BO 1 SPIAGENT CT32B1 The following counter timer modes are available SPIAGENT TIMER MODE DISABLED SPIAGENT TIMER MODE RESET SPIAGENT TIMER MODE PCLK SPIAGENT TIMER MODE CAPO RISING SPIAGENT TIMER MODE CAPO FALLING SPIAGENT TIMER MODE CAPO BOTH The response message error field will be set to ENODEV if the timer identifier is invalid or to EINVAL if the mode is invalid Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 23 of 49 Note PCLK is the LPC1114 s 48 MHz system clock CAPO is the capture input 4 for CT32BO GPIOO for 2 1 16 SPIAGENT CMD CONFIGURE TIMER PRESCALER The command message data field minus 1 will be written to the prescaler divisor register for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command message pin field The response message error field will be set to ENODEV if the timer identifier is invalid or to EINVAL if the divisor is zero
8. 17 SPIAGENT CMD CONFIGURE TIMER CAPTURE The capture subsystem for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command message pin field will be configured according to the settings indicated by the command message data field The settings are encoded as follows Bits 0 3 Capture edge Bit 4 Interrupt the Raspberry Pi on each capture event Bits 5 31 Not used The following capture edge settings are available 0 SPIAGENT TIMER CAPTURE EDGE DISABLED 1 SPIAGENT TIMER CAPTURE EDGE CAPO RISING 2 SPIAGENT TIMER CAPTURE EDGE CAPO FALLING 3 SPIAGENT TIMER CAPTURE EDGE CAPO BOTH The response message error field will be set to ENODEV if the timer identifier is invalid or to EINVAL if the mode is invalid 18 SPIAGENT CMD CONFIGURE TIMER MATCHO 19 SPIAGENT CMD CONFIGURE TIMER MATCH1 20 SPIAGENT CMD CONFIGURE TIMER MATCH2 21 SPIAGENT CMD CONFIGURE TIMER MATCH3 The corresponding match control register MCRO 3 and external match register EMRO 3 for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command message pin field will be configured according to the settings in the command message data field Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 24 of 49 The settings encoded as follows Bits 0 3 Match output action Bit 4 Interrupt the Raspberry Pi on match Bit 5 Reset the counter on match Bit 6 Stop the counter on match Bits 7 31 Not used The following match output ac
9. This service configures a pair of GPIO pins PWM output and direction output for driving an H bridge DC motor driver The pwmpin parameter indicates the pin to configure as the PWM output Allowed values are LPC1114 PWM1 through LPC1114 The dirpin parameter indicates the pin to configure as the direction output Allowed values LPC1114 through LPC1114 GPIOT pwmpin and dirpin cannot be the same pin spiagent motor void spiagent motor put uint32 t pwmpin uint32 t dirpin float speed int error This service sets the speed for a H bridge driven DC motor The pwmpin parameter indicates the pin configured as the PWM output Allowed values are LPC1114 PWM1 through LPC1114 The dirpin parameter indicates the pin configured as the direction output Allowed values LPC1114 through LPC1114 GPIO7 pwmpin and dirpin cannot be the same pin The speed parameter sets the normalized speed of the motor Allowed values are 1 0 full speed reverse through 1 0 full speed forward value of 0 0 stops the motor Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 34 of 49 Timer Definitions typedef enum SPIAGENT CT32B0 SPIAGENT CT32B1 SPIAGENT TIMER ID SENTINEL spiagent timer t typedef enum SPIAGENT TIMER MODE DISABLED SPIAGENT TIMER MODE RESET SPIAGENT TIMER PCLK SPIAGENT TIMER MODE CAPO
10. Width Modulated Output 2 32 Bit Timer 1 Match Output 1 LPC1114 GPIO3 P1 3 General Purpose Input Output 3 Analog Input 4 Pulse Width Modulated Output 3 32 Bit Timer 1 Match Output 2 LPC1114 GPIO4 P1 4 General Purpose Input Output 4 Analog Input 5 32 Bit Timer 1 Match Output 3 LPC1114 GPIO5 P1 5 General Purpose Input Output 5 32 Bit Timer 0 Capture Input 0 LPC1114 GPIO6 P1 8 General Purpose Input Output 6 16 Bit Timer 1 Capture Input O LPC1114 GPIO7 P1 9 General Purpose Input Output 7 Pulse Width Modulated Output 4 16 Bit Timer 1 Match Output 0 Table 1 LPC1114 GPIO Pin Functions Note The LPC1114 GPIO pins are 5V tolerant except when configured as analog inputs The input voltage to pins configured for analog input must never exceed 3 3V Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 7 of 49 Connecting the Processor Expansion Board It is recommended to mount your Raspberry Pi in some sturdy fashion before attaching the LPC1114 I O Processor Expansion Board to it Some suggestions are Mount both the Raspberry Pi and the I O Processor Expansion Board to piece of wood using screws and standoffs Mount the Raspberry Pi inside case such as the Pibow which is in turn mounted to piece of wood Mount the I O Processor Expansion Board with screws and standoffs Mount both the Raspberry and the I O Processor Expansion Board inside a project case
11. have an internal pull up resistor enabled If you need a high impedance input with neither pull up nor pull down use the SPIAGENT CMD CONFIGURE GPIO command described below The response message error field will be set to ENODEV if the selected pin 15 not a valid GPIO input pin or EINVAL if the data field is invalid Valid pins for this service are LPC1114 GPIO0 7 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 19 of 49 4 SPIAGENT CMD CONFIGURE GPIO OUTPUT The LPC1114 GPIO pin indicated by the command message pin field will be configured as digital push pull output The data field indicates the initial state for the GPIO output pin If you need an open drain output instead of push pull use the SPIAGENT CMD CONFIGURE GPIO command described below The response message error field will be set to ENODEV if the selected pin is not a valid GPIO output pin or EINVAL if the data field is invalid Valid pins for this service are LPC1114 GPIO0 7 LPC1114 INT and LPC1114 LED 5 SPIAGENT CMD CONFIGURE PWM OUTPUT The LPC1114 GPIO pin indicated by the command message pin field will be configured as a Pulse Width Modulated push pull output The data field sets the pulse frequency and is limited to the range 50 through 50 000 Hz inclusive The response message error field will be set to ENODEV if the selected pin is not configurable as a PWM output or EINVAL if the pulse frequency is out of range Valid pins for t
12. scripts expansion 1 1114 install expansion 1 1114 flash Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 11 of 49 Preprogrammed SPI Agent Firmware The LPC1114 single chip microcomputer comes preprogrammed with program known as the SPI Agent The SPI Agent program configures the LPC1114 SPI Serial Peripheral Interconnect as an SPI slave and listens for commands from the Raspberry Pi All of the example programs in the Raspberry Pi Microcontroller Framework source directory rpi mcu expansion LPCl1114 src rely on the SPI Agent firmware LED Test You can run the following commands at the Raspberry Pi command line to try the SPI Agent cd HOME rpi mcu expansion LPC1114 src led test led These commands compile and run the C program test led which merely flashes the LPC1114 I O Processor Expansion Board LED Once a second test led running on the Raspberry Pi sends an SPI command message to the SPI Agent running on the LPC1114 I O Processor Expansion Board telling it to toggle the LED SPI Agent Test Run the following commands to run the SPI Agent verification test which exercises the SPI interconnect between the Raspberry PI and the LPC1114 I O Processor Expansion Board cd HOME rpi mcu expansion LPC1114 src spi agent lib clients c make spi agent test localhost 1000000 This compiles and runs spi agent test which executes over a million SPI transactions to ensure error free per
13. 4 GPIO pin identifier echoed data Depends upon the particular command error Error number from errno h Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 18 of 49 Commands The following commands are defined New commands will be added from time to time but backward compatibility will be maintained All response messages will echo the command and pin fields from the command message Unless specified otherwise the response message data field will always be set to zero The response message error field will also be set to zero upon success or to a value from errno h typically ENODEV or EINVAL upon failure 0 SPIAGENT CMD NOP The response message data field will contain the SPI Agent Firmware version number if available 1 SPIAGENT CMD LOOPBACK The command message command pin and data fields are all echoed in the response message 2 SPIAGENT CMD CONFIGURE ANALOG INPUT The LPC1114 GPIO pin indicated by the command message pin field is configured as an analog input The command message data field is ignored The response message error field will be set to ENODEV if the selected pin is not a valid analog input pin Valid pins for this service are LPC1114 ADC1 5 3 SPIAGENT CMD CONFIGURE GPIO INPUT The LPC1114 GPIO pin indicated by the command message pin field will be configured as a digital input If data is zero it will have an internal pull down resistor enabled If data is one it will
14. ELKT br NOISNvdX3 Id 8 5 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 46 of 49 Board Revision 1 Revision 2 User Guide Revision 1 0 Revision 1 1 Revision 1 2 Revision 1 3 Revision 1 4 Revision 1 5 Revision 1 6 Revision 1 7 Revision 1 8 Revision 1 9 Revision History 17 December 2012 First prototype 25 January 2013 Reduced the size of the board 29 June 2013 Published for Revision 2 board 13 July 2013 Changed expansion to I O Processor throughout Added note that no extra hardware is required for programming the LPC1114 flash 15 July 2013 Added Quick Setup with shortened URL Added more explanatory notes here and there 27 July 2013 Added instructions for updating the LPC1114 SPI Agent factory firmware 23 August 2013 The RPC servers are now enabled by default so the text describing how to enable them was removed Removed liblockdev1 dev from the list of required packages Renamed the Developing Firmware section to Software Support 9 October 2013 Changed I O Processor Board to I O Processor Expansion Board throughout Added section describing the libspiagent so shared library Other minor edits 25 October 2013 Added Java to the list of languages that can use libspiagent so Other minor edits 16 December 2013 Added SPI Agent Firmware API Reference section 31 Janu
15. LPC1114 INT and LPC1114 INT2 as LPC1114 READY Revision 26 2 October 2015 Renamed 1 1114 PWM4 5 6 to LPC1114 PWM1 2 3 Added support for fourth PWM outout LPC1114 GPIOT Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 49 of 49
16. O Processor Expansion Board User Guide Rev 26 Page 31 of 49 Analog Input Services spiagent analog configure void spiagent analog configure unsigned pin int error This service configures an LPC1114 GPIO pin as an analog input The pin parameter indicates the pin to configure Allowed values are LPC1114 AD1 though LPC1114AD5 spiagent analog get void spiagent analog get unsigned pin float voltage int error This service samples an analog input pin The pin parameter indicates the pin to read from Allowed values are LPC1114 AD1 though LPC1114AD5 The voltage parameter well be set to the voltage sampled at the analog input with range from 0 0 to 3 3V Pulse Width Modulator Output Services spiagent set frequency void spiagent set frequency unsigned freq int error This service sets the PWM pulse frequency for all four PWM channels The freg parameter sets the PWM pulse frequency in Hz The allowed frequency range is 50 50000 Hz spiagent configure void spiagent pwm configure unsigned pin int error This service configures an LPC1114 GPIO pin as a PWM output The pin parameter indicates the pin to configure Allowed values are LPC1114 PWM1 through LPC1114 spiagent put void spiagent pwm put unsigned pin float dutycycle int error Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 32 of 49 This service sets the output duty cycle
17. O pin assignments define define define define define define define define define define define LPC1114 INT LPC1114 READY LPC1114 LED LPC1114 GPIOO LPC1114 GPIO1 LPC1114 GPIO2 LPC1114 LPC1114 4 LPC1114 5 LPC1114 6 LPC1114 GPIO7 3 11 7 12 13 14 15 16 17 20 21 PIO0 3 Raspberry Pi GPIO4 0 11 Raspberry Pi GPIO22 PIO0 7 Expansion board LED 010 Terminal block pos 2 PIO1 1 Terminal block pos 3 012 Terminal block pos 4 PIO1 3 Terminal block pos 5 PIO1 4 Terminal block pos 6 PIO1 5 Terminal block pos 7 1 8 Terminal block pos 8 1 9 Terminal block pos 9 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 43 of 49 LPC1114 Processor GPIO special function aliases define LPC1114 AD1 LPC1114 define LPC1114 AD2 LPC1114 GPIO1 define LPC1114 AD3 LPC1114 GPIO2 define LPC1114 AD4 LPC1114 define LPC1114 AD5 LPC1114 GPIO4 define LPC1114 PWM1 LPC1114 GPIO1 define LPC1114 PWM2 LPC1114 GPIO2 define LPC1114 PWM3 LPC1114 iidefine LPC1114 PWM4 LPC1114 GPIO7 define LPC1114 CT32B1 CAPO LPC1114 GPIOO define LPC1114 CT32B1 LPC1114 GPIOl define LPC1114 CT32B1 MAT1 LPC1114 GPIO2 define LPC1114 CT32B1 2 LPC1114 define LPC1114 CT32B1 MAT3 LPC1114 GPIO4 iidefine LPC1114 CT32BO CAPO LPC1114 5
18. ON MENS cia sa d noi d aon ad end cepe a ees ex ea aca re te 43 Additional Online 1 4 2 90 nn 45 DEE i udo ie than da 46 Revision Tuba Ta bet 47 Bardus 47 User ene 47 Raspberry LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 4 of 49 Introduction The Raspberry Pi LPC1114 I O Processor Expansion Board is an expansion board for the Raspberry Pi containing an LPC1114 ARM Cortex MO microcontroller The LPC1114 microcontroller connects to the SPI I2C and UART ports on the Raspberry Pi expansion header and to 8 GPIO signals on the terminal block The LPC1114 microcontroller is capable of very fast interrupt and GPIO signal manipulation making it suitable for variety of applications such as infrared remote control protocols Such protocols typically have stringent timing requirements and would otherwise be impossible to implement with the Raspberry Pi alone The LPC1114 microcontroller also offers a great deal of flexibility The GPIO signals brought out from the LPC1114 to the terminal block may be configured under software control for variety of functions such as A D Analog to Digital inputs PWM Pulse Width Modulation outputs and GPIO General Purpose Input Output si
19. PUT SPIAGENT GPIO DIRECTION SENTINEL SPIAGENT GPIO DIRECTION t SPI Agent Firmware GPIO resistor directions typedef enum SPIAGENT GPIO PULLDOWN SPIAGENT GPIO PULLUP SPIAGENT GPIO RESISTOR SENTINEL SPIAGENT GPIO RESISTOR t Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 29 of 49 SPI Agent Firmware GPIO configuration modes typedef enum SPIAGENT GPIO MODE INPUT High impedance input SPIAGENT GPIO MODE INPUT PULLDOWN SPIAGENT GPIO MODE INPUT PULLUP SPIAGENT GPIO MODE OUTPUT Push pull output SPIAGENT GPIO MODE OUTPUT OPENDRAIN SPIAGENT GPIO MODE SENTINEL SPIAGENT GPIO MODE SPI Agent Firmware GPIO input interrupt configurations typedef enum SPIAGENT GPIO INTERRUPT DISABLED SPIAGENT GPIO INTERRUPT FALLING SPIAGENT GPIO INTERRUPT RISING SPIAGENT GPIO INTERRUPT BOTH SPIAGENT GPIO INTERRUPT SENTINEL SPIAGENT GPIO INTERRUPT CONFIG t GPIO Services spiagent gpio configure void spiagent gpio configure unsigned pin unsigned direction unsigned state int error This service configures an LPC1114 GPIO pin setting the direction and state in a single operation The pin parameter indicates the pin to configure The direction parameter indicates whether to configure the pin as input or output Use values from SPIAGENT GPIO DIRECTION t The state parameter sets the initial state for output pins 0 or 1 and the resistor configuration for input
20. RISING SPIAGENT TIMER MODE CAPO FALLING SPIAGENT TIMER MODE CAPO BOTH SPIAGENT TIMER SENTINEL spiagent _ timer _ mode _ t typedef enum SPIAGENT TIMER CAPTURE EDGE DISABLED SPIAGENT TIMER CAPTURE EDGE CAPO RISING SPIAGENT TIMER CAPTURE EDGE _ CAPO FALLING SPIAGENT TIMER CAPTURE EDGE _ CAPO BOTH SPIAGENT TIMER CAPTURE EDGE SENTINEL spiagent timer capture edge typedef enum SPIAGENT TIMER MATCH OUTPUT DISABLED SPIAGENT TIMER MATCH OUTPUT CLEAR SPIAGENT TIMER MATCH OUTPUT SET SPIAGENT TIMER MATCH OUTPUT TOGGLE SPIAGENT TIMER MATCH OUTPUT _ SENTINEL spiagent _ timer match output action t Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 35 of 49 Timer Services Note the internal clock of the LPC1114 microcontroller 15 only accurate to 1 over the temperature range of 40 to 85 These services are complicated in order to support all of the features of the LPC1114 timers You will need to carefully study the LPC11xx User Guide order to fully understand how the timers work Experimenting with test_timer cin the timer directory will also be helpful spiagent timer init void spiagent timer init unsigned timer int error This service powers on and initializes an LPC1114 timer The timer parameter selects which timer to configure Use values from spiagent timer id t spiagent timer configu
21. Raspb Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Revision 26 2 October 2015 by Philip Munts Munts Technologies http tech munts com erry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 1 of 49 Contents Todt SoS 5 Around the LPC1114 I O Processor Expansion 6 Connecting the I O Processor Expansion 8 Software SUPPEN 9 Quick Setup For the IMPatient daa 9 Step One Install Linux 9 Step Two Install the ARM Microcontroller Cross Compiler Toolchain 10 Step Three Download Support 10 Step Four Upgrade SPI Agent 10 Software UPC ales eda ad dd aaa 11 Preprogrammed SPI Agent 2 24 2 22 2 12 LED TESS SN 12 SPI AJEN ES ME 12 SPI Agent RLS PR 14 vestes 6 e 14 GT 14 HIP SEVEN er Aae Ge kb dl 15 The libspiagent so Shared
22. Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 44 of 49 Additional Online Documentation SPI Agent Firmware C Language API Reference ONC RPC http tech munts com rpi Ipc1114 src csharp SPIAgent Lib ONC RPC API html SPI Agent Firmware C Language API Reference XML RPC http tech munts com rpi Ipc1114 src csharp SPIAgent Lib XML RPC API html SPI Agent Firmware Python3 Language API Reference http tech munts com rpi Ipc1114 src python API html LPC1114 Data Sheet http www nxp com documents data sheet LPC111X pdf LPC1114 User Manual http www nxp com documents user manual UM10398 pdf Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 45 of 49 0 51 USP InEWSYISPENPODD SINNNNSIINPOISJJSID alld SUNA SUNN dyd JOUINY 000 51 pieog uorsuedx3 PLL LOT Id Auaqdsey eni polq iunii sod OF er Schematic Diagram On NO On NO On NO On NO S310H ONILNNOW ONS 241 SANIOd 1531 OIQMS ETHOId Z OOld 13S3H 0125 9 0014 170014951 05 970019 2700147088 170014 270018 ATIMS OL 00184 00141125 ISON 6 0014 08104270014 ZOWSZNIPLEEIGT in PE vf pp er 221 Japeay GAs OND MTISHLOIdO OSIN GOIdO ISOW OLOIdO 220140 170149 yOIdo waan zt ano 23 2
23. Type Definitions SPI Agent Firmware commands typedef enum SPIAGENT CMD NOP SPIAGENT CMD LOOPBACK SPIAGENT CMD CONFIGURE ANALOG INPUT SPIAGENT CMD CONFIGURE GPIO INPUT SPIAGENT CMD CONFIGURE GPIO OUTPUT SPIAGENT CMD CONFIGURE PWM OUTPUT SPIAGENT CMD GET ANALOG SPIAGENT CMD GET GPIO SPIAGENT CMD PUT GPIO SPIAGENT CMD SPIAGENT CMD CONFIGURE GPIO INTERRUPT SPIAGENT CMD CONFIGURE GPIO SPIAGENT CMD LEGORC SPIAGENT CMD GET SFR SPIAGENT CMD SFR SPIAGENT CMD CONFIGURE _ TIMER MODE SPIAGENT CMD CONFIGURE TIMER PRESCALER SPIAGENT CMD CONFIGURE TIMER CAPTURE SPIAGENT CMD CONFIGURE TIMER MATCHO SPIAGENT CMD CONFIGURE TIMER MATCHL SPIAGENT CMD CONFIGURE TIMER MATCH2 SPIAGENT CMD CONFIGURE TIMER MATCH3 SPIAGENT CMD CONFIGURE TIMER MATCHO VALUE SPIAGENT CMD CONFIGURE TIMER VALUE SPIAGENT CMD CONFIGURE TIMER MATCH2 VALUE SPIAGENT CMD CONFIGURE TIMER MATCH3 VALUE SPIAGENT CMD GET TIMER VALUE SPIAGENT CMD GET TIMER CAPTURE SPIAGENT CMD GET TIMER CAPTURE DELTA SPIAGENT CMD INIT TIMER SPIAGENT CMD SENTINEL SPIAGENT COMMAND t Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 27 of 49 SPI Agent Firmware commmand message structure typedef struct uint32 t command uint32 t pin uint32 t data SPIAGENT COMMAND MSG t SPI Agent Firmware response message structure type
24. about Muntsos Revision 16 13 October 2014 Clarified the timer service definitions Revision 17 21 October 2014 Added spiagent servo set postion for controlling RC servo motors Revision 18 24 October 2014 Removed the runtest target from testprogram mk Modified testprogram mk to allow multiple test programs per directory Revision 19 6 November 2014 Allow configuring the LED and interrupt output pins with SPIAGENT CMD CONFIGURE GPIO Revision 20 7 November 2014 Use expansion 1 1114 flash instead of make install factory firmware Revision 21 6 February 2015 Renamed muntsos lpclll4 zip to muntsos lpclll4 RaspberryPi zip Added links to additional online documentation Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 48 of 49 22 6 March 2015 Added spiagent servo configure Renamed spiagent servo set position to spiagent servo put Added spiagent motor configure and spiagent motor put Also lifted the 50 Hz PWM pulse rate requirement for servos servos can now be configured with pulse rates of 50 400 Hz Standard RC servos still need 50 Hz some newer digital servos can go as high as 400 Hz Revision 23 23 March 2015 Moved the ARM microcontroller toolchain installation directory from opt arm mcu tools to usr local arm mcu tools Revision 24 11 June 2015 Moved repositories to http git munts com Revision 25 28 August 2015 Refined LPC1114 5
25. about the SPI Agent Firmware API Application Programming Interface is the C header file include spi agent h and its subordinates Each SPI bus transaction between the Raspberry Pi and the LPC1114 consists of two message packets one to the LPC1114 the Command Message and the other from the LPC1114 the Response Message Pointers to these message structures are handed to the Linux SPI ioctl operation The underlying C library functions system calls and kernel services pass the command message to the LPC1114 and retrieve the response message from it all in single ioctl system call Command Message The Command Message is a sequence of three 32 bit unsigned integers It is defined as a structure of type SPIAGENT COMMAND MSG tin spi agent h for the language Other language bindings may implement the command message in their respective record or structure equivalents or as a simple array of 32 bit integers command command code defined below pn pin LPC1114 GPIO pin identifier defined below data Depends upon the particular command Response Message The Response Message is a sequence of four 32 bit unsigned integers It is defined as a structure of type SPIAGENT RESPONSE MSG t in spi agent h for the C language Other language bindings may implement the command message in their respective record or structure equivalents or as a simple array or list of 32 bit integers command Command code echoed pn pin LPC111
26. and followed by a semicolon 0 8 7 0 0 Your client program should be able to handle gracefully any arbitrary response message such aS ERROR 404 or other messages inserted by proxy servers Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 15 of 49 libspiagent so Shared Library As an even further abstraction the dynamic shared library libspiagent so libspiagent dll on Windows encapsulates several different transport mechanisms between an application program and the SPI Agent Firmware These mechanisms include the ONC RPC and XML RPC protocols described above along with HTTP and the Linux ioctl interface The GNAT Ada C C Free Pascal Java and Python3 programming languages the Raspberry Pi can use libspiagent so Each of these languages has thin binding for libspiagent so available For remote client computers libspiagent so may or may not be usable depending on the programming language and the operating system See README txt in the spi agent lib directory for more detailed information Most of the example programs for the Raspberry Pi LPC1114 Processor Expansion Board have been rewritten to use libspiagent Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 16 of 49 MuntsOS Dedicated Server If you intend to use your Raspberry Pi and LPC1114 I O Processor Expansion board as a dedicated system you may want to consider using the Muntsos Dedicated Se
27. arameter selects which CAPO input edge or edges trigger a counter capture event Use values from spiagent timer capture edge t The intr parameter selects whether an interrupt to the Raspberry Pi is generated upon a capture event Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 37 of 49 spiagent timer configure matchf void spiagent timer configure match unsigned timer unsigned match uint32 t value unsigned action bool intr bool reset bool stop int error This service configures an LPC1114 timer match register A match will occur each time the counter register equals the match register The timer parameter selects which timer to configure Use values from spiagent timer id t The match parameter selects which match register to configure Legal values are 0 to 3 inclusive The value parameter will be written to the match register The action selects what will happen at the match output pin MATO through MAT3 if a match occurs Not timers have all match outputs available Use values from spiagent timer match output action t The intr parameter selects whether an interrupt to the Raspberry Pi is generated upon a match The reset parameter selects whether the timer is reset to zero upon a match The stop parameter selects whether the timer is stopped upon a match spiagent timer get void spiagent timer get unsigned timer uint32 t count int error This service retrieves the current valu
28. ard other motor values 0 Not used Bits 16 23 Motor 0 stop 1 Motor 2 Motor 3 Combo Direct 4 Combo PWM Bits 24 31 Channel 1 4 The response message error field will be set to ENODEV if the selected pin is not a valid GPIO output pin or to EINVAL if the command message data field is invalid Valid pins for this service are LPC1114 00 7 Note The LEGO Power Functions RC Protocol specifies that each command be transmitted 5 times with timing between transmissions dependent upon the channel number This service only sends the command one time Note This service requires 20 milliseconds to execute during which both the ioctl system call and calling program are blocked Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 22 of 49 Note See the LEGO Power Functions RC specification for more information especially about the Combo Direct and Combo PWM commands 13 SPIAGENT CMD GET SFR The contents of the LPC1114 peripheral register indicated by the command message pin field will be returned in the response message data field The response message error field will set to ENODEV if the register address passed in the command message is outside the ranges 0x40000000 through 0x4007FFFF 0x50000000 through 0x501FFFFF 14 SPIAGENT CMD PUT SFR The contents of the command message data field will be written to the LPC1114 peripheral register indicated by the command message pin field
29. ary 2014 Expanded the API reference section to include all of the C functions in libspiagent so Added timer services Added section about the HTTP server 26 March 2014 Renamed led_test to test_led Added SFR and LEGO RC services for C to libspiagent so Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 47 of 49 Revision 1 10 8 April 2014 Added optional cmd prefix to the server query string Added trailing semicolon to the HTTP server response string Revision 1 11 3 June 2014 Added missing interrupt enable bit to the specification for SPIAGENT CMD CONFIGURE TIMER CAPTURE Added SPIAGENT CMD INIT TIMER and the corresponding C library function spiagent timer init Revision 12 6 June 2014 Renamed the library functions spiagent init to spiagent set frequency spiagent timer get counter tO spiagent timer get Revision 13 11 June 2014 Reference spi agent test in spi agent lib clients c instead of in spi agent Revision 14 25 June 2014 Added support for LEGO Power Functions Remote Control Combo Direct and Combo PWM commands Revision 15 7 October 2014 Changed the library function spiagent analog get to return float voltage measurement with range of 0 0 to 3 3 volts Changed the library function spiagent put to take float duty cycle value with range of 0 0 to 100 0 percent Mention PWM outputs in Table 1 Added section
30. cated by the command register pin field will be returned in the response message data field The response message error field will be set to ENODEV if the timer identifier is invalid 28 SPIAGENT CMD GET TIMER CAPTURE DELTA The difference between the last two capture values for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command register pin field will be returned in the response message data field The response message error field will be set to ENODEV if the timer identifier is invalid Note This service 15 useful for taking rudimentary frequency measurements by calculating the frequency from the time between pulse edges using 1 t 29 SPIAGENT CMD INIT TIMER The 1114 counter timer CT32BO or CT32B1 indicated by the command message pin field will be powered on and then initialized by writing zeros to all of the timer registers This service should be called in timer object constructors to guarantee proper initial state of the timer hardware Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 26 of 49 Language API Reference The following service functions are included libspiagent so to make application development for the LPC1114 I O Processor Expansion Board much easier All of these functions return an errno value the error parameter zero value returned in error indicates success all other values indicate failures unless noted below SPI Agent Transport
31. def struct uint32 t command uint32 t pin uint32 t data uint32 t error SPIAGENT RESPONSE MSG t SPI Agent Transport Service Functions spiagent open void spiagent open char servername int error This service opens connection to the specified SPI Agent Firmware server The servername parameter indicates the Raspberry PI SPI Agent Firmware server to use It has the following syntax http ioctl oncrpc xmlrpc hostname If the method http et al is omitted default method that is platform dependent will be used The default method for the Raspberry Pi is ioctl For other platforms the default method will depend on how libspiagent so was built but will typically be http Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 28 of 49 spiagent_command void spiagent command SPIAGENT COMMAND MSG t SPIAGENT RESPONSE MSG t resp int error This service issues a command message to the SPI Agent Firmware and retrieves a response message The cmd parameter is a pointer to SPIAGENT COMMAND MSG_t command message structure The resp parameter is a pointer to SPIAGENT RESPONSE MSG t response message structure spiagent close void spiagent close int error This service closes the connection to the SPI Agent Firmware server GPIO Type Definitions SPI Agent Firmware GPIO data directions typedef enum SPIAGENT GPIO INPUT SPIAGENT GPIO OUT
32. e of an LPC1114 timer s counter register The timer parameter selects which timer the counter value will be retrieved from Use values from spiagent timer id t The count parameter will be set to the current value of the counter register Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 38 of 49 spiagent timer get capture void spiagent timer get capture unsigned timer uint32 t count int error This service retrieves the current value of an LPC1114 timer s capture register i e the last value captured The timer parameter selects which timer the capture value will be retrieved from Use values from spiagent timer id The count parameter will be set to the current value of the capture register spiagent timer get capture delta void spiagent timer get capture delta unsigned timer uint32 t count int error This service retrieves the difference between the last two values captured in an LPC1114 timer s capture register It is useful for frequency measurement by using the equation f 1 t to derive the frequency of a pulse train from the time between successive edges The timer parameter selects which timer the capture value will be retrieved from Use values from spiagent timer id t The count parameter will be set to the difference between the last two captured values Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 39 of 49 LEGO Power Functions Remote Contr
33. e timeout parameter indicates how long in milliseconds po11 should wait A value of 1 indicates po11 should wait forever The Linux GPIO pin number 4 corresponding to INT on which the interrupt pulse was detected will be returned in pin An error value of ENODATA indicates the 11 timeout expired without receiving an interrupt pulse on INT Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 42 of 49 Raspberry GPIO Pin Assignments and Device Nodes The following Raspberry Pi expansion header GPIO pins are defined in include expansion lpc1114 h Raspberry Pi Pl Expansion Header GPIO pin assignments define define define define LPC1114 GPIO INT LPC1114 GPIO READY LPC1114 GPIO ISP LPC1114 GPIO RESE T 4 22 23 18 Note The above definitions are for Linux GPIO pin numbers not P1 header pin numbers nor LPC1114 GPIO pins The following device nodes actually symbolic links corresponding to the above GPIO pins are also defined in include expansion 1 1114 LPC1114 Processor Device node names define define define define LPC1114 GPIO Pin Assignments LPC1114 INT DEV LPC1114 READY DEV LPC1114 ISP DEV LPC1114 RESET DEV dev lpc1114 int dev lpc1114 ready dev lpclll4 isp dev lpc1114 reset The following LPC1114 I O pins are defined in include spi agent h or one of its subordinate header files LPC1114 Processor GPI
34. es 40000000 4007FFF and 50000000 501FFFFF LPC1114 peripheral registers accessible Reference the LPC111x LPC11Cxx User manual UM10398 for register details and exercise caution spiagent sfr get void spiagent sfr get uint32 t address uint32 t data int error This service reads from an LPC1114 special function register spiagent sfr put void spiagent sfr put uint32 t address uint32 t data int error This service writes to an LPC1114 special function register Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 41 of 49 Interrupt Services interrupt services are only available to program running directly on the Raspberry Pi with an LPC1114 I O Processor Expansion Board attached They are not available to remote client programs spiagent interrupt enable void spiagent interrupt enable int error This service enables interrupt monitoring on the rNT signal spiagent interrupt disable void spiagent interrupt disable int error This service disables interrupt monitoring on the INT signal spiagent interrupt wait void spiagent interrupt wait int timeout int pin int error This service calls po11 to wait for interrupt pulses from the LPC1114 microcontroller The calling program will be blocked by 11 and will consume no CPU time This is the preferred method for handling interrupts from Raspberry Pi GPIO pins for all but the most time critical applications Th
35. formance The output from spi agent test will resemble the following Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 12 of 49 Raspberry LPC1114 I O Processor Expansion Board SPI Agent Firmware Test Issuing some SPI transactions Response command 0 pin 0 data 7355 error 0 Response command 1 pin 2 data 3 error 0 Response 7 99 data 0 error 19 Response command 99 pin 2 data 0 error 22 The LPC1114 firmware version is 7355 The LPC1114 device ID is 1A40902B The expansion board LED is ON Starting 1000000 SPI agent loopback test transactions Performed 1000000 loopback tests in 173 seconds 5780 3 iterations per second 173 0 microseconds per iteration This indicates that each command to the SPI Agent firmware completes in 173 microseconds for a maximum of about 5780 commands per second Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 13 of 49 SPI Agent RPC Servers A further abstraction of the LPC1114 SPI Agent Firmware can be accomplished by wrapping it in an RPC Remote Procedure Call server There are two RPC servers programs available for the LPC1114 SPI Agent one for the ONC RPC formerly known as Sun RPC protocol and one for the XML RPC protocol Either of these servers can run on the Raspberry Pi to provide RPC services to client programs running on the Raspberry Pi itself or other computers connecting via the network ONC RPC Server
36. gnals Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 5 of 49 Around the LPC1114 I O Processor Expansion Board Raspberry Pi LPC1114 O KO e UTOR 4 9 e e e o From left to right 21 is 26 header Connect the supplied 26 conductor ribbon cable from 21 to the Raspberry P1 expansion header The LPC1114 I O Processor Expansion Board takes 3 3V power from the Raspberry Pi via the cable to J1 Above J1 are test point holes for 5V power and ground These are connected to the 5V power bus on the Raspberry Pi You can connect 5V power supply here to power both the Raspberry Pi and the LPC1114 I O Processor Expansion Board if desired eliminating the need to provide power to the Raspberry Pi via the micro USB connector Note The 5 0 test hole is connected directly to the Raspberry Pi 5V power bus bypassing the fuse on the Raspberry Pi micro USB connector This means there is no overcurrent or short circuit protection except that which be implemented within the external power supply This may be an advantage for embedded systems as you can probably use a USB WiFi network interface without a powered USB hub Continuing D1 is an LED Light Emitting Diode controlled by the LPC1114 7 GPIO pin The LED can be turned on and off from LPC1114 firmware for debugging or signaling purposes One example of LED usage would be to blink
37. his service are LPC1114 1 4 Note LPC1114 1 3 share the same clock generator so setting the pulse frequency on any one of the channels always affects all three channels LPC1114 PWM4 can be configured for a different pulse frequency 6 SPIAGENT CMD GET ANALOG The response message data field will be set to the unsigned 10 bit analog value 3 22 millivolts per step corresponding to the analog input voltage at the LPC1114 analog input pin indicated by the command message pin field The command message data field is ignored The response message error field will be set to ENODEV if the selected pin is not a valid analog input pin Valid pins for this service are LPC1114 ADC1 5 7 SPIAGENT CMD GPIO The response message data field will be set to the state of the LPC1114 GPIO pin indicated by the command message pin field The command message data field is ignored The response message error field will be set to ENODEV if the selected pin is not a valid GPIO pin Valid pins for this service are LPC1114 GPIO0 7 LPC1114 INT and LPC1114 LED Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 20 of 49 8 SPIAGENT CMD GPIO The LPC1114 GPIO output pin indicated by the command message pin field is set to the state indicated by the command message data field The response message error field will be set to ENODEV if the selected pin is not valid GPIO pin or to EINVAL if the data value is ou
38. n two git repositories hosted by SourceForge arm mcu ARM Microcontroller Framework and rpi mcu Raspberry Pi Microcontroller Framework Checkout copies of arm mcu and rpi mcu using the following commands git clone http git munts com arm mcu git git clone http git munts com rpi mcu git Note arm mcu is only necessary if you intend to write new firmware for the LPC1114 microcontroller You do not need to clone arm mcu if you will only use the factory default SPI Agent firmware for the LPC1114 microcontroller After you have cloned the azm mcu and rpi mcu repositories you will need to run a final script to install the various scripts kernel modules and utility programs for the Raspberry Pi LPC1114 I O Processor Expansion Board HOME rpi mcu expansion LPC1114 src scripts expansion 1 1114 install Step Four Upgrade SPI Agent Firmware Run the following commands to flash the latest firmware to the LPC1114 microcontroller on the LPC1114 I O Processor Expansion Board usr local libexec expansion 1 1114 flash Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 10 of 49 Software Updates From time to time additions corrections and bug fixes will be made to arm mcu and rpi mcu To import the latest LPC1114 I O processor support software changes to your Raspberry Pi run the following command sequence cd HOME arm mcu git pull cd HOME rpi mcu git pull cd HOME rpi mcu expansion LPC1114 src
39. nload and install the software components for LPC1114 I O Processor Expansion Board development Quick Setup For the Impatient To install of the run time and firmware development support for the LPC1114 I O Processor Expansion Board with a single command run the following command on the Raspberry Pi Linux command line instead of following Steps One Four below wget q http goo gl 7wtzx sh lt 7wtzx Step One Install Linux Packages Run the following commands on the Raspberry Pi Linux command line to install the necessary packages sudo apt get update sudo apt get install install git libcurl4 openssl dev libncurses5 dev libxmlrpc core c3 dev Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 9 of 49 Step Two Install the ARM Microcontroller Cross Compiler Toolchain Note This step 15 only necessary if you intend to write new firmware for the LPC1114 microcontroller You do not need to perform this step if you will only use the factory default SPI Agent firmware for the LPC1114 microcontroller Run the following commands to install the ARM microcontroller cross compiler toolchain wget http tech munts com MCU Frameworks ARM toolchain arm mcu tools latest Linux armv61 tgz sudo tar xzf arm mcu tools latest Linux armv6l tgz directory usr local Step Three Download Support Software Most of the software you will need for development for the LPC1114 I O Processor Expansion Board resides i
40. ol Type Definitions typedef enum LEGORC_ALLSTOP LEGORC MOTORA LEGORC MOTORB LEGORC COMBODIRECT LEGORC COMBOPWM LEGORC MOTOR SENTINEL legorc motor id t typedef enum LEGORC REVERSE LEGORC FORWARD LEGORC DIRECTION SENTINEL legorc direction id LEGO Power Functions Remote Control Services spiagent legorc put void spiagent legorc put unsigned pin unsigned channel unsigned motor unsigned direction unsigned speed int error This service transmits a LEGO Power Functions RC command out the specified GPIO output pin driving an infrared emitter which must have been previously configured as an output with spiagent gpio configure pin parameter must be LPC1114 GPIOO0 through LPC1114 GPIOT The channel parameter must be 1 through 4 The motor parameter must be 0 through 4 All Stop Motor A Motor B Combo Direct Combo PWM The direction parameter must be 0 for reverse or 1 for forward for Motor or Motor and 0 for all other motor values The speed parameter must be 0 through 7 for Motor or Motor 0 15 for Combo Direct and 0 255 for Combo PWM Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 40 of 49 Special Function Register Services Special Function Registers are 32 bit wide peripheral registers in the LPC1114 address space These services allow reading from and writing arbitrary data to LPC1114 peripheral registers Only addresses in the rang
41. pins 0 pull down 1 pull up Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 30 of 49 spiagent gpio configure mode void spiagent gpio configure mode unsigned pin unsigned mode int error This service also configures an LPC1114 GPIO pin It allows configuring an input as high impedance or an output as open drain It does not allow setting the initial state of an output pin The pin parameter indicates the pin to configure The mode parameter indicates how to configure the pin Use values from SPIAGENT GPIO MODE t spiagent gpio configure interrupt void spiagent gpio configure interrupt unsigned pin unsigned intconfig int error This service configures an LPC1114 GPIO input pin interrupt The pin parameter indicates the pin to configure The intconfig parameter indicates how to configure the interrupt Use values from SPIAGENT GPIO INTERRUPT CONFIG t spiagent gpio get void spiagent gpio get unsigned pin unsigned state int error This service reads the state of a GPIO input or output pin The pin parameter indicates the pin to read from The state parameter will be set to the current state of the GPIO pin spiagent gpio put void spiagent gpio put unsigned pin unsigned state int error This service writes to a GPIO output pin The pin parameter indicates the pin to write to The state parameter 0 or 1 indicates the level to write to the pin Raspberry Pi LPC1114 I
42. re mode void spiagent timer configure mode unsigned timer unsigned mode int error This service configures an LPC1114 timer s operating mode and clock source The timer parameter selects which timer to configure Use values from spiagent timer id t The mode parameter selects the whether the timer is disabled held in reset or clocked from the LPC1114 internal system peripheral clock signal PCLK or from the CAPO capture input pin Use values from spiagent timer mode t Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 36 of 49 spiagent timer configure 1 void spiagent timer configure prescaler unsigned timer uint32 t divisor int error This service configures an LPC1114 timer s prescale counter The timer parameter selects which timer to configure Use values from spiagent timer id t The divisor parameter sets the prescale counter divisor Allowed values are 1 through 222 1 0x00000001 through OxFFFFFFFF spiagent timer configure capture void spiagent timer configure capture unsigned timer unsigned edge bool intr int error This service configures an LPC1114 timer s capture feature If a counter capture event is triggered by a transition at the capture input pin CAPO the value of the counter register TC at that instant is copied to the capture register CRO The timer parameter selects which timer to configure Use values from spiagent timer id t The edge p
43. rry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 14 of 49 Python language comes with XML RPC support built in using the xmlrpc module The simplest Python client for SPI Agent XML RPC that executes a single loopback test command would be like this usr bin python3 import xmlrpc client s xmlrpc client ServerProxy http localhost 8080 RPC2 print s system listMethods print s spi agent transaction 1 2 3 A somewhat more elaborate Python client for SPI Agent XML RPC which includes the ability to select the server network address is available in the directory SHOME rpi mcu expansion LPC1114 src spi agent xmlrpc clients python HTTP Server There is also an HTTP server that although not strictly an RPC server is used exactly in the same manner Some programming languages may not have support for either ONC RPC or XML RPC but do have support for HTTP Microsoft Small Basic is one example Free Pascal for Windows is another The HTTP server syntax is simple Append a query string composed of an optional cmd and 3 integers separated by commas command pin data to the URL The following example illustrates how to turn on the LED on a Raspberry Pi with the domain name zoar munts net http zoar munts net 8081 SPIAGENT 8 7 1 The HTTP server returns a minimal web page containing a response string which is composed of 5 integers separated by commas ioctl error command pin data error
44. rver firmware MuntsOS is a very small less than 32 MB embedded Linux distribution based on BusyBox and other components Muntsos is delivered as a Single Linux kernel image file which also contains the root file system using the initramfs facility After the Linux kernel has booted the system runs entirely from RAM There are several advantages to this especially for remote and or headless embedded systems Boot time is significantly faster File system access is very fast Risk of SD card corruption is minimized No need to perform an orderly shutdown At boot time the Muntsos environment be extended by extension modules which are executable shell archive scripts installed in the directory autoexec d on various media such as the SD card boot partition USB mass storage device USB CD ROM or an NFS mount Just download http tech munts com rpi lpc1114 src muntsos muntsos lpc1114 RaspberryPi zip extract it to a freshly formatted FAT32 SD card and insert it into the Raspberry Pi You can then modify autoexec d 00 wlan RaspberryPi on the SD card to customize it for your wireless network environment if desired For more information about MuntsOS see http tech munts com rpi Ipc1114 src muntsos http tech munts com MCU Frameworks ARM Linux Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 17 of 49 SPI Agent Firmware Reference The authoritative source for information
45. such as the Radio Shack 270 1807 or 270 1809 Halt and power off your Raspberry Pi before connecting the LPC1114 I O Processor Expansion Board to it Connect the supplied 26 pin ribbon cable from the J1 header on the LPC1114 I O Processor Expansion Board to the P1 expansion header on the Raspberry The colored stripe on the ribbon cable should oriented to pin 1 on both the Raspberry Pi and the I O Processor Expansion Board See figure 2 below Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 8 of 49 Software Support To develop software for the LPC1114 I O Processor expansion board you will need to install several items on your Raspberry Pi Certain Linux packages cross compiler toolchain compiler assembler linker librarian debugger A microcontroller firmware framework Run time startup linker scripts I O libraries etc e A flash programming utility program to update the firmware within the LPC1114 No extra hardware is required to program flash Sample programs specific to the LPC1114 I O Processor Expansion Board All of these items will be installed by the following procedure It assumes you are running the Raspbian Wheezy image downloaded from www raspberrypi org Other Linux distributions may require adjustment to the procedure With Pidora subsitute yum for apt get for example Your Raspberry Pi will need to be connected to the Internet in order to dow
46. t of range not 0 or 1 Valid pins for this service are LPC1114 GPIO0 7 LPC1114 INT and LPC1114 LED 9 SPIAGENT CMD PUT PWM The LPC1114 PWM output pin indicated by the command message pin field will be set to the 16 bit duty cycle indicated by the command message data field A level of 0 indicates minimum duty cycle at the PWM output and value of 65535 indicates maximum duty cycle at the PWM output Note The actual resolution of the duty cycle varies depending on the pulse frequency from full 16 bits at low frequencies to as little as 6 bits at higher frequencies The response message error field will be set to ENODEV if the selected pin is not a PWM output or to EINVAL if the data value is out of range Valid pins for this service are LPC1114 1 4 10 SPIAGENT CMD CONFIGURE GPIO INTERRUPT The LPC1114 GPIO input pin indicated by the command message pin field is configured as an interrupt input causing an interrupt pulse to the Raspberry Pi out LPC1114 INT according to configuration in the command message data field The following interrupt configurations are available 0 SPIAGENT GPIO INTERRUPT DISABLED Interrupts are disabled default 1 SPIAGENT GPIO INTERRUPT FALLING Falling edge causes interrupt 2 SPIAGENT GPIO INTERRUPT RISING Rising edge cause interrupt 3 SPIAGENT GPIO INTERRUPT BOTH Both edges cause interrupts The response message error field will be set to ENODEV if the selected pin is not a valid GPIO inp
47. the LED whenever the Raspberry Pi sends a command message to the LPC1114 22 is a 4 pin header not populated for SWD Serial Wire Debug You can solder header pins here and connect a SWD debug pod such as the SEGGER J Link to 22 to perform source level debugging with gdb Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 6 of 49 Adjacent to 22 test point holes for 3 3V power and ground 3 3V power comes from the Raspberry Pi s voltage regulator not attempt to take more than few milliamperes from it or you will overload the Raspberry Pi J3 the 10 position terminal block is on the right edge of the board 3 3V power ground and 8 114 GPIO pins are brought out to 23 3 3V power supply comes from the Raspberry Pi s voltage regulator Do not attempt to take more than few milliamperes from it or you will overload the Raspberry Pi Each of the LPC1114 GPIO pins brought out to 23 may be configured for variety of purposes See Table 1 See the LPC1114 datasheet and user manual documents from NXP for more information about GPIO pin functions LPC1114 P1 0 General Purpose Input Output 0 Analog Input 1 32 bit Timer 1 Capture Input 0 LPC1114 GPIO1 P1 1 General Purpose Input Output 1 Analog Input 2 Pulse Width Modulated Output 1 32 bit Timer 1 Match Output 0 LPC1114 GPIO2 P1 2 General Purpose Input Output 2 Analog Input 3 Pulse
48. tions are available 0 SPIAGENT TIMER MATCH OUTPUT DISABLED 1 SPIAGENT TIMER MATCH OUTPUT CLEAR 2 SPIAGENT TIMER MATCH OUTPUT SET 3 SPIAGENT TIMER MATCH OUTPUT TOGGLE The response message error field will be set to ENODEV if the timer identifier is invalid or to EINVAL if any of the settings are invalid Note The match output pins for CT32BO are not available so the only allowed match output action for it 15 SPIAGENT TIMER MATCH OUTPUT DISABLED 22 SPIAGENT CMD CONFIGURE TIMER MATCHO VALUE 23 SPIAGENT CMD CONFIGURE TIMER MATCH1 VALUE 24 SPIAGENT CMD CONFIGURE TIMER MATCH2 VALUE 25 SPIAGENT CMD CONFIGURE TIMER MATCH3 VALUE The command message data field will be written to the corresponding match register MRO 3 for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command message pin field The response message error field will be set to ENODEV if the timer identifier is invalid 26 SPIAGENT CMD GET TIMER VALUE The current value in the counter register for the LPC1114 counter timer CT32BO or CT32B1 indicated by the command register pin field will be returned in the response message data field The response message error field will be set to ENODEV if the timer identifier is invalid Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 25 of 49 27 SPIAGENT CMD TIMER CAPTURE The current value in the capture register CRO for the LPC1114 counter timer CT32BO or CT32B1 indi
49. ut pin or to EINVAL if the command message data field is invalid Valid pins for this service are LPC1114 GPIO0 7 Raspberry Pi LPC1114 I O Processor Expansion Board User Guide Rev 26 Page 21 of 49 11 SPIAGENT CMD CONFIGURE GPIO The LPC1114 GPIO pin indicated by the command message pin field will be configured according to the configuration indicated by the command message data field The following GPIO configurations are available 0 SPIAGENT GPIO MODE INPUT High impedance input 1 SPIAGENT GPIO MODE INPUT PULLDOWN Input with weak pull down resistor 2 SPIAGENT GPIO MODE INPUT PULLUP Input with weak pull up resistor 3 SPIAGENT GPIO MODE OUTPUT Push pull sink or source output 4 SPIAGENT GPIO MODE OUTPUT OPENDRAIN Open drain sink only output The response message error field will be set to ENODEV if the selected pin is not a valid GPIO pin or to EINVAL if the command message data field is invalid Valid pins for this service LPC1114 GPIO0 7 LPC1114 INT LPC1114 LED The interrupt and LED pins can only be configured as push pull outputs 12 SPIAGENT CMD PUT LEGORC LEGO Power Functions Remote Control command will be emitted from the LPC1114 GPIO output pin indicated by the command message pin field The message parameters are encoded in the command message data field as follows Bits 0 7 Speed Motor A or Motor B 0 7 Combo Direct 0 15 Combo PWM 0 255 Bits 8 15 Direction Motor A or Motor B O Reverse 1 Forw
Download Pdf Manuals
Related Search
Related Contents
manuel d`utilisation modèles sur table modeles speciaux Pittsburgh Corning 100745.0 Instructions / Assembly Users Manual - CNET Content Solutions LG LW2513ER Specification Sheet Quatech DSPR-100 HP No.80 Ink Supplies Troubleshooting USER MANUAL V1.4 Global Safety & Security Solutions Oy www Manual de Usuario SIMTO 2010年9月 No.87 www . relpol .com.pl Copyright © All rights reserved.
Failed to retrieve file