예제 #1
0
/**
  * @brief Reads any byte from flash memory
  * @param[in] Address Address to read
  * @retval u8 Value read
  * @par Required preconditions:
    * PointerAttr define is declared in the stm8s.h file to select if pointer will be declared
  *    as near (2 bytes) or far (3 bytes).
  */
u8 FLASH_ReadByte(u32 Address)
{
    /* Check parameter */
    assert_param(IS_FLASH_ADDRESS_OK(Address));
    return(*((PointerAttr u8*) Address)); /* Read byte */

}
예제 #2
0
/**
  * @brief Erases one byte in the program or data EEPROM memory
  * @param[in] Address Address of the byte to erase
  * @retval
  * None.
  * @par Required preconditions:
    * PointerAttr define is declared in the stm8s.h file to select if pointer will be declared
  *    as near (2 bytes) or far (3 bytes).
*/
void FLASH_EraseByte(u32 Address)
{
    /* Check parameter */
    assert_param(IS_FLASH_ADDRESS_OK(Address));
    *((PointerAttr u8*) Address) = FLASH_CLEAR_BYTE; /* Erase byte */

}
예제 #3
0
/**
  * @brief  Programs one word (4 bytes) in program or data EEPROM memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if 
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : The address where the data will be programmed
  * @param  Data : Value to be programmed
  * @retval None
  */
void FLASH_ProgramWord(uint32_t Address, uint32_t Data)
{
  /* Check parameters */
  assert_param(IS_FLASH_ADDRESS_OK(Address));
  
  /* Enable Word Write Once */
  FLASH->CR2 |= FLASH_CR2_WPRG;
  FLASH->NCR2 &= (uint8_t)(~FLASH_NCR2_NWPRG);
  
#ifndef _SDCC_
  /* Write one byte - from lowest address*/
  *((PointerAttr uint8_t*)(MemoryAddressCast)Address)       = *((uint8_t*)(&Data));
  /* Write one byte*/
  *(((PointerAttr uint8_t*)(MemoryAddressCast)Address) + 1) = *((uint8_t*)(&Data)+1); 
  /* Write one byte*/    
  *(((PointerAttr uint8_t*)(MemoryAddressCast)Address) + 2) = *((uint8_t*)(&Data)+2); 
  /* Write one byte - from higher address*/
  *(((PointerAttr uint8_t*)(MemoryAddressCast)Address) + 3) = *((uint8_t*)(&Data)+3); 
#else
  write_byte_address(Address    , *((uint8_t*)(&Data)));    // SDCC patch: required for far pointers
  write_byte_address(Address + 1, *((uint8_t*)(&Data)+1));
  write_byte_address(Address + 2, *((uint8_t*)(&Data)+2));
  write_byte_address(Address + 3, *((uint8_t*)(&Data)+3));
#endif // _SDCC_
}
예제 #4
0
/**************************************************************************
* @brief   Programs one byte in program or data EEPROM memory
* @note   PointerAttr define is declared in the stm8s.h file to select if 
*         the pointer will be declared as near (2 bytes) or far (3 bytes).
* @param  Address : Address where the byte will be programmed
* @param  Data : Value to be programmed
* @retval None
***************************************************************************/
void FLASH_ProgramByte(uint32_t Address, uint8_t Data)
{
    /* Check parameters */
    if(IS_FLASH_ADDRESS_OK(Address))
		{
			*(PointerAttr uint8_t*) (uint16_t)Address = Data;
		}	
}
예제 #5
0
/**
  * @brief   Reads any byte from flash memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : Address to read
  * @retval Value of the byte
  */
uint8_t FLASH_ReadByte(uint32_t Address)
{
    /* Check parameter */
    assert_param(IS_FLASH_ADDRESS_OK(Address));

    /* Read byte */
    return(*(PointerAttr uint8_t *) (uint16_t)Address);

}
예제 #6
0
/**
  * @brief   Erases one byte in the program or data EEPROM memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : Address of the byte to erase
  * @retval None
  */
