Hardware interface description:
The J2304 socket on the motherboard corresponds to the SPI1 of the CPU, and the socket wiring sequence is explained as follows:
Serial Number | Description | Remarks |
---|---|---|
1 | VCC | 3.3V power supply |
2 | CLK | SPI clock |
3 | MOSI | |
4 | MISO | |
5 | CS | Film Selection |
6 | GND | Power ground |
1.1 SPI has four modes, as follows:
The different combinations of CPOL (clock polarity) and CPHA (clock phase) form different modes of the SPI bus. Different SPI slave devices support different modes
Mode | CPOL | CPHA |
---|---|---|
Mode 1 | 0 | 0 |
Mode 2 | 0 | 1 |
Mode 3 | 1 | 0 |
Mode 4 | 1 | 1 |
1.2 Sample timing chart
Adding method: Please refer to the following section of the "Windows Driver Development" description. Here, only the ASL code that needs to be added is indicated. The key information is annotated in Chinese and modified according to the actual hardware. It should be emphasized that Chinese cannot appear in the formal ASL code, and the Chinese annotations should be removed or replaced with English annotations
Add an SPI device to the following ASL code, and modify the key three items according to the actual situation:
Project | Description Value | Remarks |
---|---|---|
Device driver ID | SPI1001 | The associated hardware ID corresponding to the driver program |
SPI mode | Here are four modes listed, select the corresponding mode based on the slave device, and mask the other three modes | |
SPI rate | 0X89544 | SPI rate, here is 562.5k |
Scope (_SB.PC00.SPI1)
{
Device (SSPI)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "SPI1001") // _HID: Hardware ID
Name (_CID, "SPI1001") // _CID: Compatible ID
Name (_UID, "SPI1001") // _UID: Unique ID
Method(_CRS, 0x0, NotSerialized)
{
Name (RBUF, ResourceTemplate ()
{
// ---model 0--- 562.5k=0X89544
SpiSerialBus (0x0000, PolarityLow, FourWireMode, 0x08,ControllerInitiated, 0X89544, ClockPolarityLow,ClockPhaseFirst,
"\\_SB.PC00.SPI1", 0x00, ResourceConsumer, , )
// ---model 1---
// SpiSerialBus (0x0000, PolarityLow, FourWireMode, 0x08,ControllerInitiated, 0X89544, ClockPolarityLow,ClockPhaseSecond,
// "\\_SB.PC00.SPI1", 0x00, ResourceConsumer, , )
// ---model 2---
// SpiSerialBus (0x0000, PolarityLow, FourWireMode, 0x08,ControllerInitiated, 0X89544, ClockPolarityHigh,ClockPhaseFirst,
// "\\_SB.PC00.SPI1", 0x00, ResourceConsumer, , )
// ---model 3---
// SpiSerialBus (0x0000, PolarityLow, FourWireMode, 0x08,ControllerInitiated, 0X89544, ClockPolarityHigh,ClockPhaseSecond,
// "\\_SB.PC00.SPI1", 0x00, ResourceConsumer, , )
})
Return(RBUF)
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
}
}
After adding SPI devices to the BIOS, you can view them from the Device Manager: Unknown devices, corresponding hardware IDs, and descriptions in the ASL code_ Same as HID (SPI1001)
We will provide an SPI driver and add the hardware ID SPI1001 to the driver installation file "SpbDriver. inf". The full text of the driver file is as follows:
[Version]
Signature = "$WINDOWS NT$"
Class = HIDClass
ClassGuid ={745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Provider = %ProviderName%
DriverVer = 08/13/2023,16.5.5.7
CatalogFile = SpbDriver.cat
PnpLockdown = 1
[DestinationDirs]
DefaultDestDir = 13
[SourceDisksNames]
1 = %DiskId1%,,,""
[SourceDisksFiles]
SpbDriver.sys = 1,,
[Manufacturer]
%StdMfg%=Standard,NTamd64
[Standard.NTamd64]
%SpbDriver.DeviceDesc%=SpbDriver_Device, ACPI\25DV0053
%SpbDriver1.DeviceDesc%=SpbDriver_Device, ACPI\25DV0057
%SpbDriver2.DeviceDesc%=SpbDriver_Device, ACPI\I2C30001
%SpbDriver3.DeviceDesc%=SpbDriver_Device, ACPI\SPI1001
[SpbDriver_Device.NT]
CopyFiles=Drivers_Dir
[SpbDriver_Device.NT.HW]
AddReg=SpbDriver_AddReg
[Drivers_Dir]
SpbDriver.sys
[SpbDriver_AddReg]
HKR,Settings,"ConnectInterrupt",0x00010001,1
[SpbDriver_Device.NT.Services]
AddService = SpbDriver,%SPSVCINST_ASSOCSERVICE%, SpbDriver_Service_Inst
[SpbDriver_Service_Inst]
DisplayName = %SpbDriver.SVCDESC%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %13%\SpbDriver.sys
[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ProviderName = "www.youyeetoo.com"
StdMfg = "(Standard system devices)"
DiskId1 = "SPB Driver Peripheral Installation Disk #1"
SpbDriver.DeviceDesc = "25DV0053 NFC I2C4 Address 0X53"
SpbDriver.SVCDESC = "SPB Driver Peripheral desc"
SpbDriver1.DeviceDesc = "25DV0057 NFC I2C4 Address 0X57"
SpbDriver2.DeviceDesc = "I2C30001 Address 0X50"
SpbDriver3.DeviceDesc = "SPI1001 Driver"
ClassName = "I2C"
The two most critical lines in the file, which are also modified according to the actual situation, are as follows:
[Standard.NTamd64]
%SpbDriver3.DeviceDesc%=SpbDriver_Device, ACPI\SPI1001
[Strings]
SpbDriver3.DeviceDesc = "SPI1001 Driver"
If the system you are installing is not the firmware we released, then you need the content in this section. If you are using our system, it defaults to the driver, which can be skipped
After modifying the above steps, right-click on the "SpbDriver. inf" file and select "Install". The system will prompt you with "Always Install Driver". After a while, a successful installation pop-up window will appear. In the "Human Machine Interface Device" section of the Device Manager, you can see that the SPI device driver has been successfully installed.
We provide a C # sample program to demonstrate SPI read and write testing, as shown in the figure
|Note: The SPI slave device communication mode and communication rate need to be set and modified in the motherboard ASL CODE
Operation process:
SPI Write Only ": Write only but not read, this operation needs to be selected based on the communication timing of the slave device
SPI write first read later ": Write data to the slave device first, and then read data. This operation needs to be selected based on the communication timing of the slave device
SPI synchronous write read ": Write data to the slave device while reading data from the device. This operation needs to be selected based on the communication timing of the slave device
The USB to SPI slave module can be used to simulate the SPI slave, as shown in the figure:
The module is connected to the computer USB, SPI related pins, and development connections are as follows:
Main board J2304 interface wire sequence | Purpose | Analog module labeling 1 and 4 |
---|---|---|
1 | VCC | Not connected: because the module has been powered on and does not need to be connected to the power supply of the development board |
2 | CLK | SCK |
3 | MOSI | MOSI |
4 | MISO | MISO |
5 | CS | CS |
6 | GND | GND |
Configure the software on the computer, as shown in the parameter section on the left side of the figure: Set USB to SPI slave mode, frame format: MSB, SPI mode: Mode 00, and then click "Set Parameters",The mode 00 here should correspond to the mode used in the motherboard ASL CODE one by one, otherwise there may be communication data issues
On the development version of the SPI testing software, after connecting the SPI device, click "SPI Synchronous Write Read" and you will see that the SPI simulation slave software will receive data sent by the testing software and return the synchronously read data. Synchronous read write will delay the simulation device software by one byte (see the simulation software description for details)
Test software download
Execution File
driver
Download testing software source code
Source Code
6.1 If it were not for the Windows system installation package we provided, install other versions of Windows systems on your own, and the system defaults to the SPI driver, the SPI node cannot be found in the "Human Input Device"
The processing method is as follows:
Uninstall the default SPI chip driver for the system first: In "System Devices", locate the "Intel (R) SPI (flash) Controller -4DA4“
After uninstalling the default SPI chip driver of the system, you need to replace it with the SPI chip driver we provided(There are 2 folders in the driver package that require installing the SPI driver before installing the chip driver). After replacing it, restart the Windows system to see the SPI node.
SPI chip driver V3