Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT Monitoring Module
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
DIOT Monitoring Module
Commits
a4459f10
Commit
a4459f10
authored
Oct 20, 2021
by
Christos Gentsos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Main: store fan settings on the flash, making it persistent
parent
962f456a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
flash_utils.h
common/include/flash_utils.h
+8
-1
user_flash.bin
main_fw/build/user_flash.bin
+0
-0
i2c_impl.c
main_fw/src/i2c_impl.c
+31
-0
main.c
main_fw/src/main.c
+10
-1
No files found.
common/include/flash_utils.h
View file @
a4459f10
...
...
@@ -12,8 +12,15 @@
typedef
struct
{
//! check if we want to enable the remote programming functionality
uint32_t
copy_fw
;
//! store fan configuration and speeds
uint16_t
setfrpms
[
3
];
uint16_t
fan_installed
[
3
];
uint16_t
fan_cmdrpm
[
3
];
uint16_t
fan_ppr
[
3
];
//! provide some (optional) user data storage
uint8_t
user_data
[
2
52
];
uint8_t
user_data
[
2
28
];
}
user_flash_t
;
extern
user_flash_t
user_flash
;
...
...
main_fw/build/user_flash.bin
View file @
a4459f10
No preview for this file type
main_fw/src/i2c_impl.c
View file @
a4459f10
...
...
@@ -271,6 +271,23 @@ void __xMR fan_config()
fan_installed
[
2
]
=
(
fan_config_3_4
>>
7
)
&
0x1
;
fan_cmdrpm
[
2
]
=
(
fan_config_3_4
>>
6
)
&
0x1
;
fan_ppr
[
2
]
=
(
fan_config_3_4
>>
4
)
&
0x3
;
uint32_t
*
char_user_flash
=
(
uint32_t
*
)
&
user_flash
;
user_flash_t
*
tmp_user_flash
=
(
user_flash_t
*
)
&
fw_write_buf
;
/* backup existing user data */
for
(
uint8_t
i
=
0
;
i
<
FLASH_ROW_SIZE
/
4
;
++
i
)
fw_write_buf
[
i
]
=
char_user_flash
[
i
];
/* set 0xBEC0ABCD copy FW code */
for
(
uint8_t
i
=
0
;
i
<
3
;
++
i
)
{
tmp_user_flash
->
fan_installed
[
i
]
=
fan_installed
[
i
];
tmp_user_flash
->
fan_cmdrpm
[
i
]
=
fan_cmdrpm
[
i
];
tmp_user_flash
->
fan_ppr
[
i
]
=
fan_ppr
[
i
];
}
/* copy modified block back to the flash */
flash_write_row
((
uint32_t
*
)
&
user_flash
,
(
uint32_t
*
)
fw_write_buf
);
}
...
...
@@ -279,6 +296,20 @@ void __xMR set_frpms()
setfrpms
[
0
]
=
linear_to_float
(
setfrpms_lin
[
0
]);
setfrpms
[
1
]
=
linear_to_float
(
setfrpms_lin
[
1
]);
setfrpms
[
2
]
=
linear_to_float
(
setfrpms_lin
[
2
]);
uint32_t
*
char_user_flash
=
(
uint32_t
*
)
&
user_flash
;
user_flash_t
*
tmp_user_flash
=
(
user_flash_t
*
)
&
fw_write_buf
;
/* backup existing user data */
for
(
uint8_t
i
=
0
;
i
<
FLASH_ROW_SIZE
/
4
;
++
i
)
fw_write_buf
[
i
]
=
char_user_flash
[
i
];
/* set 0xBEC0ABCD copy FW code */
for
(
uint8_t
i
=
0
;
i
<
3
;
++
i
)
tmp_user_flash
->
setfrpms
[
i
]
=
setfrpms
[
i
];
/* copy modified block back to the flash */
flash_write_row
((
uint32_t
*
)
&
user_flash
,
(
uint32_t
*
)
fw_write_buf
);
}
...
...
main_fw/src/main.c
View file @
a4459f10
...
...
@@ -56,13 +56,15 @@ uint16_t tacho_rpm[3];
// duty cycle (0 to 1000)
#if defined(MMFANT) || defined(MMPROT)
uint16_t
fan_installed
[
3
]
__xMR
=
{
1
,
1
,
1
};
uint16_t
setfrpms
[
3
]
__xMR
=
{
600
,
600
,
600
};
#else
uint16_t
fan_installed
[
3
]
__xMR
=
{
0
,
0
,
0
};
uint16_t
setfrpms
[
3
]
__xMR
=
{
0
,
0
,
0
};
#endif
uint16_t
fan_cmdrpm
[
3
]
__xMR
=
{
0
,
0
,
0
};
uint16_t
fan_ppr
[
3
]
__xMR
=
{
1
,
1
,
1
};
// a 1 here means 2 pulses per revolution
uint16_t
setfrpms
[
3
]
__xMR
=
{
600
,
600
,
600
};
// static user_flash_t myflash __attribute__((aligned(256))) __attribute__((used)) = {.copy_fw = 0, .setfrpms = {600, 600, 600}, .fan_installed = {1, 1, 1}, .fan_cmdrpm = {0, 0, 0}, .fan_ppr = {1, 1, 1}}; // helper struct to grab user_flash.bin initialization data
pid_cntrl_t
PID1
__xMR
;
pid_cntrl_t
PID2
__xMR
;
...
...
@@ -466,6 +468,13 @@ int main(void)
ext_irq_enable
(
PIN_PA13
);
ext_irq_enable
(
PIN_PB10
);
for
(
uint8_t
i
=
0
;
i
<
3
;
++
i
)
{
fan_installed
[
i
]
=
user_flash
.
fan_installed
[
i
];
fan_cmdrpm
[
i
]
=
user_flash
.
fan_cmdrpm
[
i
];
fan_ppr
[
i
]
=
user_flash
.
fan_ppr
[
i
];
setfrpms
[
i
]
=
user_flash
.
setfrpms
[
i
];
}
update_pwm
();
pwm_enable
(
&
PWM_0
);
pwm_enable
(
&
PWM_1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment