-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import my code things into Atmel stidio and merge it with board things
- Loading branch information
nicolas-rabault
committed
Aug 3, 2016
1 parent
6e6c37b
commit 0b10182
Showing
219 changed files
with
2,126 additions
and
1,382 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "hal.h" | ||
|
||
#include "asf.h" | ||
#include "stdio_serial.h" | ||
#include "conf_board.h" | ||
#include "conf_clock.h" | ||
#include "uart.h" | ||
#include "time.h" | ||
#include "button.h" | ||
#include "rs485.h" | ||
#include "ptp.h" | ||
#include "test_board.h" | ||
|
||
#include "log.h" | ||
#define LOG_TAG "Main" | ||
#define LOG_LEVEL LOG_LEVEL_DEBUG | ||
|
||
|
||
// Global variables | ||
context_t ctx; | ||
|
||
/** | ||
* \fn void hal_init(void) | ||
* \brief hardware configuration (clock, communication, DMA...) | ||
*/ | ||
void hal_init(void) { | ||
// init all things | ||
sysclk_init(); | ||
board_init(); | ||
|
||
uart_stdio_init(CONSOLE_UART, 115200); | ||
|
||
TEST_LOG_INFO(){ | ||
printf("\n\r\tFirmware Poppy-com built on %s at %s\n\r", __DATE__, __TIME__ ); | ||
} | ||
|
||
if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { | ||
LOG_ERROR("systic config failed"); | ||
while (1); | ||
} | ||
|
||
rs485_init(); | ||
ptp_init(); | ||
|
||
ptp_set_mode(ptp_a, PTP_MODE_RX); | ||
ptp_set_mode(ptp_b, PTP_MODE_RX); | ||
} | ||
|
||
/** | ||
* \fn unsigned char hal_transmit(unsigned char* data) | ||
* \brief write a data byte | ||
* | ||
* \param data *data bytes to send | ||
* \param size size of data to send in byte | ||
* | ||
* \return error | ||
*/ | ||
unsigned char hal_transmit(unsigned char* data, unsigned short size) { | ||
rs485_set_dir(HALF_DUPLEX_TX); | ||
for (unsigned short i = 0; i < size; i++) | ||
{ | ||
if (rs485_write((uint32_t) data[i])) | ||
return 1; | ||
delay_ms(1); | ||
} | ||
rs485_set_dir(HALF_DUPLEX_RX); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef _HAL_H_ | ||
#define _HAL_H_ | ||
|
||
#include "context.h" | ||
|
||
typedef enum { | ||
// Send start condition | ||
START, | ||
// Send data with ACK enable | ||
DATA, | ||
// Send data with ACK disable | ||
DATA_NACK, | ||
// Send stop condition | ||
STOP | ||
}com_state_t; | ||
|
||
void hal_init(void); | ||
|
||
unsigned char hal_transmit(unsigned char* data, unsigned short size); | ||
|
||
#endif /* _HAL_H_ */ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _CMD_H_ | ||
#define _CMD_H_ | ||
|
||
/* | ||
* All applicativ side message should have a structure like : | ||
* ADDR - REGISTER - SIZE - DATA[512] - CHECKSUM | ||
*/ | ||
typedef enum { | ||
GET_ID, /*!< Reply with ID. */ | ||
WRITE_ID, /*!< Get and save a new given ID. */ | ||
GET_MODULE_TYPE, /*!< Reply with module_type number. */ | ||
GET_STATUS, /*!< Reply with a status register. */ | ||
GET_FIRM_REVISION, /*!< Reply with the actual firmware revision number. */ | ||
GET_COM_REVISION, /*!< Reply with the actual communication protocole version (1 default). */ | ||
PROTOCOL_CMD_NB /*!< This is the minimum cmd value available for applicative side. */ | ||
}cmd_t; | ||
|
||
#endif /* _CONTEXT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* This file contain default configuration of the project. | ||
*/ | ||
|
||
#ifndef _CONFIG_H_ | ||
#define _CONFIG_H_ | ||
|
||
#include "mod_list.h" | ||
|
||
#define DEFAULTID 0x01 | ||
#define PROTOCOL_REVISION 1 | ||
#define BROADCAST_VAL 0x0FFF | ||
|
||
#ifndef MODULETYPE | ||
#define MODULETYPE DEV_BOARD | ||
#endif | ||
|
||
#ifndef MAINCLOCK | ||
#define MAINCLOCK 16000000 | ||
#endif | ||
|
||
#ifndef SCLFREQ | ||
#define SCLFREQ 400000 | ||
#endif | ||
|
||
#ifndef MAX_TRIES | ||
#define MAX_TRIES 5 | ||
#endif | ||
|
||
|
||
#endif /* _CONFIG_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef _CONTEXT_H_ | ||
#define _CONTEXT_H_ | ||
|
||
#include "config.h" | ||
#include "poppyNetwork.h" | ||
#include "cmd.h" | ||
|
||
#define TRUE 1 | ||
#define FALSE 0 | ||
|
||
typedef void (*DATA_CB) (volatile unsigned char *data); | ||
|
||
typedef struct { | ||
unsigned char rx_error : 1; | ||
unsigned char unexpected_state : 1; | ||
unsigned char warning : 1; | ||
} status_t; | ||
|
||
|
||
typedef struct { | ||
// Callback pointers | ||
DATA_CB data_cb; /*!< Data management callback. */ | ||
RX_CB rx_cb; /*!< User side slave RX callback. */ | ||
|
||
// Module infomations | ||
unsigned short id; /*!< Module ID. */ | ||
unsigned char type; /*!< Module type. */ | ||
unsigned char alias[16];/*!< Module alias. */ | ||
|
||
// Variables | ||
status_t status; /*!< Status. */ | ||
msg_t msg; /*!< Message. */ | ||
|
||
unsigned char max_multicast_target; /*!< Position pointer of the last multicast target. */ | ||
unsigned short multicast_target_bank[256]; /*!< multicast target bank. */ | ||
|
||
unsigned char max_virtual_target; /*!< Position pointer of the last virtual target. */ | ||
unsigned short virtual_target_bank[256]; /*!< virtual target bank. */ | ||
}context_t; | ||
|
||
extern context_t ctx; | ||
|
||
#endif /* _CONTEXT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* This file list all available modules. | ||
*/ | ||
|
||
#ifndef _MOD_LIST_H_ | ||
#define _MOD_LIST_H_ | ||
|
||
enum { | ||
DEV_BOARD, | ||
MOTOR_BOARD | ||
}; | ||
|
||
#endif /* _MOD_LIST_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _RECEPTION_H_ | ||
#define _RECEPTION_H_ | ||
|
||
#include "context.h" | ||
|
||
unsigned short crc(unsigned char* data, unsigned short size); | ||
|
||
// Callbacks | ||
void get_header(volatile unsigned char *data); | ||
void get_data(volatile unsigned char *data); | ||
void catch_ack(volatile unsigned char *data); | ||
|
||
void msg_complete(void); | ||
|
||
#endif /* _RECEPTION_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _SYS_MSG_H_ | ||
#define _SYS_MSG_H_ | ||
|
||
#include "context.h" | ||
|
||
unsigned char set_extern_id(target_mode_t target_mode, unsigned short target, | ||
unsigned short newid); | ||
void send_ack(void); | ||
// unsigned char get_extern_module_type(unsigned short addr, unsigned short *module_type); | ||
|
||
|
||
|
||
#endif /* _SYS_MSG_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _TARGET_H_ | ||
#define _TARGET_H_ | ||
|
||
#include "context.h" | ||
|
||
unsigned char multicast_target_bank(unsigned short val); | ||
void add_multicast_target(unsigned short target); | ||
|
||
unsigned char virtual_target_bank(unsigned short val); | ||
void add_virtual_target(unsigned short target); | ||
|
||
|
||
#endif /* _TARGET_H_ */ |
Oops, something went wrong.