A kind of communication means of single-wire bus system
Technical field
The present invention relates to bus field, more particularly to a kind of communication means of single-wire bus system.
Background technology
Traditional communications bus is all made up of multi-thread, and such as I2C, C2, USB, UART respectively has two
Line, is more made up of tetra- lines of SPI, I2S, and on processor of single chip computer, every line all has to occupancy one
Individual I/O port, multi-thread communication make the area of chip just become big, cause the great wasting of resources, so that chip
Cost increase.
In order to solve the multi-thread waste for causing, usually using the communication mode of single line, communication interface reaches people
Most save, saved general purpose data port resource.
The defect of prior art is:On existing single-wire bus system after electricity, in single-wire bus system communication
Loitering phase adopts high frequency clock, causes the waste of power consumption.
The content of the invention
The invention provides a kind of communication means of single-wire bus system, it is intended to solve existing design in list
The loitering phase of line bus system communication causes the technical problem of the waste of power consumption using high frequency clock.
The present invention is achieved in that a kind of communication means of single-wire bus system, wherein single-wire bus system
Including at least one main device and at least one from device, the main device and it is described from device by single line it is total
Line is communicated, it is characterised in that the communication means of the single-wire bus system includes:
A. it is described to judge whether the single bus are more than or equal to preset duration in the persistent period from equipment
The first level, if so, then execution step B;
B. it is described to judge whether the main device sends open signal from equipment, if so, then execution step C;
C. the clock of the single-wire bus system is switched to into high frequency clock by low-frequency clock.
The beneficial effect brought of technical scheme that the present invention is provided is:
Knowable to the invention described above, as wherein single-wire bus system includes at least one main device and at least one
It is individual to be communicated by single bus from device, main device and from device;Whether single bus are judged from equipment
Be the first level more than or equal to preset duration in the persistent period, if so, then main device is judged from equipment
Whether open signal is sent, when the clock of single-wire bus system being switched to high frequency by low-frequency clock then if so,
Clock;It is thereby achieved that the loitering phase in single-wire bus system communication adopts low-frequency clock, power consumption is reduced
The waste of amount.
Description of the drawings
For the technical scheme being illustrated more clearly that in the embodiment of the present invention, below will be to institute in embodiment description
The accompanying drawing that needs are used is briefly described, it should be apparent that, drawings in the following description are only the present invention
Some embodiments, for those of ordinary skill in the art, on the premise of not paying creative work,
Can be with according to these other accompanying drawings of accompanying drawings acquisition.
Fig. 1 is a kind of flow chart of the communication means of single-wire bus system provided in an embodiment of the present invention;
Fig. 2 is open signal sequential chart;
Fig. 3 is that single-wire bus system opens sequential chart;
1 high level and 1 low level pulse sequence diagram when Fig. 4 is high frequency clock;
1 high level and 1 low level pulse sequence diagram when Fig. 5 is low-frequency clock;
Fig. 6 is another kind of flow chart of the communication means of single-wire bus system provided in an embodiment of the present invention;
Fig. 7 is read data frame structure chart;
Fig. 8 is write data frame structure chart.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to the present invention
Embodiment is described in further detail.
The embodiment of the present invention provides the flow process of the communication means of single-wire bus system, referring to Fig. 1, single bus system
The communication means of system includes:
101:Judge whether single bus are more than or equal to the first of preset duration in the persistent period from equipment
Level, if so, then execution step 102.
102:Judge whether main device sends open signal from equipment, if so, then execution step 103.
In being embodied as, open signal sequential can include pulse and 4 frequencies of 4 frequencies for 0.5kHz
For the pulse of 1kHz, as shown in Figure 2.
103:The clock of single-wire bus system is switched to into high frequency clock by low-frequency clock.
For example, when the first level is low level, the unlatching sequential chart of single-wire bus system as shown in figure 3,
At stage (1), the low level of the level of single bus, at stage (2), the level of single bus
For open signal, at the end of the stage (2), the clock of single-wire bus system is switched to by low-frequency clock
High frequency clock.
In all steps of Fig. 1, single-wire bus system is by judging high level pulse and low level pulse
Continuous number is to determine data as high level or low level.
Wherein, when the clock of single-wire bus system is high frequency clock, single-wire bus system is by judging high electricity
The continuous number of flat pulse and low level pulse is to determine data as high level or low level is specially:
When continuously there is 2 low level pulses and 8 high level pulses, then data are judged as 1 high electricity
It is flat.
When continuously there is 8 pulses lows and 2 pulse high levels, then data are judged as 1 low electricity
It is flat.
Now, 1 high level and 1 low level pulse train are as shown in Figure 4.
Wherein, when the clock of single-wire bus system is low-frequency clock, single-wire bus system is by judging high electricity
The continuous number of flat pulse and low level pulse is to determine data as high level or low level is specially:
When continuously there is 2 low level pulses and 20 high level pulses, then data are judged as 1 high electricity
It is flat;
When continuously there is 20 pulses lows and 2 pulse high levels, then data are judged as 1 low electricity
It is flat.
Now, 1 high level and 1 low level pulse train are as shown in Figure 5.
Alternatively, as shown in fig. 6, also including step 104-1 to 107-1 after step 103:
104-1:Judge whether main device sends reading control word from equipment, if so, execution step 105-1, if
It is no, execution step 106-1;
105-1:Single-wire bus system enters read operation pattern, sends read data frame to main device from device.
In being embodied as, as shown in fig. 7, read data frame can include reading bytes field, read address field
With reading data field.Wherein, the content of reading bytes field is the byte number for needing to read, and reads address field
Content is the address read, and the content for reading data field is the data come of reading back.
106-1:Judge whether main device sends from equipment and write control word, if so, execution step 107-1.
107-1:Single-wire bus system enters write operation pattern, and main device sends write data frame to from device.
In being embodied as, as shown in figure 8, write data frame can include write verse number field, write address field
With write data field.Wherein, the content of write verse number field is the byte number for needing to write, write address field
Content is the address write, and the content for writing data field is the data for needing write.
Alternatively, as shown in fig. 6, step 104-2 to 105-2 can also be included after step 103:
104-2:Judge whether main device sends reset control word from equipment, if so, execution step 105-2;
105-2:Single-wire bus system enters reset mode, and single bus are used as general-purpose data line.
Alternatively, as shown in fig. 6, step 100 can also be included before step 101:
100:Judge whether depositor is preset value from equipment, if so, execution step 101.
To sum up, the embodiment of the present invention includes at least one main device and at least one by wherein single-wire bus system
It is individual to be communicated by single bus from device, main device and from device;Whether single bus are judged from equipment
Be the first level more than or equal to preset duration in the persistent period, if so, then main device is judged from equipment
Whether open signal is sent, when the clock of single-wire bus system being switched to high frequency by low-frequency clock then if so,
Clock;It is thereby achieved that the loitering phase in single-wire bus system communication adopts low-frequency clock, power consumption is reduced
The waste of amount.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that realizing that all or part of step of above-described embodiment can pass through
Hardware is completing, it is also possible to instruct the hardware of correlation to complete by program, described program can be stored in
In a kind of computer-readable recording medium, storage medium mentioned above can be read only memory, disk or
CD etc..
Presently preferred embodiments of the present invention is the foregoing is only, it is not to limit the present invention, all the present invention's
Within spirit and principle, any modification, equivalent substitution and improvements made etc. should be included in the present invention's
Within protection domain.