dev
This commit is contained in:
parent
39cce4bbde
commit
38b0853c32
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#define EE_ARM_OFFSET_H 0x10 // ARM offset high byte
|
#define EE_ARM_OFFSET_H 0x10 // ARM offset high byte
|
||||||
#define EE_ARM_OFFSET_L 0x11 // ARM offset low byte
|
#define EE_ARM_OFFSET_L 0x11 // ARM offset low byte
|
||||||
|
#define EE_SPOOL_RATIO_H 0x12
|
||||||
|
#define EE_SPOOL_RATIO_L 0x13
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
// API publique
|
// API publique
|
||||||
|
|||||||
@ -5,12 +5,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
// Registres Modbus
|
// Registres Modbus
|
||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
#define REG_CTRL 0x0800 // registre de contrôle commun
|
#define REG_CTRL 0x0800 // registre de contrôle commun
|
||||||
#define SPOOL_REG_FREQ 0x0801 // fréquence Step (Hz)
|
#define SPOOL_REG_FREQ 0x0801 // fréquence Step (Hz)
|
||||||
|
#define SPOOL_REG_RATIO 0x0806 // ratio démultiplication (millièmes, ex: 1000=1:1)
|
||||||
|
|
||||||
// bits REG_CTRL
|
// bits REG_CTRL
|
||||||
#define CTRL_SPOOL_ENABLE ((uint16_t)(1U << 15)) // bit15 : SPOOL enable
|
#define CTRL_SPOOL_ENABLE ((uint16_t)(1U << 15)) // bit15 : SPOOL enable
|
||||||
@ -39,8 +41,11 @@
|
|||||||
// ─────────────────────────────────────────────
|
// ─────────────────────────────────────────────
|
||||||
|
|
||||||
void SPOOL_Init(void);
|
void SPOOL_Init(void);
|
||||||
void SPOOL_TimerISR(void); // ISR Timer5 basse priorité
|
void SPOOL_TimerISR(void); // ISR Timer5 haute priorité
|
||||||
void SPOOL_SetCtrl(uint16_t ctrl); // écriture registre 0x0800
|
void SPOOL_SetCtrl(uint16_t ctrl); // écriture registre 0x0800
|
||||||
void SPOOL_SetFreq(uint16_t hz); // écriture registre 0x0801
|
void SPOOL_SetFreq(uint16_t hz); // écriture registre 0x0801
|
||||||
|
void SPOOL_SetRatio(uint16_t milli); // écriture registre 0x0806 + sauvegarde EEPROM
|
||||||
|
|
||||||
|
extern volatile uint16_t arm_target_position; // position cible ARM (micropas)
|
||||||
|
|
||||||
#endif // SPOOL_H
|
#endif // SPOOL_H
|
||||||
20
src/main.c
20
src/main.c
@ -10,7 +10,16 @@
|
|||||||
void main(void) {
|
void main(void) {
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
while(1) {
|
uint16_t arm_current_position = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (arm_current_position < arm_target_position) {
|
||||||
|
arm_current_position++;
|
||||||
|
ARM_HSTEP();
|
||||||
|
} else if (arm_current_position > arm_target_position) {
|
||||||
|
arm_current_position--;
|
||||||
|
ARM_HSTEP();
|
||||||
|
}
|
||||||
RTU_Task();
|
RTU_Task();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,13 +27,12 @@ void main(void) {
|
|||||||
void __interrupt(low_priority) LOWprio_interrupt(void) {
|
void __interrupt(low_priority) LOWprio_interrupt(void) {
|
||||||
if (PIR1bits.TMR2IF)
|
if (PIR1bits.TMR2IF)
|
||||||
RTU_TimerISR();
|
RTU_TimerISR();
|
||||||
if (PIR3bits.TMR5IF)
|
|
||||||
SPOOL_TimerISR();
|
|
||||||
}
|
|
||||||
|
|
||||||
void __interrupt(high_priority) HIGHprio_interrupt(void) {
|
|
||||||
if (PIR1bits.RCIF)
|
if (PIR1bits.RCIF)
|
||||||
RTU_RxISR();
|
RTU_RxISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __interrupt(high_priority) HIGHprio_interrupt(void) {
|
||||||
|
if (PIR3bits.TMR5IF)
|
||||||
|
SPOOL_TimerISR();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user