void FLASH_EraseByte(uint32_t Address)
{
    /* Check parameter */
    assert_param(IS_FLASH_ADDRESS_OK(Address));

    /* Erase byte */
   *(PointerAttr uint8_t*) (uint16_t)Address = FLASH_CLEAR_BYTE;

}
예제 #7
0
/**
  * @brief  Reads any byte from flash memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if 
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : Address to read
  * @retval Value of the byte
  */
uint8_t FLASH_ReadByte(uint32_t Address)
{
  /* Check parameter */
  assert_param(IS_FLASH_ADDRESS_OK(Address));
  
  /* Read byte */
#ifndef _SDCC_
  return(*(PointerAttr uint8_t *) (MemoryAddressCast)Address); 
#else
  return(read_byte_address(Address));    // SDCC patch: required for far pointers
#endif // _SDCC_
}
예제 #8
0
/**
  * @brief  Programs one byte in program or data EEPROM memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if 
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : Address where the byte will be programmed
  * @param  Data : Value to be programmed
  * @retval None
  */
void FLASH_ProgramByte(uint32_t Address, uint8_t Data)
{
  /* Check parameters */
  assert_param(IS_FLASH_ADDRESS_OK(Address));

  /* Program byte */
#ifndef _SDCC_
  *(PointerAttr uint8_t*) (MemoryAddressCast)Address = Data;
#else
  write_byte_address(Address, Data);    // SDCC patch: required for far pointers
#endif // _SDCC_

}
예제 #9
0
/**
  * @brief  Erases one byte in the program or data EEPROM memory
  * @note   PointerAttr define is declared in the stm8s.h file to select if 
  *         the pointer will be declared as near (2 bytes) or far (3 bytes).
  * @param  Address : Address of the byte to erase
  * @retval None
  */
void FLASH_EraseByte(uint32_t Address)
{
  /* Check parameter */
  assert_param(IS_FLASH_ADDRESS_OK(Address));
  
  /* Erase byte */
#ifndef _SDCC_
  *(PointerAttr uint8_t*) (MemoryAddressCast)Address = FLASH_CLEAR_BYTE; 
#else
  write_byte_address(Address, FLASH_CLEAR_BYTE);    // SDCC patch: required for far pointers
#endif // _SDCC_

}
예제 #10
0
/**
  * @brief Programs one word (4 bytes) in program or data EEPROM memory
  * @param[in] Address Adress where the byte is written
  * @param[in] Data Value to be written
  * @retval
  * None.
  * @par Required preconditions:
    * PointerAttr define is declared in the stm8s.h file to select if pointer will be declared
  *    as near (2 bytes) or far (3 bytes).
  */
void FLASH_ProgramWord(u32 Address, u32 Data)
{
    /* Check parameters */
    assert_param(IS_FLASH_ADDRESS_OK(Address));

    /* Enable Word Write Once */
    FLASH->CR2 |= FLASH_CR2_WPRG;
    FLASH->NCR2 &= (u8)(~FLASH_NCR2_NWPRG);

    *((PointerAttr u8*)Address)       = *((u8*)(&Data)); /* Write one byte - from lowest address*/
    *(((PointerAttr u8*)Address) + 1) = *((u8*)(&Data)+1); /* Write one byte*/
    *(((PointerAttr u8*)Address) + 2) = *((u8*)(&Data)+2); /* Write one byte*/
    *(((PointerAttr u8*)Address) + 3) = *((u8*)(&Data)+3); /* Write one byte - from higher address*/
}
예제 #11
0
/**
  * @brief Programs one byte in program or data EEPROM memory
  * @param[in] Address Adress where the byte is written
  * @param[in] Data Value to be written
  * @retval
  * None.
  * @par Required preconditions:
    * PointerAttr define is declared in the stm8s.h file to select if pointer will be declared
  *    as near (2 bytes) or far (3 bytes).
  */
void FLASH_ProgramByte(u32 Address, u8 Data)
{
    /* Check parameters */
    assert_param(IS_FLASH_ADDRESS_OK(Address));
    *((PointerAttr u8*) Address) = Data;
}