Object <- Server <- HardwareStream <- MagicBus |
|
|
MaxRxBaudRate MaxRxByteRate MaxTxBaudRate MaxTxByteRate |
| Field | Type | |
|---|---|---|
| Server: | enabled: | Boolean |
| Stream: | target: | Object |
| HardwareStream: | state: | Unsigned |
| readRate: | Unsigned | |
| writeRate: | Unsigned | |
| maxReadRate: | Unsigned | |
| maxWriteRate: | Unsigned | |
| defaultTimeout: | Unsigned | |
| UsesExtraPower: | microampLoad: | Signed |
| CanPreventSleep: | dozeCount: | Signed |
| sleepCount: | Signed | |
| MagicBus: | globalsID: | Object |
| magicBusActor: | Object | |
| totalMagicBusCurrent: | Signed | |
| magicBusTimer: | Object | |
| totalNumberOfFailures: | Unsigned | |
| maxTxBaudRate: | Unsigned | |
| maxRxBaudRate: | Unsigned | |
| maxTxByteRate: | Unsigned | |
| maxRxByteRate: | Unsigned |
instance MagicBus tag; enabled: false; target: nilObject; state: 0; readRate: 0; writeRate: 0; maxReadRate: 0; maxWriteRate: 0; defaultTimeout: 0; microampLoad: 0; dozeCount: 0; sleepCount: 0; globalsID: nilObject; magicBusActor: nilObject; totalMagicBusCurrent: 0; magicBusTimer: nilObject; totalNumberOfFailures: 0; maxTxBaudRate: 0; maxRxBaudRate: 0; maxTxByteRate: 0; maxRxByteRate: 0; end instance;
#endif Define Class MagicBus; inherits from HardwareStream; inherits from HasReinitialize, WantsPowerEvents, UsesExtraPower, CanPreventSleep; field globalsID: Object; field magicBusActor: Object; field totalMagicBusCurrent: Signed; // Total current that can be supplied by this master device in micro-amps field magicBusTimer: Object; field totalNumberOfFailures: Unsigned; field maxTxBaudRate: Unsigned, getter; // Maximum Transmit baud rate for this implementation. field maxRxBaudRate: Unsigned, getter; // Maximum Receive baud rate for this implementation. field maxTxByteRate: Unsigned, getter, setter; // Maximum Transmit byte rate (bytes/second) (lesser of DMA rate and baud rate divided by 8). field maxRxByteRate: Unsigned, getter, setter; // Maximum Receive baud rate (bytes/second) (lesser of DMA rate and baud rate divided by 8). attribute MaxTxBaudRate: Unsigned, readOnly; // Maximum Transmit baud rate for this implementation. attribute MaxRxBaudRate: Unsigned, readOnly; // Maximum Receive baud rate for this implementation. attribute MaxTxByteRate: Unsigned; // Maximum Transmit byte rate (bytes/second) (lesser of DMA rate and baud rate). attribute MaxRxByteRate: Unsigned; // Maximum Receive baud rate (bytes/second) (lesser of DMA rate and baud rate). overrides ReleaseHardware; // Relinquishes all hardware and shuts down all MagicBus OS support overrides ReinitializeClass, ResetClass; // Sets up all hardware, creates buffers, etc to handle all future transactions overrides CanSleep; overrides Instances; // Returns actual number of instances of "MagicBus_" Objects. overrides MaxInstances; // Returns maximum number of instances of "MagicBus_" Objects. overrides PoweringDown, PoweringUp, MainBatteryIsLow, MainBatteryIsGood; // Informs peripherals of power changes and look for peripherals on powerup operation InitializeMagicBus(): Boolean; // Resets MagicBus. Creates clients for and initializes all attached peripherals. operation DispatchPeripheralRequests(); // Disptaches all Pending peripherals requests to appropriate MagicBusClients operation ServiceMagicBus(): Boolean; // Handles all pending communication to and from MagicBus Async routines operation HandleAttachedPeripherals(): Unsigned; // Install and initialize peripherals which were just added onto the bus operation AssignMagicBusAddresses(firstNewPeriphNumber: UnsignedByte): Unsigned; // Performs Address Assign and Assign Last for all peripherals on the bus operation AssignMagicBusAddress(periphNumber: UnsignedByte): Boolean; // Performs an Address Assign to the specified peripheral address, // returns a MagicBus error code operation PeripheralsAttached(firstNewPeriphNumber: UnsignedByte): Unsigned; // Performs initialization of currently attached peripherals operation LoadMagicBusClient(curAddr: Unsigned); // Upload Client software from the peripheral. operation UpdateMagicBusPeripheralInfo(client: MagicBusClient; var peripheralInfo: MagicbusPeripheralInfo); // Fill in the rest of the pInfo block operation SetMagicBusRealtimeMode(client: MagicBusClient; realtimeState: Boolean); // Sets/Clears realtime mode for the peripheral. operation RealtimePeripheralCount(): Unsigned; // Updates and returns number of peripherals in realtime mode. operation UpdateMaximumBlockLength(); // Determine largest block that can be transfered to/from each peripheral // based on maxMBReqLineLatency of all peripherals and the transfer rate of the // specific peripheral. operation UpdateMagicBusPowerConsumption(); // Calculate total power consumption of all peripherals on the bus. operation HandleDetachedPeripherals(): Unsigned; // Remove and Destory peripheral which where just removed from the bus operation HandleMagicBusFailure(); // When a communications error occur, this will attempt to recover operation VerifyMagicBus(): Boolean; // Checks communication to all peripherals and returns true if the bus // is properly configured operation GetPeripheralID(peripheralNumber: UnsignedByte): Unsigned; // Request ID from peripheral, and returns that ID. operation PeripheralIDAttached(peripheralID: Unsigned): Object; // Returns ObjectList of all Clients of peripherals on the bus with the // requested PeripheralID (all Clients if peripheralID is nil), // or nil if there are none. operation MaximumBlockLength(client: MagicBusClient; forSend: Boolean): Unsigned; // Returns current maximum block lengths for send/get. operation SendMagicBusCmd(client: MagicBusClient; mbCmd: Unsigned; response: UnsignedArrayPointer; var count: Unsigned); // Issues Magic Bus command to the client's periperhal. On Get commands, // number of actual bytes received is returned in count. operation SendMagicBusCmdNoWait(client: MagicBusClient; mbCmd: Unsigned; response: UnsignedArrayPointer; var count: Unsigned; var statusPointer: UnsignedByte; completionFunc: CompletionFunction; completionFuncParams: Pointer); // Issues Magic Bus command to the client's periperhal. On Get commands, // number of actual bytes received is returned in count. operation NumberofClients(): Unsigned; // Returns number of peripherals connected. // Some peripherals may not have valid info or a client object associated with it. operation Client(periphNumber: Unsigned): Object; // Returns client Reference for specified MagicBus peripheral, // if there is one associated with the peripheral. operation PeripheralInfo(client: MagicBusClient; var pInfo: MagicbusPeripheralInfo; var periphNumber: UnsignedByte); // Get peripheral information block from clients peripheral. end class;