Documentation ¶
Overview ¶
Copyright © 2019 Erin Shepherd
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Erin Shepherd ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Erin Shepherd ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package protocol defines and implements the NuLink communications protocol
Index ¶
- Constants
- Variables
- type ChipFamily
- type Config
- type Device
- func (d *Device) CheckID() (DeviceID, error)
- func (d *Device) Close()
- func (d *Device) EraseFlashChip() error
- func (d *Device) GetVersion() (VersionInfo, error)
- func (d *Device) MaxPayloadSize() int
- func (d *Device) Path() string
- func (d *Device) ReadMemory(space MemorySpace, address uint16, length uint8) ([]byte, error)
- func (d *Device) Receive() ([]byte, error)
- func (d *Device) Request(body []byte) ([]byte, error)
- func (d *Device) Reset(r Reset) error
- func (d *Device) Send(body []byte) error
- func (d *Device) SetConfig(c Config) error
- func (d *Device) UnknownA5() error
- func (d *Device) WriteMemory(space MemorySpace, address uint16, data []byte) error
- type DeviceID
- type FirmwareVersion
- type Frame
- type Framer
- type MemorySpace
- type ProductID
- type Reset
- type ResetConnType
- type ResetMode
- type ResetType
- type V1Frame
- type V1Framer
- type VersionInfo
Constants ¶
const ( // M2351 family (taken from Nuvoton's OpenOCD patch) ChipFamilyM2351 = 0x321 ChipFamily8051 = 0x800 )
const ( // N76E003, Observed in trace // // Matches IAP registers: // 0x00CCDDDD where // CC = Company ID // DDDD = Device ID DeviceN76E003 = 0xDA3650 DeviceMS51FB9AE = 0xDA4B21 )
const FlagIsNulinkPro = 0x00000001
Variables ¶
var ( ErrWriteSizeIncorrect = errors.New("Write of incorrect size") ErrReadSizeIncorrect = errors.New("Read of incorrect size") ErrSequenceNumberIncorrect = errors.New("Incorrect sequence number") )
var ErrBodyLengthTooLong = errors.New("Body length too long")
var ErrFrameLengthIncorrect = errors.New("Frame length incorrect")
var ErrTooShortForCommand = errors.New("Frame too short to contain command")
Functions ¶
This section is empty.
Types ¶
type ChipFamily ¶
type ChipFamily uint32
func (ChipFamily) String ¶
func (f ChipFamily) String() string
type Config ¶
type Config struct { Clock uint32 ChipFamily ChipFamily Voltage uint32 PowerTarget uint32 USBFuncE uint32 }
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func (*Device) EraseFlashChip ¶
func (*Device) GetVersion ¶
func (d *Device) GetVersion() (VersionInfo, error)
func (*Device) MaxPayloadSize ¶
func (*Device) ReadMemory ¶
func (*Device) WriteMemory ¶
func (d *Device) WriteMemory(space MemorySpace, address uint16, data []byte) error
type FirmwareVersion ¶
type FirmwareVersion uint32
const ( FirmwareVersion6909 FirmwareVersion = 6069 FirmwareVersionRequired = FirmwareVersion6909 )
func (FirmwareVersion) String ¶
func (v FirmwareVersion) String() string
type Framer ¶
type Framer interface { FrameLength() int MaxBodyLength() int Frame(seqno byte, body []byte) (Frame, error) Unframe(pkg []byte) (Frame, error) }
func NewV1Framer ¶
func NewV1Framer() Framer
type MemorySpace ¶
type MemorySpace uint16
const ( ProgramSpace MemorySpace = 0x0000 ConfigSpace MemorySpace = 0x0003 )
func (MemorySpace) String ¶
func (s MemorySpace) String() string
type Reset ¶
type Reset struct { Type ResetType Connection ResetConnType Mode ResetMode }
type ResetConnType ¶
type ResetConnType uint32
Type of connection after reset. Constants taken from OpenOCD patch
const ( ConnectNormal ResetConnType = 0 ConnectPreReset ResetConnType = 1 ConnectUnderReset ResetConnType = 2 ConnectNone ResetConnType = 3 ConnectDisconnect ResetConnType = 4 ConnectICPMode ResetConnType = 5 )
func (ResetConnType) String ¶
func (ct ResetConnType) String() string
type V1Framer ¶
type V1Framer struct{}
func (V1Framer) FrameLength ¶
func (V1Framer) MaxBodyLength ¶
type VersionInfo ¶
type VersionInfo struct { FirmwareVersion FirmwareVersion ProductID ProductID Flags uint32 // [NuLink pro only] Target voltage TargetVoltage uint16 // [NuLink pro only] USB voltage USBVoltage uint16 }
func (VersionInfo) String ¶
func (vi VersionInfo) String() string