Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
embedded-linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
embedded-linux
Commits
e8f14985
Commit
e8f14985
authored
4 months ago
by
David Maul
Browse files
Options
Downloads
Patches
Plain Diff
fix: fix invalid timings and wrong byte order in send_byte function
parent
c11f0e91
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/kmod.c
+27
-18
27 additions, 18 deletions
kernel/kmod.c
with
27 additions
and
18 deletions
kernel/kmod.c
+
27
−
18
View file @
e8f14985
...
@@ -16,10 +16,12 @@
...
@@ -16,10 +16,12 @@
#define CLASS_NAME "amogus_class"
#define CLASS_NAME "amogus_class"
#define SLOTS 4
#define SLOTS 4
#define SLOT_INTERVAL_NS 1000000
#define SLOT_INTERVAL_NS 1000000
0
#define MAX_VALUES 16
#define MAX_VALUES 16
#define BAUD_RATE 9600
#define BIT_TIME_US (1000000 / BAUD_RATE)
#define GPIO_PIN 575
#define GPIO_PIN 575
static
int
major_number
;
static
int
major_number
;
...
@@ -101,23 +103,29 @@ static enum hrtimer_restart timer_callback(struct hrtimer *timer) {
...
@@ -101,23 +103,29 @@ static enum hrtimer_restart timer_callback(struct hrtimer *timer) {
return
HRTIMER_RESTART
;
return
HRTIMER_RESTART
;
}
}
static
void
send_bit
(
uint8_t
bit
)
{
static
inline
void
send_bit
(
uint8_t
bit
)
{
gpio_set_value
(
GPIO_PIN
,
bit
);
gpio_set_value
(
GPIO_PIN
,
bit
);
udelay
(
1
);
udelay
(
BIT_TIME_US
);
}
}
static
void
send_byte
(
uint8_t
byte
)
{
static
inline
void
send_byte
(
uint8_t
byte
)
{
send_bit
(
0
);
send_bit
(
0
);
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
send_bit
((
byte
>>
0
)
&
1
);
int
bit
=
(
byte
>>
(
7
-
i
))
&
1
;
send_bit
((
byte
>>
1
)
&
1
);
send_bit
(
bit
);
send_bit
((
byte
>>
2
)
&
1
);
}
send_bit
((
byte
>>
3
)
&
1
);
send_bit
((
byte
>>
4
)
&
1
);
send_bit
((
byte
>>
5
)
&
1
);
send_bit
((
byte
>>
6
)
&
1
);
send_bit
((
byte
>>
7
)
&
1
);
send_bit
(
1
);
send_bit
(
1
);
}
}
static
void
send_data
(
const
packet_t
*
packet
)
{
static
void
send_data
(
const
packet_t
*
packet
)
{
send_byte
(
0xAA
);
/*
send_byte(packet->data.sensor_id);
send_byte(packet->data.sensor_id);
send_byte(packet->data.count);
send_byte(packet->data.count);
...
@@ -132,6 +140,7 @@ static void send_data(const packet_t *packet) {
...
@@ -132,6 +140,7 @@ static void send_data(const packet_t *packet) {
for (size_t i = 0; i < sizeof(uint32_t); i++) {
for (size_t i = 0; i < sizeof(uint32_t); i++) {
send_byte(bytes[i]);
send_byte(bytes[i]);
}
}
*/
}
}
static
int
timed_thread_fn
(
void
*
args
)
{
static
int
timed_thread_fn
(
void
*
args
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment