Methods for data synchronization between a sensor hub and an application processor and apparatuses using the same
A method provides data synchronization between a sensor hub and an application processor, which contains at least the following steps: generating and adding a plurality of absolute time stamps in a sensor-data stream; and generating and adding a plurality of pieces of sensor data and a plurality of relative time stamps in the sensor-data stream between the moments of generating each two adjacent absolute time stamps, wherein each relative time stamp is associated with one piece of sensor data.
1. A method for data synchronization between a sensor hub and an application processor, comprising:
reading an ID (identifier) from a sensor-data stream;
determining whether the ID is a time ID;
when the ID is the time ID, reading an absolute time stamp from the sensor-data stream and storing the absolute time stamp in the application processor;
when the ID is not the time ID, reading sensor data and a relative time stamp from the sensor-data stream, generating a recovered time stamp according to the absolute time stamp and the relative time stamp and converting the recovered time stamp to a value of an RTC (Real-time Counter) of the application processor;
after issuing an interrupt to the sensor hub, reading a first up-to-date value of an RTC of the sensor hub; and
calculating a bias according to the first up-to-date value and a second up-to-date value corresponding to a prior interrupt;
wherein the bias is calculated by using an Equation as follows:
σ= TS p −( f ( TS t )− f ( TS t-1 )),
wherein σ represents the bias, TS p represents a counter value of an interrupt period, TS t represents the first up-to-date value, TS t-1 represents the second up-to-date value and f( ) represents a conversion function.
2. The method of claim 1 , wherein the sensor data and the converted value are sent to an application, thereby enabling the application to generate a control signal accordingly and complete a designated function according to the control signal.
3. The method of claim 1 , wherein the recovered time stamp is generated by using an Equation as follows:
TS rc =TS a +TS b ,
wherein TS rc represents the recovered time stamp, TS a represents the absolute time stamp and TS b represents the relative time stamp, and the converted value is generated by using an Equation as follows:
TS cnv =f ( TS rc ),
wherein TS cnv represents the converted value, TS rc represents the recovered time stamp and f( ) represents a conversion function.
4. The method of claim 1 , wherein the recovered time stamp is generated by using an Equation as follows:
TS rc =TS a +TS b ,
wherein TS rc represents the recovered time stamp, TS a represents the absolute time stamp and TS b represents the relative time stamp, and the converted value is generated by using an Equation as follows:
TS cnv =f ( TS rc )+σ,
wherein TS cnv represents the converted value, TS rc represents the recovered time stamp, f( ) represents a conversion function and σ represents the bias.
5. An apparatus for data synchronization between a sensor hub and an application processor, comprising:
a memory storing a sensor-data stream;
a sensor hub, coupled to a micro-sensor and the memory, generating and adding a plurality of first absolute time stamps in the sensor-data stream; and generating and adding a plurality of pieces of first sensor data and a plurality of first relative time stamps in the sensor-data stream between the moments of generating each two adjacent first absolute time stamps, wherein each first relative time stamp is associated with one piece of first sensor data; and
an application processor, coupled to the memory, reading an ID (identifier) from the sensor-data stream; determining whether the ID is a time ID; when the ID is the time ID, reading a second absolute time stamp from the sensor-data stream and storing the second absolute time stamp in the application processor; and when the ID is not the time ID, reading one piece of second sensor data and a second relative time stamp from the sensor-data stream, generating a recovered time stamp according to the second absolute time stamp and the second relative time stamp and converting the recovered time stamp to a value of an RTC of the application processor;
wherein, after issuing an interrupt to the sensor hub, the application processor reads a first up-to-date value of an RTC of the sensor hub; and calculates a bias according to the first up-to-date value and a second up-to-date value corresponding to a prior interrupt;
wherein the bias is calculated by using an Equation as follows:
σ= TS p −( f ( TS t )− f ( TS t-1 )),
wherein σ represents the bias, TS p represents a counter value of an interrupt period, TS t represents the first up-to-date value, TS t-1 represents the second up-to-date value and f( ) represents a conversion function.
6. The apparatus of claim 5 , wherein the piece of second sensor data and the converted value are sent to an application executed by the application processor, thereby enabling the application to generate a control signal accordingly and complete a designated function according to the control signal.
7. The apparatus of claim 5 , wherein the recovered time stamp is generated by using an Equation as follows:
TS rc =TS a +TS b ,
wherein TS rc represents the recovered time stamp, TS a represents the second absolute time stamp and TS b represents the second relative time stamp, and the converted value is generated by using an Equation as follows:
TS cnv =f ( TS rc )+σ,
wherein TS cnv represents the converted value, TS rc represents the recovered time stamp, f( ) represents a conversion function and σ represents the bias.