So here is the story:
I have several I2C sensors. I do some value reading cycles, then some voodoo magic to do the calibration, and I get 21 parameters (as floats) which I need to save to AT91SAM7128 chip, to store the calibration data, so at next start up I wouldn't need to do the calibration no more, and I could read the value from the Flash memory of the chip and use them further in the program. If I compile it now everything compiles ok, no errors. But then I add this code to function definitions as suplementary code:
Code: Select all
/* This line tells the compiler that all functions preceeded */
/* by 'RAMFUNC' should be run from RAM and not Flash, */
/* meaning that we can use them to alter flash */
#define RAMFUNC __attribute__ ((section (".ramfunc"), long_call))
#ifndef Flash_h
#define Flash_h
#pragma long_calls
/*-------------------------------*/
/* Flash Status Field Definition */
/*-------------------------------*/
#define AT91C_MC_FSR_MVM ((unsigned int) 0xFF << 8) // (MC) Status Register GPNVMx: General-purpose NVM Bit Status
#define AT91C_MC_FSR_LOCK ((unsigned int) 0xFFFF << 16) // (MC) Status Register LOCKSx: Lock Region x Lock Status
#define ERASE_VALUE 0xFFFFFFFF
/*-----------------------*/
/* Flash size Definition */
/*-----------------------*/
/* 64 Kbytes of Internal High-speed Flash, Organized in 512 Pages of 256 Bytes */
#define FLASH_PAGE_SIZE_BYTE 256
#define FLASH_PAGE_SIZE_LONG 64
#define FLASH_LOCK_BITS_SECTOR 16
#define FLASH_SECTOR_PAGE 64
#define FLASH_LOCK_BITS 8 /* 16 lock bits, each protecting 16 sectors of 32 pages*/
#define FLASH_BASE_ADDRESS 0x00100000
RAMFUNC extern void EEPROM_Init(void);
RAMFUNC extern int EEPROM_Write( unsigned int Flash_Address ,int size ,unsigned int * buff);
RAMFUNC extern void EEPROM_Unlock(unsigned int Flash_Lock);
#endif /* Flash_h */
Code: Select all
/* Setup the EEPROM writing hardware */
RAMFUNC void EEPROM_Init (void)
{
/* Set number of Flash Wait states */
/* AT91SAM7S128 features Single Cycle Access at Up to 30 MHz */
/* if MCK = 47923200, 72 Cycles for 1.5 µseconde ( field MC_FMR->FMCN) */
AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(72 <<16)) | AT91C_MC_FWS_1FWS ;
}
RAMFUNC void NVM_Init (void)
{
/* Set number of Flash wait states */
/* AT91SAM7S64 features Single Cycle Access at Up to 30 MHz */
/* if MCK = 47923200, 48 Cycles for 1 µseconde ( field MC_FMR->FMCN) */
AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(48 <<16)) | AT91C_MC_FWS_1FWS ;
}
/* Wait for the EEPROM writer to read ready */
RAMFUNC void Wait_EEPROM_Ready (void)
{
unsigned int status;
status = 0;
/* Wait until the end of the command */
while ((status & AT91C_MC_FRDY) != AT91C_MC_FRDY )
{
status = AT91C_BASE_MC->MC_FSR;
}
}
/* Unlock an area of the EEPROM so we can write to it */
RAMFUNC void EEPROM_Unlock( unsigned int EEPROM_Page)
{
EEPROM_Init();
/* Write the Clear Lock Bit command */
AT91C_BASE_MC->MC_FCR = AT91C_MC_KEY | AT91C_MC_FCMD_UNLOCK | (AT91C_MC_PAGEN & (EEPROM_Page << 8) ) ;
/* Wait for the end of command */
Wait_EEPROM_Ready();
}
/* Write data to the EEPROM */
RAMFUNC int EEPROM_Write( unsigned int Flash_Address ,int size ,unsigned int * buff)
{
/* Set the Flash controller base address */
AT91PS_MC ptMC = AT91C_BASE_MC;
unsigned int i, page, status;
unsigned int * Flash;
/* Setup flash pointer */
Flash = (unsigned int *) Flash_Address;
EEPROM_Init();
/* Get the Flash page number */
page = ((Flash_Address - (unsigned int)AT91C_IFLASH ) /FLASH_PAGE_SIZE_BYTE);
/* copy the new value */
for (i=0; (i < FLASH_PAGE_SIZE_BYTE) & (size > 0) ;i++, Flash++,buff++,size-=4 ){
*Flash=*buff;
}
/* Send the 'write page' command */
ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (page <<8)) ;
/* Wait for the command to finish */
Wait_EEPROM_Ready();
return true;
}
Code: Select all
Launching the compiler...
C:\Program Files (x86)\Flowcode(ARM)\v5\Tools\MX_bats\arm7comp.bat "Sensor_board" "F:\FLOWCO~1\SPA"
Sensor_board.c:686:1: warning: "RAMFUNC" redefined
In file included from Sensor_board.c:101:
C:/PROGRA~2/FLOWCO~1/v5/Tools/MX_bats/../Global/Board_EB031.h:105:1: warning: this is the location of the previous definition
Sensor_board.c:724: error: conflicting types for 'FCD_I2C_Master0_MI2C_Init'
Sensor_board.c:473: error: previous declaration of 'FCD_I2C_Master0_MI2C_Init' was here
Sensor_board.c:731: error: conflicting types for 'FCD_I2C_Master0_MI2C_Start'
Sensor_board.c:474: error: previous declaration of 'FCD_I2C_Master0_MI2C_Start' was here
Sensor_board.c:738: error: conflicting types for 'FCD_I2C_Master0_MI2C_Restart'
Sensor_board.c:475: error: previous declaration of 'FCD_I2C_Master0_MI2C_Restart' was here
Sensor_board.c:745: error: conflicting types for 'FCD_I2C_Master0_MI2C_Stop'
Sensor_board.c:476: error: previous declaration of 'FCD_I2C_Master0_MI2C_Stop' was here
Sensor_board.c:752: error: conflicting types for 'FCD_I2C_Master0_MI2C_Transmit_Byte'
Sensor_board.c:477: error: previous declaration of 'FCD_I2C_Master0_MI2C_Transmit_Byte' was here
Sensor_board.c:759: error: conflicting types for 'FCD_I2C_Master0_MI2C_Receive_Byte'
Sensor_board.c:478: error: previous declaration of 'FCD_I2C_Master0_MI2C_Receive_Byte' was here
Sensor_board.c:766: error: conflicting types for 'FCD_I2C_Master0_MI2C_Send_Byte_Transaction'
Sensor_board.c:479: error: previous declaration of 'FCD_I2C_Master0_MI2C_Send_Byte_Transaction' was here
Sensor_board.c:780: error: conflicting types for 'FCD_I2C_Master0_MI2C_Receive_Byte_Transaction'
Sensor_board.c:480: error: previous declaration of 'FCD_I2C_Master0_MI2C_Receive_Byte_Transaction' was here
Sensor_board.c:806: error: conflicting types for 'FCD_LCDDisplay0_RawSend'
Sensor_board.c:574: error: previous declaration of 'FCD_LCDDisplay0_RawSend' was here
Sensor_board.c:858: error: conflicting types for 'FCD_LCDDisplay0_Start'
Sensor_board.c:575: error: previous declaration of 'FCD_LCDDisplay0_Start' was here
Sensor_board.c:891: error: conflicting types for 'FCD_LCDDisplay0_Clear'
Sensor_board.c:576: error: previous declaration of 'FCD_LCDDisplay0_Clear' was here
Sensor_board.c:901: error: conflicting types for 'FCD_LCDDisplay0_PrintASCII'
Sensor_board.c:577: error: previous declaration of 'FCD_LCDDisplay0_PrintASCII' was here
Sensor_board.c:908: error: conflicting types for 'FCD_LCDDisplay0_Command'
Sensor_board.c:578: error: previous declaration of 'FCD_LCDDisplay0_Command' was here
Sensor_board.c:916: error: conflicting types for 'FCD_LCDDisplay0_Cursor'
Sensor_board.c:579: error: previous declaration of 'FCD_LCDDisplay0_Cursor' was here
Sensor_board.c:956: error: conflicting types for 'FCD_LCDDisplay0_PrintNumber'
Sensor_board.c:580: error: previous declaration of 'FCD_LCDDisplay0_PrintNumber' was here
Sensor_board.c:1017: error: conflicting types for 'FCD_LCDDisplay0_PrintString'
Sensor_board.c:581: error: previous declaration of 'FCD_LCDDisplay0_PrintString' was here
Sensor_board.c:1033: error: conflicting types for 'FCD_LCDDisplay0_ScrollDisplay'
Sensor_board.c:582: error: previous declaration of 'FCD_LCDDisplay0_ScrollDisplay' was here
Sensor_board.c:1069: error: conflicting types for 'FCD_LCDDisplay0_ClearLine'
Sensor_board.c:583: error: previous declaration of 'FCD_LCDDisplay0_ClearLine' was here
Sensor_board.c:1105: error: conflicting types for 'FCD_LCDDisplay0_RAM_Write'
Sensor_board.c:584: error: previous declaration of 'FCD_LCDDisplay0_RAM_Write' was here
Sensor_board.c:1135: error: conflicting types for 'FCD_SWITCH0_ReadState'
Sensor_board.c:627: error: previous declaration of 'FCD_SWITCH0_ReadState' was here
Sensor_board.c:1185: error: conflicting types for 'FCD_SWITCH0_WaitUntilHigh'
Sensor_board.c:628: error: previous declaration of 'FCD_SWITCH0_WaitUntilHigh' was here
Sensor_board.c:1223: error: conflicting types for 'FCD_SWITCH0_WaitUntilLow'
Sensor_board.c:629: error: previous declaration of 'FCD_SWITCH0_WaitUntilLow' was here
Sensor_board.c:1266: error: conflicting types for 'FCD_LED0_LEDOn'
Sensor_board.c:651: error: previous declaration of 'FCD_LED0_LEDOn' was here
Sensor_board.c:1277: error: conflicting types for 'FCD_LED0_LEDOff'
Sensor_board.c:652: error: previous declaration of 'FCD_LED0_LEDOff' was here
Sensor_board.c:1293: error: conflicting types for 'FCD_LED1_LEDOn'
Sensor_board.c:674: error: previous declaration of 'FCD_LED1_LEDOn' was here
Sensor_board.c:1304: error: conflicting types for 'FCD_LED1_LEDOff'
Sensor_board.c:675: error: previous declaration of 'FCD_LED1_LEDOff' was here
In file included from C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\includes.c:159,
from Sensor_board.c:1314:
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:220: error: conflicting types for 'FC_CAL_I2C_Master_Init_1'
Sensor_board.c:460: error: previous declaration of 'FC_CAL_I2C_Master_Init_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:221: error: conflicting types for 'FC_CAL_I2C_Master_Uninit_1'
Sensor_board.c:461: error: previous declaration of 'FC_CAL_I2C_Master_Uninit_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:222: error: conflicting types for 'FC_CAL_I2C_Master_Start_1'
Sensor_board.c:462: error: previous declaration of 'FC_CAL_I2C_Master_Start_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:223: error: conflicting types for 'FC_CAL_I2C_Master_Restart_1'
Sensor_board.c:463: error: previous declaration of 'FC_CAL_I2C_Master_Restart_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:224: error: conflicting types for 'FC_CAL_I2C_Master_Stop_1'
Sensor_board.c:464: error: previous declaration of 'FC_CAL_I2C_Master_Stop_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:225: error: conflicting types for 'FC_CAL_I2C_Master_TX_Byte_1'
Sensor_board.c:465: error: previous declaration of 'FC_CAL_I2C_Master_TX_Byte_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:226: error: conflicting types for 'FC_CAL_I2C_Master_RX_Byte_1'
Sensor_board.c:466: error: previous declaration of 'FC_CAL_I2C_Master_RX_Byte_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:244: error: conflicting types for 'FC_CAL_I2C_Master_Init_1'
Sensor_board.c:460: error: previous declaration of 'FC_CAL_I2C_Master_Init_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:269: error: conflicting types for 'FC_CAL_I2C_Master_Uninit_1'
Sensor_board.c:461: error: previous declaration of 'FC_CAL_I2C_Master_Uninit_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:281: error: conflicting types for 'FC_CAL_I2C_Master_Start_1'
Sensor_board.c:462: error: previous declaration of 'FC_CAL_I2C_Master_Start_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:298: error: conflicting types for 'FC_CAL_I2C_Master_Restart_1'
Sensor_board.c:463: error: previous declaration of 'FC_CAL_I2C_Master_Restart_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:316: error: conflicting types for 'FC_CAL_I2C_Master_Stop_1'
Sensor_board.c:464: error: previous declaration of 'FC_CAL_I2C_Master_Stop_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:334: error: conflicting types for 'FC_CAL_I2C_Master_TX_Byte_1'
Sensor_board.c:465: error: previous declaration of 'FC_CAL_I2C_Master_TX_Byte_1' was here
C:\Program Files (x86)\Flowcode(ARM)\v5\CAL\/ARM\ARM_CAL_I2C.c:373: error: conflicting types for 'FC_CAL_I2C_Master_RX_Byte_1'
Sensor_board.c:466: error: previous declaration of 'FC_CAL_I2C_Master_RX_Byte_1' was here
Sensor_board.c:1320: error: conflicting types for 'FCM_master_read_i2c'
Sensor_board.c:116: error: previous declaration of 'FCM_master_read_i2c' was here
Sensor_board.c:1402: error: conflicting types for 'FCM_master_write_i2c'
Sensor_board.c:117: error: previous declaration of 'FCM_master_write_i2c' was here
Sensor_board.c:1433: error: conflicting types for 'FCM_tmp102_get_temp'
Sensor_board.c:118: error: previous declaration of 'FCM_tmp102_get_temp' was here
Sensor_board.c:1459: error: conflicting types for 'FCM_bmp085_get_cal_par'
Sensor_board.c:119: error: previous declaration of 'FCM_bmp085_get_cal_par' was here
Sensor_board.c:1504: error: conflicting types for 'FCM_bmp085_read_uval'
Sensor_board.c:120: error: previous declaration of 'FCM_bmp085_read_uval' was here
Sensor_board.c:1544: error: conflicting types for 'FCM_bmp085_cal_press'
Sensor_board.c:121: error: previous declaration of 'FCM_bmp085_cal_press' was here
Sensor_board.c:1610: error: conflicting types for 'FCM_BMP085_osrs'
Sensor_board.c:122: error: previous declaration of 'FCM_BMP085_osrs' was here
Sensor_board.c:1672: error: conflicting types for 'FCM_bmp085_get_ut'
Sensor_board.c:123: error: previous declaration of 'FCM_bmp085_get_ut' was here
Sensor_board.c:1687: error: conflicting types for 'FCM_bmp085_get_up'
Sensor_board.c:124: error: previous declaration of 'FCM_bmp085_get_up' was here
Sensor_board.c:1702: error: conflicting types for 'FCM_bmp085_get_temp'
Sensor_board.c:125: error: previous declaration of 'FCM_bmp085_get_temp' was here
Sensor_board.c:1719: error: conflicting types for 'FCM_bmp085_get_press'
Sensor_board.c:126: error: previous declaration of 'FCM_bmp085_get_press' was here
Sensor_board.c:1741: error: conflicting types for 'FCM_get_atmos_param'
Sensor_board.c:127: error: previous declaration of 'FCM_get_atmos_param' was here
Sensor_board.c: In function 'FCM_get_atmos_param':
Sensor_board.c:1756: warning: passing argument 3 of 'FCI_FLOAT_TO_STRING' discards qualifiers from pointer target type
Sensor_board.c: At top level:
Sensor_board.c:1763: error: conflicting types for 'FCM_bmp085_eoc'
Sensor_board.c:128: error: previous declaration of 'FCM_bmp085_eoc' was here
Sensor_board.c:1775: error: conflicting types for 'FCM_bmp085_init'
Sensor_board.c:129: error: previous declaration of 'FCM_bmp085_init' was here
Sensor_board.c:1806: error: conflicting types for 'FCM_bma180_get_acc'
Sensor_board.c:130: error: previous declaration of 'FCM_bma180_get_acc' was here
Sensor_board.c:1896: error: conflicting types for 'FCM_bma180_init'
Sensor_board.c:131: error: previous declaration of 'FCM_bma180_init' was here
Sensor_board.c:2027: error: conflicting types for 'FCM_acc_new_data'
Sensor_board.c:132: error: previous declaration of 'FCM_acc_new_data' was here
Sensor_board.c:2039: error: conflicting types for 'FCM_convert_acc_to_dec'
Sensor_board.c:133: error: previous declaration of 'FCM_convert_acc_to_dec' was here
Sensor_board.c:2085: error: conflicting types for 'FCM_calc_roll'
Sensor_board.c:134: error: previous declaration of 'FCM_calc_roll' was here
Sensor_board.c:2100: error: conflicting types for 'FCM_calc_pitch'
Sensor_board.c:135: error: previous declaration of 'FCM_calc_pitch' was here
Sensor_board.c:2115: error: conflicting types for 'FCM_rad2deg'
Sensor_board.c:136: error: previous declaration of 'FCM_rad2deg' was here
Sensor_board.c:2130: error: conflicting types for 'FCM_deg2rad'
Sensor_board.c:137: error: previous declaration of 'FCM_deg2rad' was here
Sensor_board.c:2145: error: conflicting types for 'FCM_mag3110_get_mag'
Sensor_board.c:138: error: previous declaration of 'FCM_mag3110_get_mag' was here
Sensor_board.c:2195: error: conflicting types for 'FCM_convert_mag_gyro_to_dec'
Sensor_board.c:139: error: previous declaration of 'FCM_convert_mag_gyro_to_dec' was here
Sensor_board.c:2235: error: conflicting types for 'FCM_calc_heading'
Sensor_board.c:140: error: previous declaration of 'FCM_calc_heading' was here
Sensor_board.c:2281: error: conflicting types for 'FCM_mag3110_init'
Sensor_board.c:141: error: previous declaration of 'FCM_mag3110_init' was here
Sensor_board.c:2317: error: conflicting types for 'FCM_kalman_init'
Sensor_board.c:142: error: previous declaration of 'FCM_kalman_init' was here
Sensor_board.c:2359: error: conflicting types for 'FCM_kalman_getAngleR'
Sensor_board.c:143: error: previous declaration of 'FCM_kalman_getAngleR' was here
Sensor_board.c:2414: error: conflicting types for 'FCM_itg3200_get_gyro'
Sensor_board.c:144: error: previous declaration of 'FCM_itg3200_get_gyro' was here
Sensor_board.c:2471: error: conflicting types for 'FCM_dt_count'
Sensor_board.c:145: error: previous declaration of 'FCM_dt_count' was here
Sensor_board.c:2483: error: conflicting types for 'FCM_kalman_getAngleP'
Sensor_board.c:146: error: previous declaration of 'FCM_kalman_getAngleP' was here
Sensor_board.c:2539: error: conflicting types for 'FCM_kalman_getAngleH'
Sensor_board.c:147: error: previous declaration of 'FCM_kalman_getAngleH' was here
Sensor_board.c:2594: error: conflicting types for 'FCM_itg3200_init'
Sensor_board.c:148: error: previous declaration of 'FCM_itg3200_init' was here
Sensor_board.c:2615: error: conflicting types for 'FCM_invSqrt'
Sensor_board.c:149: error: previous declaration of 'FCM_invSqrt' was here
Sensor_board.c:2631: error: conflicting types for 'FCM_quaternion2eulerAangle'
Sensor_board.c:150: error: previous declaration of 'FCM_quaternion2eulerAangle' was here
Sensor_board.c:2649: error: conflicting types for 'FCM_marg_ahrs_update'
Sensor_board.c:151: error: previous declaration of 'FCM_marg_ahrs_update' was here
Sensor_board.c:2961: error: conflicting types for 'FCM_convert_temp_to_dec'
Sensor_board.c:152: error: previous declaration of 'FCM_convert_temp_to_dec' was here
Sensor_board.c:3006: error: conflicting types for 'FCM_print'
Sensor_board.c:153: error: previous declaration of 'FCM_print' was here
Sensor_board.c:3134: error: conflicting types for 'FCM_init_all_sensors'
Sensor_board.c:154: error: previous declaration of 'FCM_init_all_sensors' was here
Sensor_board.c:3173: error: conflicting types for 'FCM_get_sensor_data'
Sensor_board.c:155: error: previous declaration of 'FCM_get_sensor_data' was here
Sensor_board.c:3214: error: conflicting types for 'FCM_itg3200_calibrate_bias'
Sensor_board.c:156: error: previous declaration of 'FCM_itg3200_calibrate_bias' was here
Sensor_board.c:3261: error: conflicting types for 'FCM_mag_autoCalibrate'
Sensor_board.c:157: error: previous declaration of 'FCM_mag_autoCalibrate' was here
Sensor_board.c:3534: error: conflicting types for 'FCM_bma180_autoCalibrate'
Sensor_board.c:158: error: previous declaration of 'FCM_bma180_autoCalibrate' was here
Sensor_board.c:3925: error: conflicting types for 'FCM_det4x4'
Sensor_board.c:159: error: previous declaration of 'FCM_det4x4' was here
Sensor_board.c:4103: error: conflicting types for 'FCM_det5x5'
Sensor_board.c:160: error: previous declaration of 'FCM_det5x5' was here
Sensor_board.c:5027: error: conflicting types for 'FCM_chck_onlline_sens'
Sensor_board.c:161: error: previous declaration of 'FCM_chck_onlline_sens' was here
Sensor_board.c:5661: error: conflicting types for 'FC_Interrupt'
C:/PROGRA~2/FLOWCO~1/v5/Tools/MX_bats/../Global/MX_interrupts.h:20: error: previous declaration of 'FC_Interrupt' was here
Sensor_board.c:5663: error: conflicting types for 'FC_Interrupt'
C:/PROGRA~2/FLOWCO~1/v5/Tools/MX_bats/../Global/MX_interrupts.h:20: error: previous declaration of 'FC_Interrupt' was here
Error returned from [arm-elf-gcc.exe]
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:
If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.
FINISHED
Another thing is how to correctly modify the read and write functions mentioned in the code above, to store and read floats??
Many thanks for your answers,
Mantas