Changeset - e8e5873934fa
[Not reviewed]
default
0 2 0
Ethan Zonca (ethanzonca) - 9 years ago 2017-01-18 11:00:26
e@ethanzonca.com
Move power to config.h
2 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
Include/config.h
Show inline comments
 
//
 
// Depth Select Configuration
 
//
 
 
#ifndef CONFIG_H
 
#define CONFIG_H
 
 
 
// --------------------------------------------------------------------------
 
// Transmitter config (si446x.c)
 
// --------------------------------------------------------------------------
 
 
// Transmit power (0-0x7F, 0mW - 40mw?)
 
#define SI446x_POWER 0x02
 
 
#define TUNE_FREQUENCY 433000000UL
 
 
// Internal macros
 
#define hal_init HAL_Init
 
 
 
 
 
// --------------------------------------------------------------------------
 
// ADC config (adc.c)
 
// --------------------------------------------------------------------------
 
 
// Temperature sensor offset (die temperature from ambient, esimate, in Celcius)
 
#define ADC_TEMPERATURE_OFFSET -10
 
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
 
 
// TX delay in milliseconds
 
#define TX_DELAY      70
 
 
// Maximum packet delay
 
#define MAX_PACKET_LEN 512  // bytes
 
 
 
// --------------------------------------------------------------------------
 
// APRS config (aprs.c)
 
// --------------------------------------------------------------------------
 
 
#define SI446x_POWER 0x7f
 
 
// Set your callsign and SSID here. Common values for the SSID are
 
// (from http://zlhams.wikidot.com/aprs-ssidguide):
 
//
 
// - Balloons:  11
 
// - Cars:       9
 
// - Home:       0
 
// - IGate:      5
 
#define S_CALLSIGN      "S"
 
#define S_CALLSIGN_ID   1
 
 
// Destination callsign: APRS (with SSID=0) is usually okay.
 
#define D_CALLSIGN      ""
 
#define D_CALLSIGN_ID   0
 
Libraries/Si446x/si446x.c
Show inline comments
 
@@ -88,97 +88,97 @@ void si446x_init(void)
 
 
    HAL_Delay(10);
 
 
    // GPIO config: Set all GPIOs LOW; Link NIRQ to CTS; Link SDO to MISO; Max drive strength
 
	uint8_t gpio_pin_cfg_command[] = {
 
    		SI446x_CMD_GPIO_PIN_CFG, // Command
 
			SI446x_GPIO_LOW,      // GPIO0 - Power amp control DAC AD5611 Sync Pin
 
			SI446x_GPIO_INPUT,    // GPIO1 - Input for modulation
 
			SI446x_GPIO_LOW,      // GPIO2 - Blue LED
 
			SI446x_GPIO_NOCHANGE, // GPIO3 - Unused
 
			SI446x_GPIO_NOCHANGE, // NIRQ
 
			SI446x_GPIO_NOCHANGE, // 0x11, // SDO
 
			SI446x_GPIO_NOCHANGE, // Gencfg
 
	};
 
    si446x_sendcmd(8, gpio_pin_cfg_command, SI446x_CHECK_ACK);
 
 
    HAL_Delay(10);
 
 
//	uint8_t tune_xo_cmd[] = {
 
//    		SI446x_CMD_SET_PROPERTY,
 
//			SI446x_XO_TUNE_REGISTER_GROUP,
 
//			0x1, // num data
 
//			SI446x_XO_TUNE_REGISTER_PROP,
 
//			SI446x_CRYSTAL_LOAD_TUNING,
 
//    };
 
//    si446x_sendcmd(5, tune_xo_cmd, SI446x_CHECK_ACK);
 
 
    HAL_Delay(10);
 
 
    // Tune to frequency specified
 
	si446x_setchannel(TUNE_FREQUENCY);
 
 
	HAL_Delay(10);
 
 
    // Set to 2FSK mode
 
    uint8_t modemconfig = SI446x_MOD_TYPE_2FSK | SI446x_MOD_TYPE_SOURCE_DIRECTMODE | SI446x_MOD_TYPE_DIRECT_ASYNCH | SI446x_MOD_TYPE_DIRECT_SOURCE_GPIO1; //SI446x_MOD_TYPE_SOURCE_PACKETHANDLER
 
    uint8_t set_modem_mod_type_command[] = {
 
    		SI446x_CMD_SET_PROPERTY,
 
    		SI446x_MOD_TYPE_REGISTER_GROUP,
 
			0x01, // num data
 
			SI446x_MOD_TYPE_REGISTER_PROP,
 
			modemconfig
 
    };
 
    si446x_sendcmd(5, set_modem_mod_type_command, SI446x_CHECK_ACK);
 
 
    HAL_Delay(10);
 
 
	// Set Si446x initial output power, input to power amp (0-0x7F, 0mW - 40mw?)
 
	uint8_t basepower = 0x02;
 
	uint8_t basepower = SI446x_POWER;
 
	// FIXME: basepower should be 0x10 for underperforming units and 0x04 for normal units
 
    uint8_t set_power_level_command[] = {SI446x_CMD_SET_PROPERTY, 0x22, 0x01, 0x01, basepower};
 
	si446x_sendcmd(5, set_power_level_command, SI446x_CHECK_ACK);
 
 
 
	HAL_Delay(10);
 
 
    // Set air data rate
 
    si446x_setdatarate();
 
    HAL_Delay(10);
 
 
	// Tune TX
 
	uint8_t change_state_command[] = {SI446x_CMD_CHANGE_STATE, 0x05}; //  Change to TX tune state
 
    si446x_sendcmd(2, change_state_command, SI446x_CHECK_ACK);
 
    HAL_Delay(10);
 
 
	si446x_cw_status = 0;
 
}
 
 
 
// Perform power-on-reset of Si446x. Takes 20ms.
 
void si446x_reset(void)
 
{
 
	si446x_shutdown();
 
	HAL_Delay(10);
 
	si446x_wakeup();
 
	HAL_Delay(10);
 
}
 
 
 
// Set GPIO pin state on Si446x
 
void si446x_gpio(uint8_t gpio, uint8_t state, uint8_t doack)
 
{
 
	// GPIO invalid
 
	if(gpio > 7)
 
		return;
 
 
	// Default to not changing any GPIO
 
	uint8_t gpio_pin_cfg_command[] = {
 
			SI446x_CMD_GPIO_PIN_CFG, // Command
 
			SI446x_GPIO_NOCHANGE, // GPIO0 - Power amp control DAC AD5611 Sync Pin
 
			SI446x_GPIO_NOCHANGE, // GPIO1 - Input for modulation
 
			SI446x_GPIO_NOCHANGE, // GPIO2 - Blue
 
			SI446x_GPIO_NOCHANGE, // GPIO3 - Unused
 
			SI446x_GPIO_NOCHANGE, // NIRQ
 
			SI446x_GPIO_NOCHANGE, // 0x11, // SDO
 
			SI446x_GPIO_NOCHANGE, // Gencfg
 
	};
0 comments (0 inline, 0 general)