对比新文件 |
| | |
| | | /* |
| | | * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and |
| | | * its subsidiaries and affiliates (collectly called MKSEMI). |
| | | * |
| | | * All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * 1. Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * |
| | | * 2. Redistributions in binary form, except as embedded into an MKSEMI |
| | | * integrated circuit in a product or a software update for such product, |
| | | * must reproduce the above copyright notice, this list of conditions and |
| | | * the following disclaimer in the documentation and/or other materials |
| | | * provided with the distribution. |
| | | * |
| | | * 3. Neither the name of MKSEMI nor the names of its contributors may be used |
| | | * to endorse or promote products derived from this software without |
| | | * specific prior written permission. |
| | | * |
| | | * 4. This software, with or without modification, must only be used with a |
| | | * MKSEMI integrated circuit. |
| | | * |
| | | * 5. Any software provided in binary form under this license must not be |
| | | * reverse engineered, decompiled, modified and/or disassembled. |
| | | * |
| | | * THIS SOFTWARE IS PROVIDED BY MKSEMI "AS IS" AND ANY EXPRESS OR IMPLIED |
| | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| | | * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| | | * DISCLAIMED. IN NO EVENT SHALL MKSEMI OR CONTRIBUTORS BE LIABLE FOR ANY |
| | | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| | | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| | | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| | | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| | | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | #include "mk_trace.h" |
| | | #include "mk_uwb.h" |
| | | #include "mk_misc.h" |
| | | #include "mk_power.h" |
| | | |
| | | #include "board.h" |
| | | |
| | | #if defined(MK_SIMPLE_TX) |
| | | |
| | | extern int simple_main(void); |
| | | |
| | | struct mk_uwb_configure |
| | | { |
| | | uint8_t phy_work_mode; /* PHY_TX / PHY_RX / PHT_TX|PHY_RX */ |
| | | struct UWB_CONFIG_T phy_cfg; |
| | | }; |
| | | |
| | | /* Default communication configuration. */ |
| | | static struct mk_uwb_configure config = { |
| | | .phy_work_mode = (uint8_t)(PHY_TX), |
| | | .phy_cfg.ch_num = 5, /* Channel number. */ |
| | | .phy_cfg.code_index = 9, /* TRX preamble code */ |
| | | .phy_cfg.mean_prf = MEAN_PRF_64M, /* Mean prf 64/128/256M */ |
| | | .phy_cfg.data_bit_rate = DATA_BR_6M8, /* Data rate 6.8M */ |
| | | .phy_cfg.sync_sym = PREAM_LEN_128, /* Preamble duration, length of preamble 128 */ |
| | | .phy_cfg.sfd_sym = BPRF_NSFD_8, /* Identifier for SFD sequence */ |
| | | .phy_cfg.ranging_bit = 0, /* ranging bit set 0 */ |
| | | .phy_cfg.trx_mode = TRX_MODE_15_4Z_BPRF, /* IEEE802.15.4z - BPRF mode */ |
| | | .phy_cfg.sts_pkt_cfg = STS_PKT_CFG_0, /* SP0 Frame */ |
| | | .phy_cfg.sts_segnum = STS_SEGNUM_BPRF_1, /* Number of STS segments in the frame */ |
| | | .phy_cfg.sts_seglen = STS_SEGLEN_BPRF_64, /* Number of symbols in an STS segment */ |
| | | .phy_cfg.rx_ant_id = UWB_RX_ANT_3, /* UWB RX antenna port */ |
| | | }; |
| | | |
| | | /* - byte 0: frame type (0x49 Data Frame). |
| | | * - byte 1: sequence number, incremented for each new frame. |
| | | * - byte 2 -> 9: Mauna Kea. |
| | | */ |
| | | static uint8_t tx_msg[] = {0x49, 0, 'M', 'A', 'U', 'N', 'A', 'K', 'E', 'A'}; |
| | | |
| | | /* Inter-frame delay period, in milliseconds. */ |
| | | #define TX_DELAY_MS 500 |
| | | |
| | | int simple_main(void) |
| | | { |
| | | // The following peripherals will be initialized in the uwb_open function |
| | | // phy/mac/aes/lsp/phy timers initialized |
| | | uwb_open(); |
| | | |
| | | // Set calibration parameters |
| | | uwb_calibration_params_set(config.phy_cfg.ch_num); |
| | | |
| | | // uwb configure |
| | | uwb_configure(config.phy_work_mode, board_param.tx_power_fcc[CALIB_CH(config.phy_cfg.ch_num)], &config.phy_cfg); |
| | | |
| | | while (1) |
| | | { |
| | | // Target time equals 0 means send immediately |
| | | // Program the MAC to transmit UWB packet |
| | | uwb_tx(tx_msg, sizeof(tx_msg), 0, 0); |
| | | |
| | | // Check the MAC busy state |
| | | while (mac_is_busy()) |
| | | { |
| | | } |
| | | |
| | | LOG_INFO(TRACE_MODULE_APP, "TX Frame Sent\r\n"); |
| | | |
| | | // Power off radio |
| | | power_off_radio(); |
| | | |
| | | sys_timer_delay_ms(TX_DELAY_MS); |
| | | tx_msg[1]++; |
| | | } |
| | | } |
| | | #endif |